hgbook

view en/fixhtml.py @ 230:f83281da4122

Add new commands for commands and options provided by extensions.
Should improve indexing a bit.
author Bryan O'Sullivan <bos@serpentine.com>
date Sun May 27 09:39:27 2007 -0700 (2007-05-27)
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)