From a75df2c7bf2325449fdecc613290f126b7141ccb Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Mon, 8 Oct 2007 01:36:05 +0000 Subject: Fixed lazy blockquote and added tests --- markdown.py | 11 +++++++++-- tests/misc/lazy-block-quote.html | 9 +++++++++ tests/misc/lazy-block-quote.txt | 5 +++++ tests/misc/multi-paragraph-block-quote.html | 10 ++++++++++ tests/misc/multi-paragraph-block-quote.txt | 8 ++++++++ 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 tests/misc/lazy-block-quote.html create mode 100644 tests/misc/lazy-block-quote.txt create mode 100644 tests/misc/multi-paragraph-block-quote.html create mode 100644 tests/misc/multi-paragraph-block-quote.txt diff --git a/markdown.py b/markdown.py index adcce81..e1e7dae 100644 --- a/markdown.py +++ b/markdown.py @@ -1442,15 +1442,22 @@ class Markdown: dequoted = [] i = 0 + blank_line = False # allow one blank line between paragraphs for line in lines : m = RE.regExp['quoted'].match(line) if m : dequoted.append(m.group(1)) i += 1 + blank_line = False + elif not blank_line and line.strip() != '' : + dequoted.append(line) + i += 1 + elif not blank_line and line.strip() == '' : + dequoted.append(line) + i += 1 + blank_line = True else : break - else : - i += 1 blockquote = self.doc.createElement('blockquote') parent_elem.appendChild(blockquote) diff --git a/tests/misc/lazy-block-quote.html b/tests/misc/lazy-block-quote.html new file mode 100644 index 0000000..14da987 --- /dev/null +++ b/tests/misc/lazy-block-quote.html @@ -0,0 +1,9 @@ + +

Line one of lazy block quote. + Line two of lazy block quote. +

+

Line one of paragraph two. + Line two of paragraph two. +

+
+ diff --git a/tests/misc/lazy-block-quote.txt b/tests/misc/lazy-block-quote.txt new file mode 100644 index 0000000..e7c17ca --- /dev/null +++ b/tests/misc/lazy-block-quote.txt @@ -0,0 +1,5 @@ +> Line one of lazy block quote. +Line two of lazy block quote. + +> Line one of paragraph two. +Line two of paragraph two. diff --git a/tests/misc/multi-paragraph-block-quote.html b/tests/misc/multi-paragraph-block-quote.html new file mode 100644 index 0000000..b213d84 --- /dev/null +++ b/tests/misc/multi-paragraph-block-quote.html @@ -0,0 +1,10 @@ + +

This is line one of paragraph one + This is line two of paragraph one +

+

This is line one of paragraph two +

+

This is another blockquote. +

+
+ diff --git a/tests/misc/multi-paragraph-block-quote.txt b/tests/misc/multi-paragraph-block-quote.txt new file mode 100644 index 0000000..f8a986f --- /dev/null +++ b/tests/misc/multi-paragraph-block-quote.txt @@ -0,0 +1,8 @@ +> This is line one of paragraph one +> This is line two of paragraph one + +> This is line one of paragraph two + + + +> This is another blockquote. -- cgit v1.2.3