From 996bcdd332551b82791ab0851e2f7f826bc0a4ed Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Mon, 1 Mar 2010 13:07:57 -0500 Subject: Fix bug with rawhtml and markdown escaping. Previously, any inline rawhtml that contained text that fit markdown's escaping syntax (i.e. ) was never unescaped. Now it is. Markdown probably shouldn't be escaping before removing rawhtml in the first place, but this will do for now. --- markdown/postprocessors.py | 8 ++++++++ tests/misc/html.html | 3 ++- tests/misc/html.txt | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/markdown/postprocessors.py b/markdown/postprocessors.py index 80227bb..e5c2e06 100644 --- a/markdown/postprocessors.py +++ b/markdown/postprocessors.py @@ -44,6 +44,7 @@ class RawHtmlPostprocessor(Postprocessor): """ Iterate over html stash and restore "safe" html. """ for i in range(self.markdown.htmlStash.html_counter): html, safe = self.markdown.htmlStash.rawHtmlBlocks[i] + html = self.unescape(html) if self.markdown.safeMode and not safe: if str(self.markdown.safeMode).lower() == 'escape': html = self.escape(html) @@ -59,6 +60,13 @@ class RawHtmlPostprocessor(Postprocessor): 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 = markdown.INLINE_PLACEHOLDER % k + html = html.replace(ph, '\%s' % v) + return html + def escape(self, html): """ Basic html escaping """ html = html.replace('&', '&') diff --git a/tests/misc/html.html b/tests/misc/html.html index cd6d4af..c4bad4f 100644 --- a/tests/misc/html.html +++ b/tests/misc/html.html @@ -10,4 +10,5 @@ Html with various attributes.

And of course .

-

this . [this ) +Some funky inline stuff with markdown escaping syntax. -- cgit v1.2.3