From 44caa3aaa1022532f3ecdada6cff7fe5fd0a2c44 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Fri, 30 Dec 2011 05:19:46 +0800 Subject: Fixed #57. Multiline HTML Blocks no longer require a blank line after them. --- markdown/preprocessors.py | 9 ++++++++- tests/misc/multi-line-tags.html | 10 +++++++++- tests/misc/multi-line-tags.txt | 7 +++++++ tests/misc/multiline-comments.html | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/markdown/preprocessors.py b/markdown/preprocessors.py index 28f731f..a80f9fb 100644 --- a/markdown/preprocessors.py +++ b/markdown/preprocessors.py @@ -202,14 +202,21 @@ class HtmlBlockPreprocessor(Preprocessor): new_blocks.append(block) else: + #import pdb; pdb.set_trace() items.append(block) right_tag, data_index = self._get_right_tag(left_tag, - left_index, + 0, block) if self._equal_tags(left_tag, right_tag): # if find closing tag + + if data_index < len(block): + # we have more text after right_tag + items[-1] = block[:data_index] + text.insert(0, block[data_index:]) + in_tag = False if self.markdown_in_raw and 'markdown' in attrs.keys(): start = re.sub(r'\smarkdown(=[\'"]?[^> ]*[\'"]?)?', diff --git a/tests/misc/multi-line-tags.html b/tests/misc/multi-line-tags.html index 784c1dd..69899aa 100644 --- a/tests/misc/multi-line-tags.html +++ b/tests/misc/multi-line-tags.html @@ -2,4 +2,12 @@ asdf asdfasd - \ No newline at end of file + + +
+ +foo bar + +
+ +

No blank line.

\ No newline at end of file diff --git a/tests/misc/multi-line-tags.txt b/tests/misc/multi-line-tags.txt index 4ea3b02..9056473 100644 --- a/tests/misc/multi-line-tags.txt +++ b/tests/misc/multi-line-tags.txt @@ -4,3 +4,10 @@ asdf asdfasd + +
+ +foo bar + +
+No blank line. diff --git a/tests/misc/multiline-comments.html b/tests/misc/multiline-comments.html index 12f8cb5..29c17e9 100644 --- a/tests/misc/multiline-comments.html +++ b/tests/misc/multiline-comments.html @@ -2,7 +2,7 @@ foo ---> +-->

-- cgit v1.2.3