--- 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)
--- a/tests/test-minirst.py Sat Oct 23 17:45:49 2010 +0200
+++ b/tests/test-minirst.py Sat Oct 23 17:30:08 2010 +0200
@@ -214,3 +214,15 @@
"""
debugformat('admonitions', admonitions, 30)
+
+comments = """
+Some text.
+
+.. A comment
+
+ .. An indented comment
+
+ Some indented text.
+"""
+
+debugformat('comments', comments, 30)
--- a/tests/test-minirst.py.out Sat Oct 23 17:45:49 2010 +0200
+++ b/tests/test-minirst.py.out Sat Oct 23 17:30:08 2010 +0200
@@ -334,3 +334,10 @@
This is danger
----------------------------------------------------------------------
+comments formatted to fit within 30 characters:
+----------------------------------------------------------------------
+Some text.
+
+ Some indented text.
+----------------------------------------------------------------------
+