kaet.livejournal.com |
Fri 2003-05-30 08:46 |
An SGML true-comment is any text ecluding COM (--), surrounded by two COM. There are a number of places it can be used, inside many MD's (<-- ... >) at sensible places, and also in an MD of its own. Any number of true-comments can occur in a comment MD, including zero, so <!> is a valid comment.
<!-- --> should only leave you out of a comment if you are not in one. If you are in a comment the first <! is seen as part of that comment (not an MDO), the COM is taken as the comment end, the space is permitted, the next COM puts you back into the next comment and the > is seen as comment material in the next comment (not as an MDC). The easiset way to illustrate this is as
<!-- > These <!-- --> are <!-- --> each <!-- --> comments <!-- --> in <!-- --> a <!-- --> single <!-- --> comment <!-- --> MD <!-->
which is a ingle comment declaration containing multiple comments with the texts:
- > These <!
- > are <!
- > each <!
- > comments <!
- > in <!
- > a <!
- > single <!
- > comment <!
- > MD <!
SGML, yay! Goodness knows what any browsers do with that (and it was a real arse entering all those character entities just now!) and HTML probably "traditionally" does something wrong too.
I can't think of a way of closing a comment declaration whether in one or not, (though I'm convinced there must be a way), it's difficult because of the way COM is used both to open and to close a comment within a comment declaration and is yet banned from a comment.
The space will have worked because mozilla is, spit using MDO-COM (<!--) as a comment start token and COM-MDC (-->) as a comment close token, and has a lexer dumb enough not to step over the whole token before looking for the end, the COM standing for both tokens, like parsing abc as ab followed by bc.
|
|