Skip to content

Commit 190835f

Browse files
committed
Update url regex
1 parent 11cb736 commit 190835f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ansi2html/converter.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,12 @@ def append_color_unless_default(output, color, default, negative, neg_css_class)
176176

177177

178178
def linkify(line, latex_mode):
179-
url_matcher = re.compile('(https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+)')
179+
url_matcher = re.compile(
180+
r'(((((https?|ftps?|gopher|telnet|nntp)://)|'
181+
r'(mailto:|news:))(%[0-9A-Fa-f]{2}|[-()_.!~*'
182+
r'\';/?:@&=+$,A-Za-z0-9])+)([).!\';/?:,][[:blank:]])?)')
180183
if latex_mode:
181-
return url_matcher.sub(r'\\\\url{\1}', line)
184+
return url_matcher.sub(r'\\url{\1}', line)
182185
else:
183186
return url_matcher.sub(r'<a href="\1">\1</a>', line)
184187

0 commit comments

Comments
 (0)