From 3c5a355edd62efb8642b71b28cd39f7f8f2b3dc6 Mon Sep 17 00:00:00 2001 From: Gerry LaMontagne Date: Tue, 23 Mar 2010 13:41:41 -0400 Subject: Blockquoted text in the first item of a list is now placed in child p tag of the blockquote tag. Added lists8.txt and .html for test suite to test condition. --- markdown/blockprocessors.py | 28 +++------------------------- tests/misc/lists8.html | 39 +++++++++++++++++++++++++++++++++++++++ tests/misc/lists8.txt | 16 ++++++++++++++++ 3 files changed, 58 insertions(+), 25 deletions(-) create mode 100644 tests/misc/lists8.html create mode 100644 tests/misc/lists8.txt diff --git a/markdown/blockprocessors.py b/markdown/blockprocessors.py index f73a4d8..7e6860f 100644 --- a/markdown/blockprocessors.py +++ b/markdown/blockprocessors.py @@ -127,20 +127,10 @@ class ListIndentProcessor(BlockProcessor): ) def run(self, parent, blocks): - print "BEGIN ListIndentProcessor" - print "parent: %s" % markdown.etree.tostring(parent) - print "blocks: %s" % blocks - block = blocks.pop(0) level, sibling = self.get_level(parent, block) block = self.looseDetab(block, level) - print "block: %s" % block - if sibling: - print "sibling: %s" % markdown.etree.tostring(sibling) - else: - print "sibling: none" - self.parser.state.set('detabbed') if parent.tag in self.ITEM_TYPES: # It's possible that this parent has a 'ul' or 'ol' child list @@ -172,8 +162,6 @@ class ListIndentProcessor(BlockProcessor): self.create_item(sibling, block) self.parser.state.reset() - print "END ListIndentProcessor" - def create_item(self, parent, block): """ Create a new li and parse the block with it as the parent. """ li = markdown.etree.SubElement(parent, 'li') @@ -263,7 +251,10 @@ class BlockQuoteProcessor(BlockProcessor): # This is a new blockquote. Create a new parent element. quote = markdown.etree.SubElement(parent, 'blockquote') # Recursively parse block with blockquote as parent. + # change parser state so blockquotes embedded in lists use p tags + self.parser.state.set('blockquote') self.parser.parseChunk(quote, block) + self.parser.state.reset() def clean(self, line): """ Remove ``>`` from beginning of a line. """ @@ -290,20 +281,10 @@ class OListProcessor(BlockProcessor): return bool(self.RE.match(block)) def run(self, parent, blocks): - print "BEGIN OListProcessor" - print "parent: %s" % markdown.etree.tostring(parent) - print "blocks: %s" % blocks - # Check fr multiple items in one block. items = self.get_items(blocks.pop(0)) sibling = self.lastChild(parent) - print "items: %s" % items - if sibling: - print "sibling: %s" % markdown.etree.tostring(sibling) - else: - print "sibling: none" - if sibling and sibling.tag in ['ol', 'ul']: # Previous block was a list item, so set that as parent lst = sibling @@ -323,7 +304,6 @@ class OListProcessor(BlockProcessor): self.parser.state.set('looselist') firstitem = items.pop(0) self.parser.parseBlocks(li, [firstitem]) - print "looselist: %s" % markdown.etree.tostring(lst) self.parser.state.reset() elif parent.tag in ['ol', 'ul']: # this catches the edge case of a multi-item indented list whose @@ -348,8 +328,6 @@ class OListProcessor(BlockProcessor): self.parser.parseBlocks(li, [item]) self.parser.state.reset() - print "END OListProcessor" - def get_items(self, block): """ Break a block into list items. """ items = [] diff --git a/tests/misc/lists8.html b/tests/misc/lists8.html new file mode 100644 index 0000000..8a93a51 --- /dev/null +++ b/tests/misc/lists8.html @@ -0,0 +1,39 @@ +

Lists with blockquotes

+
    +
  1. +
    +

    Four-score and seven years ago...

    +
    +
  2. +
  3. +
    +

    We have nothing to fear...

    +
    +
  4. +
  5. +
    +

    This is it...

    +
    +
  6. +
+

Multi-line blockquotes

+ \ No newline at end of file diff --git a/tests/misc/lists8.txt b/tests/misc/lists8.txt new file mode 100644 index 0000000..8ab6767 --- /dev/null +++ b/tests/misc/lists8.txt @@ -0,0 +1,16 @@ +# Lists with blockquotes +1. > Four-score and seven years ago... + +2. > We have nothing to fear... + +3. > This is it... + +# Multi-line blockquotes +* > Four-score and sever years ago + > our fathers brought forth + +* > We have nothing to fear + > but fear itself + +* > This is it + > as far as I'm concerned -- cgit v1.2.3