##// END OF EJS Templates
doc, minirst: support hg interpreted text role
Martin Geisler -
r10972:0a2c6948 default
parent child Browse files
Show More
@@ -13,7 +13,16 b' where WRITER is the name of a Docutils w'
13 """
13 """
14
14
15 import sys
15 import sys
16 from docutils.parsers.rst import roles
16 from docutils.core import publish_cmdline
17 from docutils.core import publish_cmdline
18 from docutils import nodes, utils
19
20 def role_hg(name, rawtext, text, lineno, inliner,
21 options={}, content=[]):
22 node = nodes.literal(rawtext, "hg " + utils.unescape(text, True))
23 return [node], []
24
25 roles.register_local_role("hg", role_hg)
17
26
18 if __name__ == "__main__":
27 if __name__ == "__main__":
19 if len(sys.argv) < 2:
28 if len(sys.argv) < 2:
@@ -252,6 +252,15 b' def inlineliterals(blocks):'
252 return blocks
252 return blocks
253
253
254
254
255 _hgrolere = re.compile(r':hg:`([^`]+)`')
256
257 def hgrole(blocks):
258 for b in blocks:
259 if b['type'] == 'paragraph':
260 b['lines'] = [_hgrolere.sub(r'"hg \1"', l) for l in b['lines']]
261 return blocks
262
263
255 def addmargins(blocks):
264 def addmargins(blocks):
256 """Adds empty blocks for vertical spacing.
265 """Adds empty blocks for vertical spacing.
257
266
@@ -333,6 +342,7 b' def format(text, width, indent=0, keep=N'
333 blocks = findliteralblocks(blocks)
342 blocks = findliteralblocks(blocks)
334 blocks, pruned = prunecontainers(blocks, keep or [])
343 blocks, pruned = prunecontainers(blocks, keep or [])
335 blocks = inlineliterals(blocks)
344 blocks = inlineliterals(blocks)
345 blocks = hgrole(blocks)
336 blocks = splitparagraphs(blocks)
346 blocks = splitparagraphs(blocks)
337 blocks = updatefieldlists(blocks)
347 blocks = updatefieldlists(blocks)
338 blocks = findsections(blocks)
348 blocks = findsections(blocks)
@@ -178,3 +178,6 b" debugformat('containers (verbose)', cont"
178 debugformat('containers (debug)', containers, 60, keep=['debug'])
178 debugformat('containers (debug)', containers, 60, keep=['debug'])
179 debugformat('containers (verbose debug)', containers, 60,
179 debugformat('containers (verbose debug)', containers, 60,
180 keep=['verbose', 'debug'])
180 keep=['verbose', 'debug'])
181
182 roles = """Please see :hg:`add`."""
183 debugformat('roles', roles, 60)
@@ -298,3 +298,8 b' Debug output.'
298 []
298 []
299 ----------------------------------------------------------------------
299 ----------------------------------------------------------------------
300
300
301 roles formatted to fit within 60 characters:
302 ----------------------------------------------------------------------
303 Please see "hg add".
304 ----------------------------------------------------------------------
305
General Comments 0
You need to be logged in to leave comments. Login now