Mercurial > hgbook
view en/fixhtml.py @ 152:44f233544e9e
Fix up the "note" rendering for HTML.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Thu, 08 Mar 2007 23:35:57 -0800 |
parents | 16f02802f448 |
children | 2e73abddad21 |
line wrap: on
line source
#!/usr/bin/env python import os import sys import re unicode_re = re.compile(r'�([0-7][0-9a-f]);', re.I) fancyvrb_re = re.compile(r'id="fancyvrb\d+"', re.I) tmpsuffix = '.tmp.' + str(os.getpid()) def fix_ascii(m): return chr(int(m.group(1), 16)) for name in sys.argv[1:]: tmpname = name + tmpsuffix ofp = file(tmpname, 'w') for line in file(name): line = unicode_re.sub(fix_ascii, line) line = fancyvrb_re.sub('id="fancyvrb"', line) ofp.write(line) ofp.close() os.rename(tmpname, name)