minirst: handle line breaks in hg role
authorMartin Geisler <mg@aragost.com>
Tue, 18 May 2010 16:24:14 +0200
changeset 11192 babf9a5f5528
parent 11191 c45a47bc4114
child 11193 687c7d395f20
minirst: handle line breaks in hg role
mercurial/minirst.py
--- a/mercurial/minirst.py	Mon May 17 23:11:27 2010 +0200
+++ b/mercurial/minirst.py	Tue May 18 16:24:14 2010 +0200
@@ -257,12 +257,15 @@
     return blocks
 
 
-_hgrolere = re.compile(r':hg:`([^`]+)`')
-
 def hgrole(blocks):
     for b in blocks:
         if b['type'] in ('paragraph', 'section'):
-            b['lines'] = [_hgrolere.sub(r'"hg \1"', l) for l in b['lines']]
+            # Turn :hg:`command` into "hg command". This also works
+            # when there is a line break in the command and relies on
+            # the fact that we have no stray back-quotes in the input
+            # (run the blocks through inlineliterals first).
+            b['lines'] = [l.replace(':hg:`', '"hg ').replace('`', '"')
+                          for l in b['lines']]
     return blocks