Posted by Jim Higson on 08/23/06 18:18
Abe Simpson wrote:
> Hi all,
>
> I am developing an HTML rendering app and now working on CSS
> implementation. I understand I need to build a document tree to be able to
> correctly implement CSS inheritance and contextual selectors. Now, a
> document
>
> ABC <B> DEF <I> GHI </i> KLM </B> NOP
>
> tranlates into a simple nice tree as every tag has a matching closing tag
> and there are no crossovers. But what do you do with something like this :
>
> ABC <B> DEF <I> GHI </B> KLM </I> NOP
>
> Note that the closing B tag is encounted before a closing I tag. This is
> still perfectly legal HTML, but how do you build a free out of that?
Personally, I'd just reject bad markup. If you must accept it, copy what the
main browsers do (you can use Mozilla's DOM inspector to see how they parse
it)
TagSoup (http://home.ccil.org/~cowan/XML/tagsoup/) is a good parser for bad
markup - maybe you can use that?
--
Jim
[Back to original message]
|