aboutsummaryrefslogtreecommitdiffstats
path: root/markdown/inlinepatterns.py
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2012-01-18 23:56:56 -0500
committerWaylan Limberg <waylan@gmail.com>2012-01-18 23:56:56 -0500
commit481e50700e269f9a56337cd9fabc3b5251958d10 (patch)
tree269237d32923c6e5b86d3c6ebdf0cd4d1ea957e0 /markdown/inlinepatterns.py
parent01f4b8cdcf37e3e17e50dfbb51b49472f4b5dc95 (diff)
downloadmarkdown-481e50700e269f9a56337cd9fabc3b5251958d10.tar.gz
markdown-481e50700e269f9a56337cd9fabc3b5251958d10.tar.bz2
markdown-481e50700e269f9a56337cd9fabc3b5251958d10.zip
Fixed #59. Raw HTML parsing is no longer slow.
Replaced the unescape method I carlessly threw in the RawHtmlProcessor. Unfortunetly, this reintroduces the bug just fixed in commit 425fde141f17973aea0a3a85e44632fe18737996 Sigh!
Diffstat (limited to 'markdown/inlinepatterns.py')
-rw-r--r--markdown/inlinepatterns.py15
1 files changed, 13 insertions, 2 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. """