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: Al Gilman
Subject: Re: LYNX-DEV A question about <SCRIPT> <!-- comment --> </SCRIPT>
Date: Sat, 12 Apr 1997 11:34:50 -0400 (EDT)

  From: Klaus Weide <address@hidden>

  On Sat, 12 Apr 1997, --- Alvian --- wrote:
  
  > 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...
  
In the mind of the author writing the HTML 3.2 document you quote,
the SCRIPT block can also be closed by closing a container in which
the SCRIPT container is enclosed.  There is no language definition
of that set of tags starting with </[a-zA-Z], the definition lies
in the parse stack for the current document.

Alvian:
  > Why do script authors
  > put a comment immediately inside a SCRIPT block to shield the
  > instructions?
  
Al:
Because they have been taught to document their programs with comments.
The program they write is mechanically pasted within a <SCRIPT> block
not by the writer of the script.

The catch-22 for Javascript is probably that <!-- ... --> is 
a Javascript comment section, but by the rules of HTML the SCRIPT
tag per se deprives it of that special status.  One would need to 
create a <JAVASCRIPT> tag which is a peer of the SCRIPT tag except
that it preserves more of the low-level utilities of SGML such as
commenting...

  > 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.
  
Al:
You can do this by escaping the literal </SCRIPT> that appears
within the script as literal text to be placed in the returned
page IF the target script language provides some escape mechanism
that it will decode, such as URL-encoding.  The inner tag needs
to be expressed in some way -- hey- it could even be a
catenate-expression -- such that the script when it runs returns
a </SCRIPT> but the text of the script doesn't literally say
</SCRIPT> or the parse of the enclosing document will say "Time's
up -- that's all the script you get!"
;
; 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]