hgbook

diff en/fixhtml.py @ 937:d7159547e28a

Fixing some URLs that was breaking the build... Some still not working here, but i'll fix it later
author Romain PELISSE <belaran@gmail.com>
date Sat Feb 14 13:27:23 2009 +0100 (2009-02-14)
parents 2e73abddad21
children
line diff
     1.1 --- a/en/fixhtml.py	Wed May 30 21:50:21 2007 -0700
     1.2 +++ b/en/fixhtml.py	Sat Feb 14 13:27:23 2009 +0100
     1.3 @@ -22,6 +22,7 @@
     1.4  angle_re = re.compile(r'(&#x003[CE];)')
     1.5  unicode_re = re.compile(r'&#x00([0-7][0-9A-F]);')
     1.6  fancyvrb_re = re.compile(r'id="fancyvrb\d+"', re.I)
     1.7 +ligature_re = re.compile(r'&#xFB0([0-4]);')
     1.8  
     1.9  tmpsuffix = '.tmp.' + str(os.getpid())
    1.10  
    1.11 @@ -31,12 +32,18 @@
    1.12  def fix_ascii(m):
    1.13      return chr(int(m.group(1), 16))
    1.14  
    1.15 +ligatures = ['ff', 'fi', 'fl', 'ffi', 'ffl']
    1.16 +
    1.17 +def expand_ligature(m):
    1.18 +    return ligatures[int(m.group(1))]
    1.19 +
    1.20  for name in sys.argv[1:]:
    1.21      tmpname = name + tmpsuffix
    1.22      ofp = file(tmpname, 'w')
    1.23      for line in file(name):
    1.24          line = angle_re.sub(hide_angle, line)
    1.25          line = unicode_re.sub(fix_ascii, line)
    1.26 +        line = ligature_re.sub(expand_ligature, line)
    1.27          line = fancyvrb_re.sub('id="fancyvrb"', line)
    1.28          ofp.write(line)
    1.29      ofp.close()