# HG changeset patch # User Martin Geisler # Date 1272212394 -7200 # Node ID 68b7d2d668ce63b4032339d019ce1bf8ad91a1f9 # Parent 287a5cdf7743b9e1a1b3123ee84444c09888f1d3 minirst: support all recommended title adornments diff -r 287a5cdf7743 -r 68b7d2d668ce mercurial/minirst.py --- a/mercurial/minirst.py Sun Apr 25 17:48:26 2010 +0200 +++ b/mercurial/minirst.py Sun Apr 25 18:19:54 2010 +0200 @@ -225,6 +225,8 @@ return blocks, pruned +_sectionre = re.compile(r"""^([-=`:.'"~^_*+#])\1+$""") + def findsections(blocks): """Finds sections. @@ -240,7 +242,8 @@ # +------------------------------+ 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 -r 287a5cdf7743 -r 68b7d2d668ce tests/test-minirst.py --- a/tests/test-minirst.py Sun Apr 25 17:48:26 2010 +0200 +++ b/tests/test-minirst.py Sun Apr 25 18:19:54 2010 +0200 @@ -184,8 +184,14 @@ sections = """ -A Somewhat Wide Section Header ------------------------------- +Title +===== + +Section +------- + +Subsection +'''''''''' Markup: ``foo`` and :hg:`help` ------------------------------ diff -r 287a5cdf7743 -r 68b7d2d668ce tests/test-minirst.py.out --- a/tests/test-minirst.py.out Sun Apr 25 17:48:26 2010 +0200 +++ b/tests/test-minirst.py.out Sun Apr 25 18:19:54 2010 +0200 @@ -305,8 +305,14 @@ sections formatted to fit within 20 characters: ---------------------------------------------------------------------- -A Somewhat Wide Section Header ------------------------------- +Title +===== + +Section +------- + +Subsection +'''''''''' Markup: "foo" and "hg help" ---------------------------