PY to HTML

Kirby Urner urner at alumni.princeton.edu
Thu Jul 27 19:01:35 EDT 2000


"Colin Meeks" <colinmeeks at home.com> wrote:

>Does anybody know anything that will enable me to convert a Python script to
>HTML, so I can display it on a webpage nicely formatted with syntax colour
>coding.  Manually coding is a pain in the posterior :-)
>
>Colin
>

Yes, some folks have put out the components you need, 
one of them by Guido's bro, Just van Rossum.

You need py2html and PyFontify. 

I've made them downloadable for you at
ftp://ftp.teleport.com/pub/users/pdx4d/python/

along with html.py -- a few lines I wrote to glue these 
together and make conversion easier.  You just go:

 >>> import html
 >>> html.convert("turtles")  # no file extension (assumes .py)
 OK

and you'll have turtles.html (or whatever).

Note:  I changed py2html slightly to make its colors 
match the ones used by Windows IDLE.  I've used this
colorizing capability a lot at:

http://www.inetarena.com/~pdx4d/ocn/numeracy0.html

(my 'Numeracy + Computer Literacy' series, featuring
Python as teaching language -- see the Python edu-sig
for more ramblings and background about it).

Also:  the above utilities do not, so far as I know,
color code cut 'n paste transcripts from the 
command window itself, just .py files.  I still to
quite a bit of manual colorizing of cut 'n paste 
sessions.


Kirby




More information about the Python-list mailing list