[PATCH 1 of 4] minirst: detect bullet lists using asterisks

Gregory Szorc gregory.szorc at gmail.com
Thu Feb 16 01:58:58 UTC 2017


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1487205737 28800
#      Wed Feb 15 16:42:17 2017 -0800
# Node ID dd90d5f7dc1908d9b69e6a4b8165a73757d1c84b
# Parent  afaf3c2b129c8940387fd9928ae4fdc28259d13c
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.

diff --git a/mercurial/minirst.py b/mercurial/minirst.py
--- a/mercurial/minirst.py
+++ b/mercurial/minirst.py
@@ -138,7 +138,7 @@ def findliteralblocks(blocks):
         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':(?![: ])([^:]*)(?<! ):[ ]+(.*)')
diff --git a/tests/test-minirst.py b/tests/test-minirst.py
--- a/tests/test-minirst.py
+++ b/tests/test-minirst.py
@@ -118,6 +118,13 @@ Line blocks are also a form of list:
 | 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)
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
@@ -187,6 +187,12 @@ Line blocks are also a form of list:
 
 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 @@ list:
 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 @@ Line blocks are also a form of list:
  <li> This is the first line.   The line continues here.
  <li> This is the second line.
 </ol>
+<p>
+Bullet lists are also detected:
+</p>
+<ol>
+ <li> This is the first bullet
+ <li> This is the second bullet   It has 2 lines
+ <li> This is the third bullet
+</ol>
 ----------------------------------------------------------------------
 
 == options ==


More information about the Mercurial-devel mailing list