X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Fbuild%2Fhtml-to-texi.py;fp=scripts%2Fbuild%2Fhtml-to-texi.py;h=a7005ec150b28041022073a4259604cc8cf06970;hb=e90f0536f9be39ada0bef0aeb0d275dec3b2fb5b;hp=0000000000000000000000000000000000000000;hpb=a8c9e8a7ca320ab0df5fd32e717fd62cd7635ce6;p=lilypond.git
diff --git a/scripts/build/html-to-texi.py b/scripts/build/html-to-texi.py
new file mode 100644
index 0000000000..a7005ec150
--- /dev/null
+++ b/scripts/build/html-to-texi.py
@@ -0,0 +1,94 @@
+#! @PYTHON@
+
+import re
+import sys
+
+header = '''
+'''
+
+print header
+
+body = sys.stdin.read ()
+body = re.sub ('(?ms)', '', body)
+body = re.sub ('(?ms)\n*\s*', r'@ignore\n\1\n@end ignore', body)
+body = re.sub ('(?ms)(.*?)', r'@ref{\1,\2}', body)
+
+body = re.sub ('(?ms) *', r'@node \1 ', body)
+body = re.sub ('(?ms)
(.*?)
', r'@chapheading \1', body)
+body = re.sub ('(?ms)(.*?)
', r'@unnumberedsec \1', body)
+#body = re.sub ('(?ms) *', '', body)
+#body = re.sub ('(?ms)(.*?)
', r'@node \1\n@unnumberedsec \1', body)
+
+body = re.sub ('(?ms)]*src="*([^">]*)(.png|.jpeg)"*.*?>', r'@image{\1,,,\2}', body)
+body = re.sub ('\n*
\s*\n*', r'@*\n', body)
+body = re.sub ('\n*
]*>\s*\n*', r'@*\n', body)
+body = re.sub ('(?ms)(.*?)', r'@emph{\1}', body)
+body = re.sub ('(?ms)(.*?)
', r'@quote{\1}', body)
+body = re.sub ('(?ms)(.*?)', r'@code{\1}', body)
+body = re.sub ('(?ms)(.*?)()', r'@item\n\1\n', body)
+body = re.sub ('(?ms)(.*?)()', r'@item\n\1\n\2', body)
+body = re.sub ('(?ms)(.*?)()', r'@item\n\1\n\2', body)
+body = re.sub ('(?ms)(.*?)()', r'@item\n\1\n\2', body)
+body = re.sub ('(?ms)(.*?)()', r'@item\n\1\n\2', body)
+body = re.sub ('(?ms)(.*?)()', r'@item\n\1\n\2', body)
+body = re.sub ('(?ms)(.*?)((?:u|o)l>)', r'@item\n\1\n\2', body)
+body = re.sub ('(?ms)', r'@itemize', body)
+body = re.sub ('(?ms)
', r'@end itemize', body)
+
+# added for the bib => bib2html => html2texinfo chain. -gp
+body = re.sub ('(?ms)', r'', body)
+body = re.sub ('(?ms)(.*?)()', r'', body)
+body = re.sub ('(?ms)', r'', body)
+body = re.sub ('(?ms)', r'', body)
+body = re.sub ('(?ms)', r'', body)
+
+body = re.sub ('(?ms)', r'@table @emph', body)
+body = re.sub ('(?ms)
', r'@end table', body)
+
+body = re.sub ('(?ms) (.*?)()', r'@item \1', body)
+body = re.sub ('(?ms)', r'', body)
+body = re.sub ('(?ms):', r'', body)
+body = re.sub ('(?ms)(.*?)()', r'\1', body)
+
+body = re.sub ('(?ms)(.*?)()', r'@strong{\1}', body)
+body = re.sub ('(?ms)(.*?)()', r'@emph{\1}', body)
+
+body = re.sub ('(?ms) ', r'@tie{}', body)
+
+body = re.sub ('(?ms)\cite{(.*?)}', r'[\1]', body)
+body = re.sub ('(?ms)\cite{(.*?)}', r'[\1]', body)
+
+# dangerous rule, but with the spaces should be ok
+body = re.sub ('(?ms) {(.*?)} ', r' @q{\1} ', body)
+
+# end stuff added for the bib => bib2html => html2texinfo chain -gp
+# the other lines in the file can _probably_ be trimmed.
+
+
+body = re.sub ('(?ms)', r'@enumerate POSITIVE-INTEGER', body)
+body = re.sub ('(?ms)', r'@enumerate \1', body)
+body = re.sub ('(?ms)
', r'@end enumerate', body)
+
+body = re.sub ('“(.*?)”', r'@qq{\1}', body)
+body = re.sub ('ä', '@"a', body)
+body = re.sub ('(?ms)\s*\s*', '\n\n', body)
+body = re.sub ('\n*\s*
\s*\n*', '\n\n', body)
+body = re.sub ('(?ms)?font\s*.*?>', '', body)
+body = re.sub ('(?ms)(.*?)
', r'@code{\1}', body)
+body = re.sub ('(?ms)(.*?)', r'@emph{\1}', body)
+body = re.sub ('(?ms)(.*?)', r'@strong{\1}', body)
+body = re.sub ('(?ms)(.*?)
', r'@verbatim\n\1\n@end verbatim', body)
+body = re.sub ('(?ms)(.*?)
', r'@verbatim\n\1\n@end verbatim', body)
+
+body = re.sub ('(?ms)', r'@table asis', body)
+body = re.sub ('(?ms)]*>', r'@table asis', body)
+body = re.sub ('(?ms)
', r'@end table', body)
+body = re.sub ('(?ms)(.*?)
', r'@item\n\1\n', body)
+body = re.sub ('(?ms)(.*?) | ', r'@item\n\1\n', body)
+body = re.sub ('(?ms)]*>(.*?) | ', r'@tab\n\1\n', body)
+
+#body = re.sub ('(?ms)\s*\s*((?:.|\n)*)\n\n', '@divClass{float-\\1}\n\\2\n@divEnd', body)
+body = re.sub ('(?ms)\s*
\s*', '\n\n@divClass{float-\\1}\n@divEnd\n', body)
+
+print body
+