Skip to content

Instantly share code, notes, and snippets.

@gcr
Created January 30, 2016 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gcr/5a7d0691e3e7eea0041f to your computer and use it in GitHub Desktop.
Save gcr/5a7d0691e3e7eea0041f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
from glob import glob
"""
Convert the XML file into a nice-looking HTML file suitable for reading in
Chrome
"""
assert len(sys.argv)==2, "Usage: {} folder-to-convert".format(sys.argv[0])
filenames = glob(sys.argv[1]+'/*.xml')
assert len(filenames) == 1
filename = filenames[0]
with open(filename) as fin:
with open(filename.replace("xml","htm"), "w") as fout:
fout.write("""<!doctype html>
<style>
body {
width: 80%;
margin-left: 10%;
margin-right: 10%;
font-family: DejaVu Serif, Georgia, Times, Times New Roman, serif;
color: #002b36;
line-height: 150%;
background-color: #fdf6e3;
}
</style>
""")
fout.write("".join(fin.readlines()[2:]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment