5 February 20021

HTML Formatting Minutae

There are three little annoyances you will encounter.

You can handle this with your text editor's search/replace. YOu can also paste your raw stuff into a file and use the program shown below on it, open the file it creates, and paste it into your document.

Previewing HTML You can open an HTML file with your text editor to edit. Then, use File &arar; Open in your browser to actually see it rendered.

This handy little program opens a file, reads it, translates any characters such as < and > and & into HTML special character entities. You can copy it from here or right click on the link in the navigation area to save it where you want it.


#!/usr/bin/python
from sys import argv
from html import escape
inFileName = argv[1]
outFileName = inFileName + ".out"
inFilePipe = open(inFileName, "r")
outFilePipe = open(outFileName, "w")
text = inFilePipe.readlines()
for line in text:
	line = escape(line)
	outFilePipe.write(line)
outFilePipe.close()
inFilePipe.close()

Here is how to use it. Open a cmd window and type

unix> python htmlify.py your_file

The converted file will be named your_file.out.

You will see me using this often so code examples will display propeerly in HTML.