Convert links in the commit message and comments, to be rendered as
clickable XHTML links for easy navigation.
Currently only http, https, ftp and git are recognized. And only links
that are not broken across lines are recognized.
Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
Closes: #591
_span = '<span class="%s">%s</span>'
+_comment_link_re = re.compile(r'(https|http|git|ftp)://[^<)\s]+', re.I)
+
+_link = '<a href="%s">%s</a>'
+
@register.filter
def patchsyntax(patch):
for r, cls in _comment_span_res:
content = r.sub(lambda x: _span % (cls, x.group(0)), content)
+ content = _comment_link_re.sub(
+ lambda x: _link % (x.group(0), x.group(0)), content
+ )
return mark_safe(content)