Skip to content

Commit

Permalink
Update url regex
Browse files Browse the repository at this point in the history
  • Loading branch information
sujanadiga committed Apr 3, 2018
1 parent 11cb736 commit 190835f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ansi2html/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,12 @@ def append_color_unless_default(output, color, default, negative, neg_css_class)


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

Expand Down

0 comments on commit 190835f

Please sign in to comment.