diff options
author | Waylan Limberg <waylan@gmail.com> | 2008-11-18 12:46:35 -0500 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2008-11-18 12:46:35 -0500 |
commit | 41ebca604f081d1bb798d3178f674e960a2e4ec1 (patch) | |
tree | 7429df8ec85ddbea1707ebdf807c8ff614c43598 | |
parent | 60ef37b47b99fc51683a51640ba98f2d5a25a427 (diff) | |
download | markdown-41ebca604f081d1bb798d3178f674e960a2e4ec1.tar.gz markdown-41ebca604f081d1bb798d3178f674e960a2e4ec1.tar.bz2 markdown-41ebca604f081d1bb798d3178f674e960a2e4ec1.zip |
Fixed BlockParser to parse code blocks nested in list items and added a test. Somehow we never had a test for that before. Also reset markdown.py to be executable again.
-rwxr-xr-x[-rw-r--r--] | markdown.py | 0 | ||||
-rw-r--r-- | markdown/blockprocessors.py | 3 | ||||
-rw-r--r-- | tests/markdown-test/codeblock-in-list.html | 14 | ||||
-rw-r--r-- | tests/markdown-test/codeblock-in-list.txt | 10 |
4 files changed, 27 insertions, 0 deletions
diff --git a/markdown.py b/markdown.py index 36e4e8c..36e4e8c 100644..100755 --- a/markdown.py +++ b/markdown.py diff --git a/markdown/blockprocessors.py b/markdown/blockprocessors.py index b120d73..646ae9f 100644 --- a/markdown/blockprocessors.py +++ b/markdown/blockprocessors.py @@ -115,6 +115,7 @@ class ListIndentProcessor(BlockProcessor): def test(self, parent, block): return block.startswith(' '*markdown.TAB_LENGTH) and \ + not self.parser.state.isstate('detabbed') and \ (parent.tag == "li" or \ (len(parent) and parent[-1] and \ (parent[-1].tag == "ul" or parent[-1].tag == "ol") @@ -124,6 +125,7 @@ class ListIndentProcessor(BlockProcessor): def run(self, parent, blocks): block = self.looseDetab(blocks.pop(0)) sibling = self.lastChild(parent) + self.parser.state.set('detabbed') if parent.tag == 'li': # The parent is already a li. Just parse the child block. self.parser.parseBlocks(parent, [block]) @@ -139,6 +141,7 @@ class ListIndentProcessor(BlockProcessor): # Create a new li and parse the block with it as the parent. li = markdown.etree.SubElement(sibling, 'li') self.parser.parseBlocks(li, [block]) + self.parser.state.reset() class CodeBlockProcessor(BlockProcessor): diff --git a/tests/markdown-test/codeblock-in-list.html b/tests/markdown-test/codeblock-in-list.html new file mode 100644 index 0000000..49edd56 --- /dev/null +++ b/tests/markdown-test/codeblock-in-list.html @@ -0,0 +1,14 @@ +<ul> +<li> +<p>A list item with a code block</p> +<pre><code>Some *code* +</code></pre> +</li> +<li> +<p>Another list item</p> +<pre><code>More code + +And more code +</code></pre> +</li> +</ul>
\ No newline at end of file diff --git a/tests/markdown-test/codeblock-in-list.txt b/tests/markdown-test/codeblock-in-list.txt new file mode 100644 index 0000000..87d4e3b --- /dev/null +++ b/tests/markdown-test/codeblock-in-list.txt @@ -0,0 +1,10 @@ +* A list item with a code block + + Some *code* + +* Another list item + + More code + + And more code + |