Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions patchwork/templatetags/syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def _compile(value):

_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):
Expand Down Expand Up @@ -74,5 +78,8 @@ def commentsyntax(submission):

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)