Fixed markdown so that URLs in <code> blocks no longer have

angle brackets wrapped around them
This commit is contained in:
Mike
2009-02-10 11:53:40 -08:00
parent 07b5060aa8
commit 99b4470b31

View File

@@ -98,9 +98,10 @@ def edit_comment_filter(text = ''):
r_url = re.compile('(?<![\(\[])(http://[^\s\'\"\]\)]+)')
jscript_url = re.compile('<a href="(?!http|ftp|mailto|/).*</a>', re.I | re.S)
img = re.compile('<img.*?>', re.I | re.S)
href_re = re.compile('<a href="([^"]+)"', re.I | re.S)
href_re = re.compile('<a href="([^"]+)"', re.I)
code_re = re.compile('<code>([^<]+)</code>')
a_re = re.compile('>([^<]+)</a>')
fix_url = re.compile('&lt;(http://[^\s\'\"\]\)]+)&gt;')
#TODO markdown should be looked up in batch?
@@ -109,8 +110,8 @@ def safemarkdown(text):
from contrib.markdown import markdown
if text:
# increase escaping of &, < and > once
text = text.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
#wrap urls in "<>" so that markdown will handle them as urls
text = text.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
#wrap urls in "<>" so that markdown will handle them as urls
text = r_url.sub(r'<\1>', text)
try:
text = markdown(text)
@@ -137,6 +138,7 @@ def safemarkdown(text):
text = href_re.sub(href_handler, text)
text = code_re.sub(code_handler, text)
text = a_re.sub(inner_a_handler, text)
text = fix_url.sub(r'\1', text)
return MD_START + text + MD_END