aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--markdown/inlinepatterns.py15
-rw-r--r--markdown/postprocessors.py12
2 files changed, 13 insertions, 14 deletions
diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py
index 1829348..2a33816 100644
--- a/markdown/inlinepatterns.py
+++ b/markdown/inlinepatterns.py
@@ -268,11 +268,22 @@ class DoubleTagPattern(SimpleTagPattern):
class HtmlPattern(Pattern):
""" Store raw inline html and return a placeholder. """
def handleMatch (self, m):
- rawhtml = m.group(2)
- inline = True
+ rawhtml = self.unescape(m.group(2))
place_holder = self.markdown.htmlStash.store(rawhtml)
return place_holder
+ def unescape(self, text):
+ """ Return unescaped text given text with an inline placeholder. """
+ try:
+ stash = self.markdown.treeprocessors['inline'].stashed_nodes
+ except KeyError:
+ return text
+ def get_stash(m):
+ id = m.group(1)
+ if id in stash:
+ return '\%s' % stash.get(id)
+ return util.INLINE_PLACEHOLDER_RE.sub(get_stash, text)
+
class LinkPattern(Pattern):
""" Return a link element from the given match. """
diff --git a/markdown/postprocessors.py b/markdown/postprocessors.py
index 962728b..672953a 100644
--- a/markdown/postprocessors.py
+++ b/markdown/postprocessors.py
@@ -60,21 +60,10 @@ class RawHtmlPostprocessor(Postprocessor):
text = text.replace("<p>%s</p>" %
(self.markdown.htmlStash.get_placeholder(i)),
html + "\n")
- html = self.unescape(html)
text = text.replace(self.markdown.htmlStash.get_placeholder(i),
html)
return text
- def unescape(self, html):
- """ Unescape any markdown escaped text within inline html. """
- for k, v in self.markdown.treeprocessors['inline'].stashed_nodes.items():
- ph = util.INLINE_PLACEHOLDER % k
- try:
- html = html.replace(ph, '%s' % util.etree.tostring(v))
- except:
- html = html.replace(ph, '\%s' % v)
- return html
-
def escape(self, html):
""" Basic html escaping """
html = html.replace('&', '&amp;')
@@ -82,7 +71,6 @@ class RawHtmlPostprocessor(Postprocessor):
html = html.replace('>', '&gt;')
return html.replace('"', '&quot;')
-
def isblocklevel(self, html):
m = re.match(r'^\<\/?([^ ]+)', html)
if m: