From 99b4470b31fee94ed5bbccda89ba341f1561fd6d Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 10 Feb 2009 11:53:40 -0800 Subject: [PATCH] Fixed markdown so that URLs in blocks no longer have angle brackets wrapped around them --- r2/r2/lib/filters.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/r2/r2/lib/filters.py b/r2/r2/lib/filters.py index e69e12d6f..6403600de 100644 --- a/r2/r2/lib/filters.py +++ b/r2/r2/lib/filters.py @@ -98,9 +98,10 @@ def edit_comment_filter(text = ''): r_url = re.compile('(?', re.I | re.S) img = re.compile('', re.I | re.S) -href_re = re.compile('([^<]+)') a_re = re.compile('>([^<]+)') +fix_url = re.compile('<(http://[^\s\'\"\]\)]+)>') #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("&", "&").replace("<", "<").replace(">", ">") - #wrap urls in "<>" so that markdown will handle them as urls + text = text.replace("&", "&").replace("<", "<").replace(">", ">") + #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