RE: Bug report: LINK tag not well-formed in output

Evan Lenz wrote:
> 
> This code:
> 
> <STYLE>
> <LINK REL="stylesheet"
> HREF="http://www.thestreet.com/tsc/common/stylesheets/global.css"
> TYPE="text/css">
> </STYLE>
> 
> Resulted in (XHTML mode):
> 
> <LINK REL="stylesheet"
> HREF="http://www.thestreet.com/tsc/common/stylesheets/global.css"
> TYPE="text/css">
> 
> 
> Besides the fact that it's not XHTML (lower case), it's not well-formed, as
> it should be an empty element.
> 
> I understand what the problem is here: <LINK> should be under <HEAD>, not
> <STYLE>.  For my application, I don't particularly care if the XHTML output
> is valid or not, but I definitely care if it's well-formed.
> 
> It would be nice if there was a way to incorporate, say, a SAX parser to
> ensure the output is well-formed, and give the user options as to what to do
> when it's not well-formed.  I would like a method returning true or false,
> to let me know whether I should go on or not.
> 
> What exactly is the criterion for Tidy outputting something versus nothing?
> In this case, <LINK> in its context, should be an unrecognized element...
> 
> Any further thoughts on this would be appreciated.

This is related to the JavaScript problem I mentioned in my previous
reply.  Tidy is interpreting the style element's content as just text,
not a tag to be tidied.  The "proper" XHTML output should escape the <
preceding the LINK, or wrap the content in a CDATA section.  The problem
is that, as you indicated in another message, many Tidy users want
Tidy's XHTML output to be directly renderable by today's browsers where
escaped <'s and XML CDATA sections aren't recognized.

One workaround is for Tidy to hide the CDATA section markup in comments.
This produces well-formed XML and that is also directly renderable by
existing browsers.  The gotcha is that every script and style language
has its own comment syntax, so Tidy can only recognize a limited set.

--Randy

Received on Wednesday, 6 September 2000 15:14:05 UTC