#!/usr/bin/env python

"""Usage: code2html.py filename.pyrl
Convert program source into Everything2-compatible HTML

Free software by TeknoHog, 2002"""

import string, sys

filename = sys.argv[1]
file = open(filename, "r+")
temp = file.read()
file.close()

# This must be done prior to others; {}s are not ordered properly!
temp = string.replace(temp, "&", "&amp;")

transtable = { \
    "[": "&#91;", \
    "]": "&#93;", \
    "<": "&lt;", \
    ">": "&gt;", \
    }

for key in transtable.keys():
    temp = string.replace(temp, key, transtable[key])

print "<pre>\n" + temp + "\n</pre>\n"
