changeset 11192:babf9a5f5528

minirst: handle line breaks in hg role
author Martin Geisler <mg@aragost.com>
date Tue, 18 May 2010 16:24:14 +0200
parents c45a47bc4114
children 687c7d395f20
files mercurial/minirst.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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