If I understand the specification corrently, comments are delimitted
by -- and --, but these delimitters can only occur in a block marked
by <! and >. Is this correct?
If I try to validate something like <!-- a -- b -- c --> then the
validator obviously complains about b: "invalid comment declaration:
found name start character outside comment but inside comment
declaration". Is there anything that can occur in such a place in
HTML? I wondered about the DOCTYPE statement, but it failed to
validate.
It's common to 'comment out' Javascript, but presumably in the
following:
<script type="text/javascript">
<!-- begin comment out
a=5;b=5;
b--;
if (a>b) document.write("<p>a is greater than b</p>");
// end comment out -->
</script>
the comment ends at the -- in 'b--;', the block containing the comment
ends at the '>' in 'if (a>b)', and the script elements ends at the
'</' in the '</p>'. If this occured in the document body, we would
see:
p>"; // end comment out -->
Am I correct in this assessment? (I know that real browsers cope with
horrible mess like this, I'm talking from a more theoretical
viewpoint.)
(I'm asking this as I'm thinking about automated HTML neatening -
presumably the correct approach is to removing the commenting out (as
pretty much all browsers now know not to display the contents of a
script element), parse the javascript, albeit at a very shallow level,
and escape occurances of </. Either that or move the javascript to an
external file, of course.)
--
Safalra (Stephen Morley)
http://www.safalra.com/hypertext/