W3C home > Mailing lists > Public > html-tidy@w3.org > January to March 2001

Re: Problem with TidyGUI 1.0

From: Richard A. O'Keefe <ok@atlas.otago.ac.nz>
Date: Tue, 27 Feb 2001 17:11:06 +1300 (NZDT)
Message-Id: <200102270411.RAA05833@atlas.otago.ac.nz>
To: cknight@attcanada.ca, html-tidy@w3.org
"Chris Knight" <cknight@attcanada.ca> wrote:
        Whenever Tidy finds a backslash character within a quoted string
        (of HTML code) within a JavaScript, it (Tidy) emits this message:
            line nn column nn - Warning: '<' + '/' + letter not allowed here
        
Point 1.  That's not a backslash.  It's a forward slash.

        For example, the following line (within a properly coded
        JavaScript) caused 4 errors, one for each backslash:
              shInfo = "<P><B>Folder:</B><BR>" + sFolder + "</P><P><B>File:</B><BR>"
        + sFile + "</P>";
        
        I don't think Tidy should ever parse quoted strings,

It didn't.

        but, that aside, I am
        not aware of a REAL problem in such cases. Am I mistaken?
        
Badly mistaken.  I'm assuming here that you are using a <SCRIPT> element
to contain your Javascript code.  If you look in the DTD, you'll find
        ...
        <!ENTITY % Script "CDATA">
        ...
        <!ELEMENT SCRIPT - - %Script;>
        ...
I don't know what they were smoking, but the SGML designers made a MAJOR
blunder when they designed CDATA and RCDATA elements.  These are elements
that contain no markup (CDATA) or no markup except character and entity
references (RCDATA), and you would expect that they would be terminated
by their own end-tag only.  Wrong.  The blunder is that they are terminated
by *ANY* end-tag.  So if you have
        <SCRIPT ...>shInfo = "<P><B>Folder:</B><BR>";</SCRIPT>
                                           ^
the script element actually ends right here|  not over here^^.
It then turns out to be erroneous because its own end-tag is missing.

It is ***important*** to write this as

              shInfo = "<P><B>Folder:<" + "/B><BR>" + sFolder + 
                       "<" + "/P><P><B>File:<" + "/B><BR>" +
                       sFile + "<" + "/P>";

because there are HTML processors out there that ***will*** do this the
strictly legal way and misunderstand you.

Better still, write yourself some little functions
	function p(s) { return "<P>" + s + "<" + "/P">; }
	function b(s) { return "<B>" + s + "<" + "/B">; }
	function l(s,t) { return p(b(s+":")+"<BR>"+t); }
and then write
	shInfo = l("Folder", sFolder) + l("File", sFile);

It's just like the old problem that *no* programming language has nesting
comment brackets that actually work reliably (not even Haskell or Lisp).
Received on Monday, 26 February 2001 23:11:17 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 April 2012 06:13:45 GMT