sgmllib nit

Carl Banks idot at vt.edu
Sun Dec 10 04:41:44 CET 2000


Robin Becker <robin at jessikat.fsnet.co.uk>,
exactly what drugs were you under the influence of when you wrote:
>
> I realise that it does that! Unfortunately Zope's dtml isn't HTML.
> 
> Which parser should one use to analyse dtml which can contain tags like
> <dtml-var standard_html_header>?
> 
> The above analysis won't work easily if I have <tag X> as then I'm
> presented with attribute 'x' having value 'X'.
> 
> I merely want to copy the input to the output whilst making some trivial
> changes to the URL's in <A href=URL> style tags. I guess I need to write
> my own parser that doesn't make unnecessary assumptions.


I've noted this problem myself, when I was using sgmllib for an HTML
preprocessor for my web site.

Evidently, what you're "supposed" to do is keep track of which
attributes are boolean, and which take values.  While this may be
appropriate for an HTML renderer or syntax checker, it seems like a
lot to ask of someone writing a simple filter.  Even though it's not
sgmllib's advertised job, I think setting the attribute's "value" to
None when no value was given would be nice.


Yet, upon further reflection, I realized that I would almost never use
an attribute equaling its value.  Even if I did want to do that, I had
a good workaround.  So I just took attributes equaling their values to
mean that no value was given.


-- 
CARL BANKS                   http://filebox.vt.edu/users/cabanks1/

"I like nothing better than a good challenge.
 This is not one of them."



More information about the Python-list mailing list