diff options
-rw-r--r-- | markdown/postprocessors.py | 13 | ||||
-rw-r--r-- | tests/misc/html.html | 1 | ||||
-rw-r--r-- | tests/misc/html.txt | 2 | ||||
-rw-r--r-- | tests/misc/more_comments.html | 3 |
4 files changed, 16 insertions, 3 deletions
diff --git a/markdown/postprocessors.py b/markdown/postprocessors.py index cd90eb8..8985fb8 100644 --- a/markdown/postprocessors.py +++ b/markdown/postprocessors.py @@ -8,6 +8,7 @@ processing. """ +import re import util import odict @@ -55,7 +56,7 @@ class RawHtmlPostprocessor(Postprocessor): html = '' else: html = self.markdown.html_replacement_text - if safe or not self.markdown.safeMode: + if self.isblocklevel(html) and (safe or not self.markdown.safeMode): text = text.replace("<p>%s</p>" % (self.markdown.htmlStash.get_placeholder(i)), html + "\n") @@ -78,6 +79,16 @@ class RawHtmlPostprocessor(Postprocessor): return html.replace('"', '"') + def isblocklevel(self, html): + m = re.match(r'^\<\/?([^ ]+)', html) + if m: + if m.group(1).startswith(('!', '?', '@', '%')): + # Comment, php etc... + return True + return util.isBlockLevel(m.group(1)) + return False + + class AndSubstitutePostprocessor(Postprocessor): """ Restore valid entities """ def __init__(self): diff --git a/tests/misc/html.html b/tests/misc/html.html index dd4e4e8..c72bb81 100644 --- a/tests/misc/html.html +++ b/tests/misc/html.html @@ -12,6 +12,7 @@ Html with various attributes. <p>And of course <script>blah</script>.</p> <p><a href="script>stuff</script">this <script>link</a></p> <p>Some funky <x\]> inline stuff with markdown escaping syntax.</p> +<p><img scr="foo.png" title="Only one inline element on a line." /></p> <p>And now a line with only an opening bracket:</p> <p><</p> <p>And one with other stuff but no closing bracket:</p> diff --git a/tests/misc/html.txt b/tests/misc/html.txt index b51d30b..dfee68d 100644 --- a/tests/misc/html.txt +++ b/tests/misc/html.txt @@ -17,6 +17,8 @@ And of course <script>blah</script>. Some funky <x\]> inline stuff with markdown escaping syntax. +<img scr="foo.png" title="Only one inline element on a line." /> + And now a line with only an opening bracket: < diff --git a/tests/misc/more_comments.html b/tests/misc/more_comments.html index 97074d5..99f5781 100644 --- a/tests/misc/more_comments.html +++ b/tests/misc/more_comments.html @@ -2,6 +2,5 @@ <!asd@asdfd.com> -<asd!@asdfd.com> - +<p><asd!@asdfd.com></p> <p>Test</p>
\ No newline at end of file |