mercurial/minirst.py
changeset 26157 65e41f388970
parent 26113 9b70eda7529c
child 26170 61124bf8485f
--- a/mercurial/minirst.py	Wed Sep 02 22:05:58 2015 -0700
+++ b/mercurial/minirst.py	Wed Sep 02 15:12:08 2015 -0400
@@ -727,6 +727,21 @@
             if not secs:
                 # add an initial empty section
                 secs = [('', 0, [])]
+            if b['type'] != 'margin':
+                pointer = 1
+                bindent = b['indent']
+                while pointer < len(secs):
+                    section = secs[-pointer][2][0]
+                    if section['type'] != 'margin':
+                        sindent = section['indent']
+                        if len(section['lines']) > 1:
+                            sindent += len(section['lines'][1]) - \
+                              len(section['lines'][1].lstrip(' '))
+                        if bindent >= sindent:
+                            break
+                    pointer += 1
+                if pointer > 1:
+                    secs.append(('', secs[-pointer][1] + 1, []))
             secs[-1][2].append(b)
     return secs