Commit b88fdd63 authored by fred's avatar fred

spip2html: regex to turning straight URLs into links

parent af527ac7
......@@ -228,6 +228,19 @@ class FormatterHtml(Formatter):
return ''
def paragraph(self, text):
# turn URL into links
def repl(match):
m = match.group(0)
if m[0] == '"' and m[-1] == '"':
return m
if m[0] in '>' and m[-1] == '<':
return m
m = m.rstrip('<').lstrip('>')
return '<a href="%s">%s</a>' % (m, m)
t1 = text
text = re.sub(r'([">]?http[s]?://[a-zA-Z0-9\.\/-]*[<"]?)', repl, text, re.DOTALL)
if self.states[-1] == 'blockLevel':
self.states.pop()
return text
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment