From e3c5efd182d9a80f34e3b9a770eed63c1d62b2f9 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Thu, 19 Jan 2012 06:13:21 -0500 Subject: Partial fix for issue introduced in fix for #59 Markdown markup inside angle bracktes now gets rendered properly in all cases except when safe_mode='escape'. Also added tests. --- markdown/inlinepatterns.py | 9 +++++++-- tests/basic/inline-html-simple.html | 4 +++- tests/basic/inline-html-simple.txt | 1 + tests/safe_mode/remove.html | 1 + tests/safe_mode/remove.txt | 1 + tests/safe_mode/replace.html | 1 + tests/safe_mode/replace.txt | 1 + 7 files changed, 15 insertions(+), 3 deletions(-) diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py index 2a33816..3f92737 100644 --- a/markdown/inlinepatterns.py +++ b/markdown/inlinepatterns.py @@ -280,8 +280,13 @@ class HtmlPattern(Pattern): return text def get_stash(m): id = m.group(1) - if id in stash: - return '\%s' % stash.get(id) + value = stash.get(id) + if value is not None: + try: + return util.etree.tostring(value) + except: + return '\%s' % value + return util.INLINE_PLACEHOLDER_RE.sub(get_stash, text) diff --git a/tests/basic/inline-html-simple.html b/tests/basic/inline-html-simple.html index cb10451..2159e1d 100644 --- a/tests/basic/inline-html-simple.html +++ b/tests/basic/inline-html-simple.html @@ -55,4 +55,6 @@ Blah
-
\ No newline at end of file +
+ +

weird stuff>

\ No newline at end of file diff --git a/tests/basic/inline-html-simple.txt b/tests/basic/inline-html-simple.txt index 14aa2dc..7210750 100644 --- a/tests/basic/inline-html-simple.txt +++ b/tests/basic/inline-html-simple.txt @@ -67,3 +67,4 @@ Hr's:
+ diff --git a/tests/safe_mode/remove.html b/tests/safe_mode/remove.html index a1e1626..d86b2b4 100644 --- a/tests/safe_mode/remove.html +++ b/tests/safe_mode/remove.html @@ -31,4 +31,5 @@

+

\ No newline at end of file diff --git a/tests/safe_mode/remove.txt b/tests/safe_mode/remove.txt index 14aa2dc..7210750 100644 --- a/tests/safe_mode/remove.txt +++ b/tests/safe_mode/remove.txt @@ -67,3 +67,4 @@ Hr's:
+ diff --git a/tests/safe_mode/replace.html b/tests/safe_mode/replace.html index fdf666e..cb6bfb5 100644 --- a/tests/safe_mode/replace.html +++ b/tests/safe_mode/replace.html @@ -31,4 +31,5 @@

[HTML_REMOVED]

[HTML_REMOVED]

[HTML_REMOVED]

+

[HTML_REMOVED]

[HTML_REMOVED]

\ No newline at end of file diff --git a/tests/safe_mode/replace.txt b/tests/safe_mode/replace.txt index 14aa2dc..7210750 100644 --- a/tests/safe_mode/replace.txt +++ b/tests/safe_mode/replace.txt @@ -67,3 +67,4 @@ Hr's:
+ -- cgit v1.2.3