diff options
author | Waylan Limberg <waylan@gmail.com> | 2008-11-13 15:53:42 -0500 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2008-11-13 23:27:55 -0500 |
commit | 64f5510aeb05d8912bb9f60ad247c815c2b90990 (patch) | |
tree | b4864359a9f63023148dd6a7c5495e8c70a1223c | |
parent | b02b01dbf51c1409211703a4aa32aa6cff9164d7 (diff) | |
download | markdown-64f5510aeb05d8912bb9f60ad247c815c2b90990.tar.gz markdown-64f5510aeb05d8912bb9f60ad247c815c2b90990.tar.bz2 markdown-64f5510aeb05d8912bb9f60ad247c815c2b90990.zip |
Fixed BlockquoteProcessor to acknowledge blocks in which the blockquote starts after the first line. Also updated coresponding test as it had an error and added more detail. All core tests pass now. On to extensions.
-rwxr-xr-x | markdown.py | 17 | ||||
-rw-r--r-- | tests/misc/blockquote-below-paragraph.html | 8 | ||||
-rw-r--r-- | tests/misc/blockquote-below-paragraph.txt | 12 |
3 files changed, 30 insertions, 7 deletions
diff --git a/markdown.py b/markdown.py index 4441617..f4536a2 100755 --- a/markdown.py +++ b/markdown.py @@ -361,14 +361,21 @@ class CodeBlockProcessor(BlockProcessor): class BlockQuoteProcessor(BlockProcessor): - RE = re.compile(r'^[ ]{0,3}>[ ](.*)') + RE = re.compile(r'(^|\n)[ ]{0,3}>[ ](.*)') def test(self, parent, block): - return bool(self.RE.match(block)) + return bool(self.RE.search(block)) def run(self, parent, blocks): - block = '\n'.join([self.clean(line) for line in - blocks.pop(0).split('\n')]) + block = blocks.pop(0) + m = self.RE.search(block) + if m: + before = block[:m.start()] # Lines before blockquote + # Pass lines before blockquote in recursively for parsing forst. + self.parser.parseBlocks(parent, [before]) + # Remove ``> `` from begining of each line. + block = '\n'.join([self.clean(line) for line in + block[m.start():].split('\n')]) sibling = self.lastChild(parent) if sibling and sibling.tag == "blockquote": # Previous block was a blockquote so set that as this blocks parent @@ -385,7 +392,7 @@ class BlockQuoteProcessor(BlockProcessor): if line.strip() == ">": return "" elif m: - return m.group(1) + return m.group(2) else: return line diff --git a/tests/misc/blockquote-below-paragraph.html b/tests/misc/blockquote-below-paragraph.html index c6f622e..20ffb66 100644 --- a/tests/misc/blockquote-below-paragraph.html +++ b/tests/misc/blockquote-below-paragraph.html @@ -2,4 +2,12 @@ <blockquote> <p>Block quote Yep</p> +</blockquote> +<p>Paragraph +>no space +>Nope</p> +<p>Paragraph one</p> +<blockquote> +<p>blockquote +More blockquote.</p> </blockquote>
\ No newline at end of file diff --git a/tests/misc/blockquote-below-paragraph.txt b/tests/misc/blockquote-below-paragraph.txt index 0dd4d5c..529e5a9 100644 --- a/tests/misc/blockquote-below-paragraph.txt +++ b/tests/misc/blockquote-below-paragraph.txt @@ -1,3 +1,11 @@ Paragraph ->Block quote ->Yep +> Block quote +> Yep + +Paragraph +>no space +>Nope + +Paragraph one +> blockquote +More blockquote. |