Mercurial > public > mercurial-scm > hg-stable
diff mercurial/minirst.py @ 12819:5082e2f3f8e0 stable
minirst: ignore comments
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Sat, 23 Oct 2010 17:30:08 +0200 |
parents | 3c31c0e42b11 |
children | eda77c3e246a |
line wrap: on
line diff
--- a/mercurial/minirst.py Sat Oct 23 17:45:49 2010 +0200 +++ b/mercurial/minirst.py Sat Oct 23 17:30:08 2010 +0200 @@ -292,6 +292,17 @@ i += 2 return blocks +def prunecomments(blocks): + """Remove comments.""" + i = 0 + while i < len(blocks): + b = blocks[i] + if b['type'] == 'paragraph' and b['lines'][0].startswith('.. '): + del blocks[i] + else: + i += 1 + return blocks + _admonitionre = re.compile(r"\.\. (admonition|attention|caution|danger|" r"error|hint|important|note|tip|warning)::", flags=re.IGNORECASE) @@ -405,6 +416,7 @@ blocks = hgrole(blocks) blocks = splitparagraphs(blocks) blocks = updatefieldlists(blocks) + blocks = prunecomments(blocks) blocks = addmargins(blocks) blocks = findadmonitions(blocks) text = '\n'.join(formatblock(b, width) for b in blocks) @@ -432,6 +444,7 @@ blocks = debug(splitparagraphs, blocks) blocks = debug(updatefieldlists, blocks) blocks = debug(findsections, blocks) + blocks = debug(prunecomments, blocks) blocks = debug(addmargins, blocks) blocks = debug(findadmonitions, blocks) print '\n'.join(formatblock(b, 30) for b in blocks)