diff --git a/mercurial/minirst.py b/mercurial/minirst.py --- a/mercurial/minirst.py +++ b/mercurial/minirst.py @@ -225,6 +225,8 @@ def prunecontainers(blocks, keep): return blocks, pruned +_sectionre = re.compile(r"""^([-=`:.'"~^_*+#])\1+$""") + def findsections(blocks): """Finds sections. @@ -240,7 +242,8 @@ def findsections(blocks): # +------------------------------+ if (block['type'] == 'paragraph' and len(block['lines']) == 2 and - block['lines'][1] == '-' * len(block['lines'][0])): + len(block['lines'][0]) == len(block['lines'][1]) and + _sectionre.match(block['lines'][1])): block['underline'] = block['lines'][1][0] block['type'] = 'section' del block['lines'][1] diff --git a/tests/test-minirst.py b/tests/test-minirst.py --- a/tests/test-minirst.py +++ b/tests/test-minirst.py @@ -184,8 +184,14 @@ debugformat('roles', roles, 60) sections = """ -A Somewhat Wide Section Header ------------------------------- +Title +===== + +Section +------- + +Subsection +'''''''''' Markup: ``foo`` and :hg:`help` ------------------------------ diff --git a/tests/test-minirst.py.out b/tests/test-minirst.py.out --- a/tests/test-minirst.py.out +++ b/tests/test-minirst.py.out @@ -305,8 +305,14 @@ Please see "hg add". sections formatted to fit within 20 characters: ---------------------------------------------------------------------- -A Somewhat Wide Section Header ------------------------------- +Title +===== + +Section +------- + +Subsection +'''''''''' Markup: "foo" and "hg help" ---------------------------