aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2010-03-15 20:31:59 -0400
committerWaylan Limberg <waylan@gmail.com>2010-03-15 20:41:26 -0400
commitbdf27a37a8cec16d5c0cc53e8a17e4b1ceacbd50 (patch)
tree8e33a1f9a567c0ac1838849c24351ad0115bbc05
parent114770b3043bca52a8e3fa4f007012b3b4dff602 (diff)
downloadmarkdown-bdf27a37a8cec16d5c0cc53e8a17e4b1ceacbd50.tar.gz
markdown-bdf27a37a8cec16d5c0cc53e8a17e4b1ceacbd50.tar.bz2
markdown-bdf27a37a8cec16d5c0cc53e8a17e4b1ceacbd50.zip
Fixed Ticket 53. Nested lists no longer isorder items in certain edge cases. Thanks for the report and preliminary work Gerry LaMontagne.
-rw-r--r--markdown/blockprocessors.py6
-rw-r--r--tests/misc/nested-lists.html13
-rw-r--r--tests/misc/nested-lists.txt9
3 files changed, 27 insertions, 1 deletions
diff --git a/markdown/blockprocessors.py b/markdown/blockprocessors.py
index 7d3b137..98db90b 100644
--- a/markdown/blockprocessors.py
+++ b/markdown/blockprocessors.py
@@ -143,8 +143,12 @@ class ListIndentProcessor(BlockProcessor):
# Assume the last child li is the parent of this block.
if sibling[-1].text:
# If the parent li has text, that text needs to be moved to a p
- block = '%s\n\n%s' % (sibling[-1].text, block)
+ # The p must be 'inserted' at beginning of list in the event
+ # that other children already exist i.e.; a nested sublist.
+ p = markdown.etree.Element('p')
+ p.text = sibling[-1].text
sibling[-1].text = ''
+ sibling[-1].insert(0, p)
self.parser.parseChunk(sibling[-1], block)
else:
self.create_item(sibling, block)
diff --git a/tests/misc/nested-lists.html b/tests/misc/nested-lists.html
index bb73784..9af441a 100644
--- a/tests/misc/nested-lists.html
+++ b/tests/misc/nested-lists.html
@@ -36,4 +36,17 @@
</ul>
</li>
<li>item 2</li>
+<li>item 3</li>
+<li>
+<p>item 4</p>
+<ul>
+<li>item 4-1</li>
+<li>item 4-2</li>
+<li>
+<p>item 4-3</p>
+<p>Paragraph under item 4-3</p>
+</li>
+</ul>
+<p>Paragraph under item 4</p>
+</li>
</ul> \ No newline at end of file
diff --git a/tests/misc/nested-lists.txt b/tests/misc/nested-lists.txt
index 38aae15..a2704b4 100644
--- a/tests/misc/nested-lists.txt
+++ b/tests/misc/nested-lists.txt
@@ -22,3 +22,12 @@ plain text
* item 1-2
* item 1-2-1
* item 2
+* item 3
+* item 4
+ * item 4-1
+ * item 4-2
+ * item 4-3
+
+ Paragraph under item 4-3
+
+ Paragraph under item 4