aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2011-12-29 17:31:32 -0500
committerWaylan Limberg <waylan@gmail.com>2011-12-29 17:31:32 -0500
commit1e5d0cb773e993fac2d56c4abe93b66cf208eead (patch)
tree5e9f09bb8eb30401d172a02bed8dd0ed2f4d75c2
parent400ebc2efe38178a4817cd5517d8c9d89ee3a5a7 (diff)
downloadmarkdown-1e5d0cb773e993fac2d56c4abe93b66cf208eead.tar.gz
markdown-1e5d0cb773e993fac2d56c4abe93b66cf208eead.tar.bz2
markdown-1e5d0cb773e993fac2d56c4abe93b66cf208eead.zip
Fixed #68. Blank line is not required after html comments.
Interestingly, the change to the misc/mismatched-tags test is inline with PHP Markdown Extra's behavior but not markdown.pl, which produces invalid html.
-rw-r--r--markdown/preprocessors.py24
-rw-r--r--tests/misc/comments.html6
-rw-r--r--tests/misc/comments.txt3
-rw-r--r--tests/misc/mismatched-tags.html5
4 files changed, 22 insertions, 16 deletions
diff --git a/markdown/preprocessors.py b/markdown/preprocessors.py
index a80f9fb..0094d7b 100644
--- a/markdown/preprocessors.py
+++ b/markdown/preprocessors.py
@@ -143,21 +143,20 @@ class HtmlBlockPreprocessor(Preprocessor):
if not in_tag:
if block.startswith("<") and len(block.strip()) > 1:
- left_tag, left_index, attrs = self._get_left_tag(block)
- right_tag, data_index = self._get_right_tag(left_tag,
- left_index,
- block)
if block[1] == "!":
# is a comment block
- left_tag = "--"
- right_tag, data_index = self._get_right_tag(left_tag,
- left_index,
- block)
- # keep checking conditions below and maybe just append
+ left_tag, left_index, attrs = "--", 2, ()
+ else:
+ left_tag, left_index, attrs = self._get_left_tag(block)
+ right_tag, data_index = self._get_right_tag(left_tag,
+ left_index,
+ block)
+ # keep checking conditions below and maybe just append
if data_index < len(block) \
- and util.isBlockLevel(left_tag):
+ and (util.isBlockLevel(left_tag)
+ or left_tag == '--'):
text.insert(0, block[data_index:])
block = block[:data_index]
@@ -202,12 +201,9 @@ 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,
- 0,
- block)
+ right_tag, data_index = self._get_right_tag(left_tag, 0, block)
if self._equal_tags(left_tag, right_tag):
# if find closing tag
diff --git a/tests/misc/comments.html b/tests/misc/comments.html
index 005a755..2240ab9 100644
--- a/tests/misc/comments.html
+++ b/tests/misc/comments.html
@@ -2,4 +2,8 @@
<p>X&gt;0</p>
<!-- A comment -->
-<div>as if</div> \ No newline at end of file
+<div>as if</div>
+
+<!-- comment -->
+
+<p><strong>no blank line</strong></p> \ No newline at end of file
diff --git a/tests/misc/comments.txt b/tests/misc/comments.txt
index 68302b0..d9186f0 100644
--- a/tests/misc/comments.txt
+++ b/tests/misc/comments.txt
@@ -5,3 +5,6 @@ X>0
<!-- A comment -->
<div>as if</div>
+
+<!-- comment -->
+__no blank line__
diff --git a/tests/misc/mismatched-tags.html b/tests/misc/mismatched-tags.html
index ec087e1..06bd57f 100644
--- a/tests/misc/mismatched-tags.html
+++ b/tests/misc/mismatched-tags.html
@@ -6,6 +6,9 @@
<p>And this output</p>
<p><em>Compatible with PHP Markdown Extra 1.2.2 and Markdown.pl1.0.2b8:</em></p>
-<!-- comment --><p><div>text</div><br /></p><br />
+<!-- comment -->
+<p><div>text</div><br /></p>
+
+<p><br /></p>
<p>Should be in p</p> \ No newline at end of file