Mercurial > hgbook
comparison en/fixhtml.py @ 149:16f02802f448
Start to produce saner HTML and CSS.
Drop the "beta" targets for now (forever?).
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Thu, 08 Mar 2007 22:51:50 -0800 |
parents | |
children | 2e73abddad21 |
comparison
equal
deleted
inserted
replaced
148:6a5864c09879 | 149:16f02802f448 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 import os | |
4 import sys | |
5 import re | |
6 | |
7 unicode_re = re.compile(r'�([0-7][0-9a-f]);', re.I) | |
8 fancyvrb_re = re.compile(r'id="fancyvrb\d+"', re.I) | |
9 | |
10 tmpsuffix = '.tmp.' + str(os.getpid()) | |
11 | |
12 def fix_ascii(m): | |
13 return chr(int(m.group(1), 16)) | |
14 | |
15 for name in sys.argv[1:]: | |
16 tmpname = name + tmpsuffix | |
17 ofp = file(tmpname, 'w') | |
18 for line in file(name): | |
19 line = unicode_re.sub(fix_ascii, line) | |
20 line = fancyvrb_re.sub('id="fancyvrb"', line) | |
21 ofp.write(line) | |
22 ofp.close() | |
23 os.rename(tmpname, name) |