Skip to content

Commit

Permalink
irclogs clickable links
Browse files Browse the repository at this point in the history
The links are untrusted, so nofollow.
  • Loading branch information
da2x committed May 15, 2015
1 parent 9cbfa5e commit 9415e14
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions v7/irclogs/irclogs.py
Expand Up @@ -37,6 +37,7 @@

import os
import io
import re
import pygments
import pygments.lexers

Expand All @@ -59,5 +60,7 @@ def compile_html(self, source, dest, is_two_file=True):

formatter = NikolaPygmentsHTML('irclog', linenos=False)
data = pygments.highlight(data, lexer, formatter)
link_matcher = re.compile(r"(http[s]?://[^ ]+)")
data = link_matcher.sub(r'<a href="\1" rel="nofollow">\1</a>', data)
out_file.write(data)
return True

0 comments on commit 9415e14

Please sign in to comment.