diff --git a/ansi2html/converter.py b/ansi2html/converter.py index 221c8a1..a655f6b 100755 --- a/ansi2html/converter.py +++ b/ansi2html/converter.py @@ -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, '%s' % (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'\1', line) def _needs_extra_newline(text):