HTML stylesheet expander?

Roger Binns rogerb at rogerbinns.com
Tue Nov 23 22:51:08 EST 2004


Does anyone have any code or pointers to something
that can take some HTML with CSS style information
and expand it into HTML that works pre-CSS.

For example, say I had a style like this:

 .citation { font-style: italic }

And had HTML like this:

  <p class="citation>foo bar</p>

Then the results produced are:

  <p><i>foo bar</i></p>

This does get somewhat complicated as the styles can be
"nested", apply to contained elements, expand to attributes
or new tags etc.

I generate the HTML and "own" the stylesheets.

The reason behind this is that the wxWidgets HTML control
doesn't support styles, and so something like this has to
be done to get the same kind of effect.

I do have a current solution that uses HTMLParser and
hierarchical style information that works, but really don't
like it.  It requires every HTML tag to be perfectly closed
and is very hacky.

There is talk on the wxPython group of using Mozilla or KHTML
but these aren't available on Windows, Linux and Mac, and/or
you get an entire tabbed browser etc in the deal.

Roger 





More information about the Python-list mailing list