Commits

Waylan Limberg committed 6f462c3

Fixed ticket 35. Lists now work when padded with five or more spaces after asterisk. Adjusted regex to eat all (one or more) of the spaces. While it may seem wrong (at least in the loose list case), this is how all other implementations work. And it solves a number of edge cases otherwise not accounted for in the list parser.

Comments (0)

Files changed (3)

markdown/blockprocessors.py

 
     TAG = 'ol'
     # Detect an item (``1. item``). ``group(1)`` contains contents of item.
-    RE = re.compile(r'^[ ]{0,3}\d+\.[ ](.*)')
+    RE = re.compile(r'^[ ]{0,3}\d+\.[ ]+(.*)')
     # Detect items on secondary lines. they can be of either list type.
-    CHILD_RE = re.compile(r'^[ ]{0,3}((\d+\.)|[*+-])[ ](.*)')
+    CHILD_RE = re.compile(r'^[ ]{0,3}((\d+\.)|[*+-])[ ]+(.*)')
     # Detect indented (nested) items of either type
-    INDENT_RE = re.compile(r'^[ ]{4,7}((\d+\.)|[*+-])[ ].*')
+    INDENT_RE = re.compile(r'^[ ]{4,7}((\d+\.)|[*+-])[ ]+.*')
 
     def test(self, parent, block):
         return bool(self.RE.match(block))
     """ Process unordered list blocks. """
 
     TAG = 'ul'
-    RE = re.compile(r'^[ ]{0,3}[*+-][ ](.*)')
+    RE = re.compile(r'^[ ]{0,3}[*+-][ ]+(.*)')
 
 
 class HashHeaderProcessor(BlockProcessor):

tests/misc/lists6.html

+<p>Test five or more spaces as start of list:</p>
+<ul>
+<li>five spaces</li>
+</ul>
+<p>not first item:</p>
+<ul>
+<li>one space</li>
+<li>five spaces</li>
+</ul>
+<p>loose list:</p>
+<ul>
+<li>
+<p>one space</p>
+</li>
+<li>
+<p>five spaces</p>
+</li>
+</ul>

tests/misc/lists6.txt

+Test five or more spaces as start of list:
+
+*     five spaces
+
+not first item:
+
+* one space
+*     five spaces
+
+loose list:
+
+* one space
+
+*     five spaces