aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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