So one can add text without hardcoding the indentation it will need.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
Event Timeline
Comment Actions
- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -391,6 +391,12 @@single documentation block and use it to overwrite the marker in doc. """ entries = []+ markerindent = 0
+ markerpos = doc.find(marker)
+ if markerpos >= 0:
+ newlinepos = doc.rfind('\n', 0, markerpos)
+ if newlinepos >= 0:
+ markerindent = markerpos - newlinepos - 1
Perhaps, it's simpler to use re.sub() instead of doc.replace(...), something
like:
markerre = re.compile(br'^(\s*)%s' % re.escape(marker), re.MULTILINE) markerre.sub(builditemsdoc, doc)