blob: a1596d6f4dc699cca96cfd01e21858aee7f41a76 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#!/usr/bin/env python
import fileinput
import re
import sys
links = {}
for line in open(sys.argv[1], 'r'):
m = re.match('^([^=]+)=([^\n]+)$', line);
if m:
link = "<a href=\"" + m.group(2) + "\" class=\"dg\">" + m.group(1) + "</a>"
links[m.group(1)] = link
def translate(match):
return links[match.group(0)]
rc = re.compile('|'.join(map(re.escape, sorted(links, reverse=True))))
for line in open(sys.argv[2], 'r'):
print(rc.sub(translate, line))
|