aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2008-11-12 23:11:47 -0500
committerWaylan Limberg <waylan@gmail.com>2008-11-13 23:27:23 -0500
commit45f96216f7ecc24444333186dbfdfa66230ef080 (patch)
tree8846f54dec3ecedb776c0ecb9fdf498f3e1ed97c
parent8d367ca71c610c49d3b3d5c81f49cb38f9e97fb9 (diff)
downloadmarkdown-45f96216f7ecc24444333186dbfdfa66230ef080.tar.gz
markdown-45f96216f7ecc24444333186dbfdfa66230ef080.tar.bz2
markdown-45f96216f7ecc24444333186dbfdfa66230ef080.zip
Fixed funky-list (a ul with child ol items is still an ul and visa-versa). Weird, but it matchs pl and php implementations.
-rwxr-xr-xmarkdown.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/markdown.py b/markdown.py
index 9fc6355..6b43c66 100755
--- a/markdown.py
+++ b/markdown.py
@@ -318,6 +318,7 @@ class OListProcessor(BlockProcessor):
TAG = 'ol'
RE = re.compile(r'^[ ]{0,3}\d+\.[ ](.*)')
+ CHILD_RE = re.compile(r'^[ ]{0,3}((\d+\.)|[*+-])[ ](.*)')
def test(self, parent, block):
return bool(self.RE.match(block))
@@ -325,7 +326,7 @@ class OListProcessor(BlockProcessor):
def run(self, parent, blocks):
items = self.get_items(blocks.pop(0))
sibling = self.lastChild(parent)
- if sibling and sibling.tag == self.TAG:
+ if sibling and (sibling.tag == 'ol' or sibling.tag == 'ul'):
lst = sibling
# make sure previous item is in a p.
if len(lst) and lst[-1].text and not len(lst[-1]):
@@ -353,9 +354,9 @@ class OListProcessor(BlockProcessor):
""" Break a block into list items. """
items = []
for line in block.split('\n'):
- m = self.RE.match(line)
+ m = self.CHILD_RE.match(line)
if m:
- items.append(m.group(1))
+ items.append(m.group(3))
elif line.startswith(' '*4):
if items[-1].startswith(' '*4):
items[-1] = '%s\n%s' % (items[-1], line)