Skip to content

Commit 9415e14

Browse files
committedMay 15, 2015
irclogs clickable links
The links are untrusted, so nofollow.
1 parent 9cbfa5e commit 9415e14

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed
 

‎v7/irclogs/irclogs.py

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
import os
3939
import io
40+
import re
4041
import pygments
4142
import pygments.lexers
4243

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.