]> git.donarmstrong.com Git - lilypond.git/blobdiff - stepmake/bin/text2html.py
* lily/paper-system.cc (read_left_bound): new function. Read
[lilypond.git] / stepmake / bin / text2html.py
index b7f9c922c2ef2eaef1fe893a2defd45d19da3e34..80de4094506382eb78e157962e7113ce13442180 100644 (file)
@@ -1,8 +1,24 @@
 #@PYTHON@
 import os
+import re
 import string
 import sys
 
+
+entities = {
+       "&" : 'amp',
+       "`" : 'apos',
+       '>' : 'gt',
+       '<' : 'lt',
+       '"' : 'quot',
+       }
+
+def txt2html (s):
+       for i in entities.keys ():
+               s = re.sub (i, '\001' + entities[i] + ';', s);
+       s = re.sub ('\001', '&', s);
+       return s
+
 for a in sys.argv[1:]:
        # hmm, we need: text2html out/foe.txt -> out/foe.html,
        # -o is a bit overkill?
@@ -15,10 +31,16 @@ for a in sys.argv[1:]:
            pass
 
        s = r"""
-<html><body><pre>
+
+<html>
+<head>
+  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
+</head>
+
+<body><pre>
 %s
 </pre></body></html>
-""" % open (a).read ()
+""" % txt2html (open (a).read ())
        open (outfile, 'w').write (s)