Syntax Coloring

Eddie Corns eddie at holyrood.ed.ac.uk
Tue May 6 06:51:39 EDT 2003


eddie at holyrood.ed.ac.uk (Eddie Corns) writes:

>Salvatore <artyprog at wanadoo.fr> writes:

>>Hello,

>>I have a Forum site for beginners in Python
>>running on Zope Squishdot.
>>I would like to publish python scripts with syntax coloring.
>>Although Squishdot support HTML tags it does not support the <PRE> tag
>>Does anyone have a solution ?

>You can do fixed width formatting, indenting etc. using CSS.
>In fact it's a lot better because it's more flexible.
>It's not trivial but it's not too hard.

>How? you ask.  Ah well I haven't looked at CSS for many months now and someone
>has my only book and I can't find the test code I was working on.  However
>I'll see if I can find something useful on my home machine and send it on.

OK, I found my aborted attempt at a Python source to HTML using CSS.
It's conceptually quite simple to set the margin relative to the enclosing
margin and since it's in a stylesheet users can override it.  In combination
with mono spaced fonts and CSS styles to allow users control over their own
colour coding etc it could be quite nice.  The problem though is that Python
source can break strict indentation and it's pretty damn difficult to detect
this.  It doesn't happen often but you have to deal with all situations.

Probably the simplest solution then is just to use a mono spaced font until
someone comes up with a better source code analyser.

Eddie




More information about the Python-list mailing list