Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / stepmake / bin / text2html.py
blob51f3948ef4aa68507f4f8ebfdd652ad626346981
1 #@PYTHON@
2 import os
3 import re
4 import string
5 import sys
8 entities = {
9 "&" : 'amp',
10 "`" : 'apos',
11 '>' : 'gt',
12 '<' : 'lt',
13 '"' : 'quot',
16 def txt2html (s):
17 for i in entities.keys ():
18 s = re.sub (i, '\001' + entities[i] + ';', s);
19 s = re.sub ('\001', '&', s);
20 return s
22 for a in sys.argv[1:]:
23 # hmm, we need: text2html out/foe.txt -> out/foe.html,
24 # -o is a bit overkill?
25 # outfile = os.path.basename (os.path.splitext(a)[0]) + '.html'
26 outfile = os.path.splitext(a)[0] + '.html'
28 try:
29 os.unlink(outfile)
30 except:
31 pass
33 s = r"""
35 <html>
36 <head>
37 <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
38 </head>
40 <body><pre>
42 </pre></body></html>
43 """ % txt2html (open (a).read ())
44 open (outfile, 'w').write (s)