- From: Leif Halvard Silli <xn--mlform-iua@xn--mlform-iua.no>
- Date: Thu, 18 Feb 2010 16:04:37 +0100
- To: Krzysztof Maczyński <1981km@gmail.com>
- Cc: www-archive <www-archive@w3.org>, Philip Taylor <pjt47@cam.ac.uk>
(Moving to www-archive.) In reply to: http://www.w3.org/mid/20100218010121863991.5635f637@xn--mlform-iua.no Leif Halvard Silli, Thu, 18 Feb 2010 01:01:21 +0100: > Krzysztof Maczyński, Wed, 17 Feb 2010 21:41:03 +0100: >> Thanks, Leif, for your clever solution at >> http://www.målform.no/html4-or-html5/take2_workaround which looks >> both cleaner and more universal. Have you got an explanation handy? >> As SGML I understand it but not how mainstream browsers parse it. Trying to explain more simply + add new info. Some repetition, to be complete. First: The "<!>" on line 3, [<!ATTLIST P myattr CDATA #implied --><!><!-- >]> is just a placeholder for "<!DOCTYPE HTML>" [<!ATTLIST P myattr CDATA #implied --><!DOCUMENT HTML><!-- >]> (which makes Safari trigger standards mode). User agents don't display '<!>' anyway. Second: Like I said, the last line is just something I did to un-confuse the syntax coloring of VIM. Thus the shortest variant of my workaround is the following (where I replaced the system identifier with simply "" - which is enough according to the current edition of HTML5 - thanks to Philip for that info.): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "" [<!ATTLIST P myattr CDATA #implied --><!-- >]> <!--><!!--> Annotation of components of the 2 last lines of the workaround: [<!ATTLIST P myattr CDATA #implied --> = The '-->' makes the preceding somehow end here as a "comment". <!-- >]> = "comment start". *Must* be a space before ">]>". Probably because "<!-->" is interpreted as a full comment (e.g. in Safari and also in HTML5.) ( "--><!--" is together a SGML comment inside the DOCTYPE - I know you know this, Krzysztof.) ;-) <!--><!!--> = 1) If the line only contained '<!-->', then ']>' would have been hidden in Safari and Firefox. But: Not valid mark-up syntax, of course. 2) If the line only contained '<!!-->', then ']>' would have been hidden in all GUI browsers I've tested. But: Not valid mark-up syntax, of course. 3) If the line only contained '<!---->', then ']>' would have been hidden in Firefox 3.6 with HTML5.enable turned on - and in Safari, Opera and IE. BUT: Firefox without HTML5.eable would hide the entire page content. 4) So why "<!--><!!-->"? When it starts with a '<!-->', then it is interpreted as a comment in itself, by many of the UAs. And thus '<!!--->' retains the benefit described in 2), while the entire line may still be interpreted as a valid HTML4 comment. (It is not a valid HTML5 comment ...) I hope this is not far from the truth ... -- Leif Halvard Silli
Received on Thursday, 18 February 2010 15:05:12 UTC