aboutsummaryrefslogtreecommitdiffstats
path: root/markdown/postprocessors.py
diff options
context:
space:
mode:
Diffstat (limited to 'markdown/postprocessors.py')
-rw-r--r--markdown/postprocessors.py13
1 files changed, 12 insertions, 1 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('"', '&quot;')
+ 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):