minirst: do not interpret a directive as a literal block stable
authorSimon Heimberg <simohe@besonet.ch>
Mon, 04 Nov 2013 10:23:06 +0100
branchstable
changeset 19992 8ac7b85bd8f9
parent 19987 ba6486076429
child 19993 03ec85b9cfc4
minirst: do not interpret a directive as a literal block When a directive was on its own line, it was interpreted as a literal block. Example of problematic input: .. note:: a note text
mercurial/minirst.py
--- a/mercurial/minirst.py	Wed Nov 06 10:20:18 2013 -0800
+++ b/mercurial/minirst.py	Mon Nov 04 10:23:06 2013 +0100
@@ -106,6 +106,12 @@
                 # Partially minimized form: remove space and both
                 # colons.
                 blocks[i]['lines'][-1] = blocks[i]['lines'][-1][:-3]
+            elif len(blocks[i]['lines']) == 1 and \
+                 blocks[i]['lines'][0].lstrip(' ').startswith('.. ') and \
+                 blocks[i]['lines'][0].find(' ', 3) == -1:
+                # directive on its onw line, not a literal block
+                i += 1
+                continue
             else:
                 # Fully minimized form: remove just one colon.
                 blocks[i]['lines'][-1] = blocks[i]['lines'][-1][:-1]