Skip to content

Commit

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


def linkify(line, latex_mode):
for match in re.findall(r'https?:\/\/\S+', line):
if latex_mode:
line = line.replace(match, '\\url{%s}' % match)
else:
line = line.replace(match, '<a href="%s">%s</a>' % (match, match))

return line
url_matcher = re.compile('(https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+)')
if latex_mode:
return url_matcher.sub(r'\\url{\1}', line)
else:
return url_matcher.sub(r'<a href="\1">\1</a>', line)


def _needs_extra_newline(text):
Expand Down

0 comments on commit 9adc3dd

Please sign in to comment.