[FIX] tools: html_keep_url
The urls surrounded with "" or '' don't have to be clickable. opw:652397
This commit is contained in:
@@ -466,7 +466,7 @@ def html_keep_url(text):
|
||||
""" Transform the url into clickable link with <a/> tag """
|
||||
idx = 0
|
||||
final = ''
|
||||
link_tags = re.compile(r'(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?')
|
||||
link_tags = re.compile(r"""(?<!["'])((ftp|http|https):\/\/(\w+:{0,1}\w*@)?([^\s"':]+)(:[0-9]+)?(\/|\/([^\s"']))?)(?![^\s"']*["'])""")
|
||||
for item in re.finditer(link_tags, text):
|
||||
final += text[idx:item.start()]
|
||||
final += '<a href="%s" target="_blank">%s</a>' % (item.group(0), item.group(0))
|
||||
|
||||
Reference in New Issue
Block a user