plain text python source -> HTML syntax highlighted source

François Pinard pinard at iro.umontreal.ca
Fri May 12 18:55:14 EDT 2000


Chuck Esterbrook <echuck at mindspring.com> writes:

> I know there's a program out there that reads python source and spits
> out an HTML version with syntax highlighting. However, I don't remember
> where I saw it and my searching and skimming on Parnassus missed it.
> Does anyone know where I can get this?

I merely use GNU `enscript' for that, like this:

        lines = os.popen('enscript -p- -Whtml -G -E%s %s'
                         % (language or '', input)).readlines()

The variable `language' contains the string `python' for Python code.
If None, `enscript' will guess the language from the file extension.
(I merely wanted to force `.cgi' to mean Python.)

P.S. - For the curious, the above lines are taken from:

   http://www.iro.umontreal.ca/contrib/recode/lib/distroweb.py

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard






More information about the Python-list mailing list