From c38f1813a1c2d7c531517a74c456166af92356b4 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Wed, 17 Jun 2009 17:14:01 -0400 Subject: 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. --- markdown/blockprocessors.py | 8 ++++---- tests/misc/lists6.html | 18 ++++++++++++++++++ tests/misc/lists6.txt | 14 ++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 tests/misc/lists6.html create mode 100644 tests/misc/lists6.txt diff --git a/markdown/blockprocessors.py b/markdown/blockprocessors.py index 79f4db9..7d3b137 100644 --- a/markdown/blockprocessors.py +++ b/markdown/blockprocessors.py @@ -256,11 +256,11 @@ class OListProcessor(BlockProcessor): 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)) @@ -324,7 +324,7 @@ class UListProcessor(OListProcessor): """ Process unordered list blocks. """ TAG = 'ul' - RE = re.compile(r'^[ ]{0,3}[*+-][ ](.*)') + RE = re.compile(r'^[ ]{0,3}[*+-][ ]+(.*)') class HashHeaderProcessor(BlockProcessor): diff --git a/tests/misc/lists6.html b/tests/misc/lists6.html new file mode 100644 index 0000000..24aad38 --- /dev/null +++ b/tests/misc/lists6.html @@ -0,0 +1,18 @@ +

Test five or more spaces as start of list:

+ +

not first item:

+ +

loose list:

+ \ No newline at end of file diff --git a/tests/misc/lists6.txt b/tests/misc/lists6.txt new file mode 100644 index 0000000..f12788f --- /dev/null +++ b/tests/misc/lists6.txt @@ -0,0 +1,14 @@ +Test five or more spaces as start of list: + +* five spaces + +not first item: + +* one space +* five spaces + +loose list: + +* one space + +* five spaces -- cgit v1.2.3