Regular Expression Help for Python Newbie.

Fredrik Lundh effbot at telia.com
Tue Apr 11 03:02:05 EDT 2000


Tony J Ibbs wrote:
> Fredrik Lundh replied:
> > <TR>'s are optional -- if the browser stumbles upon <TD>
> > in a <TABLE> context, it should insert <TR>'s all by itself.
>
> Well, no...

you're right -- but only in theory ;-)

> Of course, it's entirely possible to write a browser (or other HTML
reader)
> that can cope with missing <TR>'s *if* the </TR>'s are present.

it's easier than that, in fact -- according to the data model,
a <TABLE> contains a <TBODY> which contains one or more
<TR>'s, which in turn contains <TH>'s and/or <TD>'s.

so when the browser stumbles upon a <TABLE> followed by
a <TD>, it can easily figure the rest out itself, based on the
DTD.

> And obviously that's what some browsers do. This way also lies
> madness.

some?  I suspect 99.99% of browsers used for serious surfing
do things like this -- and *much* more...  (if you want to see
some real madness, go browse the original navigator sources ;-)

> I always find it strange that otherwise intelligent people don't want
> their compilers to work like this, but do want their browsers to.

well, if the early web had been restricted to people who can
read DTD's and map cryptic error messages to typos in their
sources, I doubt we'd have the rich web we have today...

    nsgmls:mypage.htm:38:3:E: start tag for "TR" omitted,
    but its declaration does not permit this

    huh?  there's no frigging TR in there?  and it looks good
    in my browser, so who cares about the "declaration"...

(the real design mistake is of course to do the fixes in the
browser, instead of doing them in the authoring system or
the server, but that's another story).

</F>





More information about the Python-list mailing list