lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LYNX-DEV A question about <SCRIPT> <!-- comment --> </SCRIPT>


From: Klaus Weide
Subject: Re: LYNX-DEV A question about <SCRIPT> <!-- comment --> </SCRIPT>
Date: Fri, 11 Apr 1997 22:44:16 -0500 (CDT)

On Sat, 12 Apr 1997, --- Alvian --- wrote:

> I have a question about comment inside a SCRIPT block.  I have
> tried my best to learn to write legal comments and to understand 
> what is valid inside a SCRIPT block.  But I am still puzzled.
> (BTW, I am using vanilla Lynx 2.7.1 on Ultrix.)
> 
> Here is an example HTML file:
> ----------
> <HTML><HEAD><TITLE>A test page</TITLE>
> <SCRIPT>
> <!-- Begin comment
> Lynx ignores things in a script block.  Lynx ignores things
> inside a comment block.  Should Lynx ignore the following tag?
> </SCRIPT>
> But: (1) can a comment exists in a script block and<p>
> (2) should Lynx keep a look out for comments within a script block?
> // End the comment here. -->
> </SCRIPT>
> </HEAD> <BODY>
> This is normal body text. <p>
> End of demonstration.
> </BODY> </HTML>

[ Lynx trace snipped ]

> It is easy to see what is happening.  Lynx saw a <SCRIPT> tag and
> started to ignore everything until it had found a </SCRIPT> tag.  My
> confusion is this:  Are comments legal within a SCRIPT block?  

I guess that depends on what you mean by "comments" and "legal"...
The sequence of four characters (for example) "<!--" is allowed
within a SCRIPT element, but it does not mean the beginning of a 
comment there.

> If
> they are legal then the </SCRIPT> tag on line 2 should not turn the
> comment off.  If they are illegal then please tell me, because I am too
> dumb to understand the HTML 3.2 Reference Specification (can't figure
> out what those containers mean).
> 
> >From HTML 3.2 Reference Specification:
> ----------
> STYLE and SCRIPT
> 
> <!ELEMENT STYLE  - - CDATA -- placeholder for style info -->
> <!ELEMENT SCRIPT - - CDATA -- placeholder for script statements -->
> 
> These are place holders for the introduction of style sheets and
> client-side scripts in future versions of HTML. User agents should
> hide the contents of these elements.
> 
> These elements are defined with CDATA as the content type. As a result
> they may contain only SGML characters. All markup characters or
> delimiters are ignored and passed as data to the application, except
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
"are ignored" _by the parser_, is what I understand.

> for ETAGO ("</") delimiters followed immediately by a name character
> [a-zA-Z]. This means that the element's end-tag (or that of an element
> in which it is nested) is recognized, while an error occurs if the
> ETAGO is invalid.
> ----------
> 
> This seems to say comments are effectively illegal in a SCRIPT block,
> because everything but </[a-zA-Z] should be ignored.  Is this so?  

"Should be ignored by the parser" is quite different from "is illegal".
It just means that a sequence of characters that would otherwise begin
a comment does not have that effect here.

> Why
> does the spec want you to look at </[a-rt-zA-RT-Z] since only a
> </SCRIPT> will close the SCRIPT block?  

I guess those rules are inherited from SGML...

> Why do script authors
> put a comment immediately inside a SCRIPT block to shield the
> instructions?

Presumably in order to hide the content from users of browsers which 
understand (some variation of..) comment syntax but do not understand
SCRIPT.  Or they have just read somewhere that this is the way to do it.
But a parser which understands the content model of SCRIPT correctly
(assuming that what you quoted is the description of the "correct" way,
and that there _is_ a correct way, and the parser at least _tries_ to
do something resembling parsing of SGML...) will not interpret "<!--"
as starting a comment.  It will just pass it as data (a sequence of
characters) to whatever is supposed to do something with the SCRIPT
contents.  It then may mean something or may not mean anything to
whatever interprets the SCRIPT contents.

> In case you are wondering, I saw this (Java?) SCRIPT which delivers a
> html-file, complete with another script, and the nested/delivered/
> secondary </SCRIPT> was closing the primary script prematurely.

Well it seems that's the wrong way then.

I am not an SGML expert, this is just my take on what you quoted.

  Klaus


;
; To UNSUBSCRIBE:  Send a mail message to address@hidden
;                  with "unsubscribe lynx-dev" (without the
;                  quotation marks) on a line by itself.
;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]