mercurial/minirst.py
changeset 10972 0a2c6948f5f4
parent 10937 a9d5943d2a30
child 10983 287a5cdf7743
--- a/mercurial/minirst.py	Thu Apr 22 09:57:04 2010 +0200
+++ b/mercurial/minirst.py	Thu Apr 22 10:04:53 2010 +0200
@@ -252,6 +252,15 @@
     return blocks
 
 
+_hgrolere = re.compile(r':hg:`([^`]+)`')
+
+def hgrole(blocks):
+    for b in blocks:
+        if b['type'] == 'paragraph':
+            b['lines'] = [_hgrolere.sub(r'"hg \1"', l) for l in b['lines']]
+    return blocks
+
+
 def addmargins(blocks):
     """Adds empty blocks for vertical spacing.
 
@@ -333,6 +342,7 @@
     blocks = findliteralblocks(blocks)
     blocks, pruned = prunecontainers(blocks, keep or [])
     blocks = inlineliterals(blocks)
+    blocks = hgrole(blocks)
     blocks = splitparagraphs(blocks)
     blocks = updatefieldlists(blocks)
     blocks = findsections(blocks)