aboutsummaryrefslogtreecommitdiffstats
path: root/markdown.py
diff options
context:
space:
mode:
authorNeale Pickett <neale@woozle.org>2008-08-20 21:09:48 -0600
committerYuri Takhteyev <yuri@freewisdom.org>2008-08-20 22:53:30 -0700
commit17292efebc8c64fe646935fc420cd703003c007f (patch)
treed9021a029ce459f604814d1c4f92d0fc7757b208 /markdown.py
parent75f33d6da5a5c59151f7779634f7efe0fef4d746 (diff)
downloadmarkdown-17292efebc8c64fe646935fc420cd703003c007f.tar.gz
markdown-17292efebc8c64fe646935fc420cd703003c007f.tar.bz2
markdown-17292efebc8c64fe646935fc420cd703003c007f.zip
Pattern.compiled_re
> I suppose one thing to do would be to somehow "annotate" nodes to > specify that they should not have their children processed. Artem, > what would you suggest? Then, <a> nodes created with [...]() would > get their children processed, but those created with autolinks (<...>) > will be marked as done. Okay, I promise to get on the mail list, but this was such an obvious and elegant solution that I couldn't wait for the subscription to finish. Any objections to me starting a branch and pushing this to your gitorious project? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Diffstat (limited to 'markdown.py')
-rwxr-xr-xmarkdown.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/markdown.py b/markdown.py
index 40cfc61..a38c6ba 100755
--- a/markdown.py
+++ b/markdown.py
@@ -210,6 +210,11 @@ def handleAttributes(text, parent):
return RE.regExp['attr'].sub(attributeCallback, text)
+class AtomicString(str):
+ "A string which should not be further processed."
+ pass
+
+
"""
======================================================================
========================== PRE-PROCESSORS ============================
@@ -776,7 +781,7 @@ class AutolinkPattern (Pattern):
def handleMatch(self, m):
el = etree.Element("a")
el.set('href', m.group(2))
- el.text = m.group(2)
+ el.text = AtomicString(m.group(2))
return el
class AutomailPattern (Pattern):
@@ -789,9 +794,9 @@ class AutomailPattern (Pattern):
email = m.group(2)
if email.startswith("mailto:"):
email = email[len("mailto:"):]
- el.text = ""
- for letter in email:
- el.text += codepoint2name(ord(letter))
+
+ letters = [codepoint2name(ord(letter)) for letter in email]
+ el.text = AtomicString(''.join(letters))
mailto = "mailto:" + email
mailto = "".join([AMP_SUBSTITUTE + '#%d;' %
@@ -1661,6 +1666,10 @@ class Markdown:
Returns: String with placeholders.
"""
+
+ if isinstance(data, AtomicString):
+ return data
+
startIndex = 0
while patternIndex < len(self.inlinePatterns):