W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2006

[whatwg] Comment Syntax and Parsing

From: Ian Hickson <ian@hixie.ch>
Date: Tue, 24 Jan 2006 21:55:49 +0000 (UTC)
Message-ID: <Pine.LNX.4.62.0601242130340.2856@dhalsim.dreamhost.com>
On Tue, 24 Jan 2006, Lachlan Hunt wrote:
> 
> As for how to parse it, I'll use these test cases to demonstrate what I 
> consider to be the most sane way to handle comments.  (Assume EOF at the 
> end of each one)
> 
> Test Case                          | Comment Content          | Output
> -----------------------------------|--------------------------|--------------
> PA<!>SS                            | ""                       | PASS
> PA<! ->SS                          | " -"                     | PASS
> PA<! -->SS                         | " "                      | PASS
> PA<!->SS                           | "-"                      | PASS
> PA<!- ->SS                         | "- -"                    | PASS
> PA<!- ->SS -->                     | "- -"                    | PASS -->

Agreed.


> PA<!- <!-->SS -->                  | "- <!"                   | PASS -->

Comment should be "- <!--" IMHO. It's still a bogus comment (in HTML5 
nomenclature), the "--" part is irrelevant.


> PA<!- <!-- ->SS -->                | "- <!-- -"               | PASS -->

Agreed.


> PA<!- -->SS                        | "- "                     | PASS
> PA<!- -- >SS                       | "- "                     | PASS

These are bogus comments, so again, they should be "- --" and "- -- " 
respectively, IMHO.


> PA<!-- FAIL -->SS                  | " FAIL "                 | PASS
> PA<!--> FAIL -->SS                 | "> FAIL "                | PASS
> PA<!--> FAIL <!-- -->SS            | "> FAIL <!-- "           | PASS
> PA<!--> FAIL <!-- -- -->SS         | "> FAIL <!-- -- "        | PASS

Agreed.


> PA<!-- > FAIL -- >SS               | " > FAIL "               | PASS

Disagree. The terminator should be "-->", not "-- S* >". I don't see any 
good reason to have "-- S* >".


> P<!-- -- >AS<!-- -->S              | " " (2 comments)         | PASS

Disagree (same reason). " -- >AS<!-- " is the comment, output is PS.


> PA<!-- FAIL -- FAIL -->SS          | " FAIL -- FAIL "         | PASS
> P<!-- -- -->AS<!-- -- -->S         | " -- " (2 comments)      | PASS
> PA<!-- -- -- -->SS                 | " -- -- "                | PASS
> PA<!-- FAIL -- FAIL -- FAIL -->SS  | " FAIL -- FAIL -- FAIL " | PASS
> PA<!--- FAIL -->SS                 | "- FAIL "                | PASS
> PA<!--- FAIL --->SS                | "- FAIL -"               | PASS
> <!-- ->FAIL                        | " ->FAIL"                |
> <!--- ->FAIL                       | "- ->FAIL"               |
> PA<!--->-->SS                      | "->"                     | PASS

Agreed.


> <!-- --- ->                        | (not sure)               |

Comment text is " --- ->".


> PA<!-- --- -->SS                   | " --- "                  | PASS
> PA<!--- --- --->SS                 | "- --- -"                | PASS

Agreed.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Tuesday, 24 January 2006 13:55:49 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:25 UTC