Use of HTMLparser to change language

Marco Mariani marco at
Fri Mar 20 14:20:00 CET 2009

pranav wrote:

>>> I am sure there is a python way of solving this problem.
>> The common sense approach (nothing to do with python) would be to
>> rewrite everything to be dynamically generated with a template language
>> - in python those would be TAL, mako, genshi, jinja, whatever ...
>> anything is better than the current solution.
> Hmm ya, that is THE best thing, if this were an application. These are
> plain HTML files and needs to be shipped with CDs.

So what? Template engines are perfectly able to generate files instead 
of sending them off the net.

> Also, it is not in the design to use anything executable.

Do you mean "put executable in the CDs", but I'm not proposing that.

Anyway, I would probably start by looping all of the files with 'tidy' - 
to have the same formatting and hopefully attribute order, examining a 
few them with something like 'vimdiff' and see if I could come up with 
some rules to implement with BeautifulSoup. False positives (i.e. files 
that should be equal but aren't) are ok because they can give new rules 
to implement.

With the same retro-engineered rules I could create the templates from 
the static files.

More information about the Python-list mailing list