#!/usr/bin/python2.2

ss="""
<head>
<style type="text/css">
/* Used for proofreading.
.sect1 { margin-left: 1em}
.sect2 { margin-left: 2em}
.sect3 { margin-left: 3em}
.sect4 { margin-left: 4em}
*/
h1 { font-weight: bold; font-size: 2em;    margin: 0.67em 0 0;}
h2 { font-weight: bold; font-size: 1.5em;  margin: 0.83em 0 0;}
h3 { font-weight: bold; font-size: 1.17em; margin: 1em 0 0;}
h4 { font-weight: bold;                    margin: 1.33em 0 0;}
tt { font-family: courier; }
.programlisting { background: #ccc; }
p + div > dl {
 margin-top: 0;
 }
dd { margin-left: 50px; }
dl { margin-bottom: 0px; padding-bottom: 0px; }
ul { margin-top: 0px; margin-bottom: 0px}
li p { margin-bottom: 0px; }
BODY {
  /* FIXME gtkhtml2 like us to give the font-family Sans, because
     it does not seem to know about sans-serif. */
  font-family : Arial,Sans,sans-serif;
  text-decoration : none;
  font-size : 14px;
</style>
"""

import sys, os

def do_file(fn):
    if not os.path.isfile(fn):
        print "warning: file don't exist, skipping:", fn
        return
    f = open(fn, 'r')
    s = f.read()
    f.close()
    s = s.replace("<head>", ss)
    s = s.replace("<HEAD\n>", ss)
    f = file(fn, 'w')
    f.write(s)
    f.close()


for fn in sys.argv[1:]:
    do_file(fn)

