From bdf27a37a8cec16d5c0cc53e8a17e4b1ceacbd50 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Mon, 15 Mar 2010 20:31:59 -0400 Subject: Fixed Ticket 53. Nested lists no longer isorder items in certain edge cases. Thanks for the report and preliminary work Gerry LaMontagne. --- markdown/blockprocessors.py | 6 +++++- tests/misc/nested-lists.html | 13 +++++++++++++ tests/misc/nested-lists.txt | 9 +++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) 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 @@
  • item 2
  • +
  • item 3
  • +
  • +

    item 4

    + +

    Paragraph under item 4

    +
  • \ 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 -- cgit v1.2.3