[Edu-sig] testing colorized code sharing

Kirby Urner pdx4d@teleport.com
Tue, 02 May 2000 23:38:00 -0700

At 07:52 AM 05/03/2000 +0100, Just van Rossum wrote:
>At 10:32 PM -0700 02-05-2000, Kirby Urner wrote:
>>Actually I guess it _depends on_ what Just did -- have to download
>>PyFontify.py separately, but the provided URL doesn't work, which
>>probably explains why the CGI script doesn't either (?).
>Dunno, it's still there on my starship page. However, since I currently
>have no access to the starship, I can't post the updated version. Two
>buglets were recently fixed. I've uploaded a version to

Thanks Just!

Worked like a charm.  Probably an access issue for me too, re

For those of you tracking on edu-sig:


give before and after pictures.  shapes.py was the input 
file, and shapes.html came out automatically, as a result
of running the downloaded code.

Here's some nuts and bolts for running from Windows IDLE
(my environment):

>>> import py2html
>>> import PyFontify
>>> c = py2html.PrettyPrint(PyFontify.fontify)
>>> c.file_filter(".\ocn\series.py",".\ocn\series.html")

That's it.  Last line provides input and output files,
with path.

Also, in order to use the same color scheme as Windows 
IDLE, I tweeked the PrettyPrint class.  The default
color scheme is pretty too, but it's cool that I could
easily customize to match what I've already been doing.

Below the commented out 'formats' dictionary is the
default, with my preferred colorizing scheme immediately

    def set_mode_html_color(self):

#	self.formats = {
#	    'all':('<PRE>','</PRE>'),
#	    'comment':('<FONT COLOR=#1111CC>','</FONT>'),
#	    'keyword':('<FONT COLOR=#3333CC><B>','</B></FONT>'),
#	    'parameter':('<FONT COLOR=#000066>','</FONT>'),
#	    'identifier':( lambda x,strip=string.strip:
#                          '<A NAME="%s"><FONT COLOR=#CC0000><B>' %
#	                   '</B></FONT></A>'),
#	    'string':('<FONT COLOR=#115511>','</FONT>')
#	    }

	self.formats = {
	    'comment':('<FONT COLOR=#FF3333>','</FONT>'),
	    'keyword':('<FONT COLOR=#FF6633>','</FONT>'),
	    'parameter':('<FONT COLOR=#000066>','</FONT>'),
	    'identifier':( lambda x,strip=string.strip:
                          '<A NAME="%s"><FONT COLOR=#0000FF>' % (strip(x)),
	    'string':('<FONT COLOR=#339933>','</FONT>')

    set_mode_rawhtml_color = set_mode_html_color

Thanks to all for helping.  Made my day (week even!).


PS:  re Tim's note, just in, I hope that wasn't me re the 
Starship crash.  All I did with enter an URL in that CGI blank,