changeset 31130:6582b3716ae0

minirst: detect bullet lists using asterisks Previously, the "bullet" regular expression excluded the asterisk ('*') as a character denoting a bulleted list. Why I'm not sure because the asterisk seems to be the canonical bullet character in reST these days. This patch makes asterisk-prefixed lines parse as bulleted lists.
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 15 Feb 2017 16:42:17 -0800
parents 71f692f1f678
children 50a49ead4db4
files mercurial/minirst.py tests/test-minirst.py tests/test-minirst.py.out
diffstat 3 files changed, 31 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/minirst.py	Wed Mar 01 20:22:04 2017 +0100
+++ b/mercurial/minirst.py	Wed Feb 15 16:42:17 2017 -0800
@@ -138,7 +138,7 @@
         i += 1
     return blocks
 
-_bulletre = re.compile(r'(-|[0-9A-Za-z]+\.|\(?[0-9A-Za-z]+\)|\|) ')
+_bulletre = re.compile(r'(\*|-|[0-9A-Za-z]+\.|\(?[0-9A-Za-z]+\)|\|) ')
 _optionre = re.compile(r'^(-([a-zA-Z0-9]), )?(--[a-z0-9-]+)'
                        r'((.*)  +)(.*)$')
 _fieldre = re.compile(r':(?![: ])([^:]*)(?<! ):[ ]+(.*)')
@@ -596,7 +596,7 @@
             out.append(' <dt>%s\n <dd>%s\n' % (term, text))
         elif btype == 'bullet':
             bullet, head = lines[0].split(' ', 1)
-            if bullet == '-':
+            if bullet in ('*', '-'):
                 openlist('ul', level)
             else:
                 openlist('ol', level)
--- a/tests/test-minirst.py	Wed Mar 01 20:22:04 2017 +0100
+++ b/tests/test-minirst.py	Wed Feb 15 16:42:17 2017 -0800
@@ -118,6 +118,13 @@
 | This is the first line.
   The line continues here.
 | This is the second line.
+
+Bullet lists are also detected:
+
+* This is the first bullet
+* This is the second bullet
+  It has 2 lines
+* This is the third bullet
 """
 
 debugformats('lists', lists)
--- a/tests/test-minirst.py.out	Wed Mar 01 20:22:04 2017 +0100
+++ b/tests/test-minirst.py.out	Wed Feb 15 16:42:17 2017 -0800
@@ -187,6 +187,12 @@
 
 This is the first line. The line continues here.
 This is the second line.
+
+Bullet lists are also detected:
+
+* This is the first bullet
+* This is the second bullet It has 2 lines
+* This is the third bullet
 ----------------------------------------------------------------------
 
 30 column format:
@@ -231,6 +237,14 @@
 This is the first line. The
 line continues here.
 This is the second line.
+
+Bullet lists are also
+detected:
+
+* This is the first bullet
+* This is the second bullet It
+  has 2 lines
+* This is the third bullet
 ----------------------------------------------------------------------
 
 html format:
@@ -276,6 +290,14 @@
  <li> This is the first line.   The line continues here.
  <li> This is the second line.
 </ol>
+<p>
+Bullet lists are also detected:
+</p>
+<ul>
+ <li> This is the first bullet
+ <li> This is the second bullet   It has 2 lines
+ <li> This is the third bullet
+</ul>
 ----------------------------------------------------------------------
 
 == options ==