hgbook

view en/fixhtml.py @ 152:44f233544e9e

Fix up the "note" rendering for HTML.
author Bryan O'Sullivan <bos@serpentine.com>
date Thu Mar 08 23:35:57 2007 -0800 (2007-03-08)
parents
children 2e73abddad21
line source
1 #!/usr/bin/env python
3 import os
4 import sys
5 import re
7 unicode_re = re.compile(r'&#x00([0-7][0-9a-f]);', re.I)
8 fancyvrb_re = re.compile(r'id="fancyvrb\d+"', re.I)
10 tmpsuffix = '.tmp.' + str(os.getpid())
12 def fix_ascii(m):
13 return chr(int(m.group(1), 16))
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)