1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
<html>
<body>
<h1>Removing HTML comments</h1>
Be sure the <b><font face="fixed">XmNenableBadHTMLWarnings</font></b> resource
is set to <b>True</b> before loading this document.<p>
This document should generate three warnings: one for line 37, one for line
53 and one for line 65.
<p>
First of all, this is the basic definition of a SGML comment (and since HTML
is an SGML application, it is also the definition of a HTML comment):
<blockquote><p>
A <i>comment declaration</i> starts with <!, followed by zero or more
comments, followed by >. A comment starts and ends with "--", and does
not contain any occurrence of "--".
</blockquote><p>
Note that an "empty" comment tag, with just "--" characters, should always
have a multiple of four "-" characters to be legal. (And yes, <!> is
also a legal comment - it's the empty comment).
<p></p><hr><p>
<!>
<tt><!> the empty comment (zero dashes)</tt>
<p></p><hr><p>
<!-- standard comment -->
<tt><!-- standard comment (four dashes) --></tt>
<p></p><hr><p>
<!-- text -- comment -- end -->
<tt><!-- text -- comment -- end (8 dashes) --></tt>
<p></p><hr><p>
<!-- this is a bad comment -- you see? -->
<tt><!-- this is a bad comment -- you see? (6 dashes) --></tt>
<p></p><hr><p>
<!--
a comment spanning multiple lines --
and it's a correct comment as well --
-->
<pre>
<!--
a comment spanning multiple lines --
and it's a correct comment as well (8 dashes) --
-->
</pre>
<p></p><hr><p>
<!--
a comment spanning multiple lines --
-- and it's a bad one --
-->
<pre>
<!--
a comment spanning multiple lines --
-- and it's a bad one (10 dashes) --
-->
</pre>
<p></p><hr><p>
<!---------------- International Sales Offices ---------------------->
<pre>
<!---------------- International Sales Offices ----------------------><br>
(bad comment, 38 dashes)
</pre>
(saillant detail: this comment comes straight from a Netscape document...)<br>
<p></p><hr><p>
<!----<-->
a nested comment (8 dashes) -->
<pre>
<!----<-->
a nested comment (8 dashes) -->
</pre>
(most browsers I know of get the above comment wrong: the <i>a nested ...</i>
will appear twice in them)
<p></p><hr><p>
<!------> hello-->
<pre>
<!------> hello-->
</pre>
(again, most browsers will also get this one wrong: the <i>hello--></i>
will appear twice)
<p></p><hr><p>
<!-- a comment - with dashes in between - (4 dashes and *not* 6) -->
<pre>
<!-- a comment - with dashes in between - (4 dashes and *not* 6) -->
</pre>
</body>
</html>
|