How do you output the html? print statements to STDOUT or some kind of templating system? Also what is the source of the input? A file or a database? Maybe you should reverse the problem and write a one off script that converts the input data once and for good.
holli
You can lead your users to water, but alas, you cannot drown them.