--- 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]
--- 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`
------------------------------
--- 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"
---------------------------