Re: Using "&...;" in <PRE> sections

Bert Bos (bert@let.rug.nl)
Tue, 12 Jul 1994 16:51:24 +0200 (METDST)


Dan Connolly writes:

|'>' is not _necessarily_ special, but
|in some cases it is. ]]> is the marked section end delimiter.
|
|The easiest way to tell folks a simple algorithm for representing
|an arbitrary string in PCDATA is to say
| "replace all &, <, and > with entity references or
| numeric character entities."
|
|Note that the spec says that this is sufficient -- it doesn't say
|it's necessary.

Of course. It's better to be safe than sorry.

|>To widen the discussion a bit: I know this definition of PRE is
|>current practice, but can't we change it? I've always wondered why
|>PRE wasn't defined as
|>
|> <!element pre - - cdata>
|>
|>that way you could _really_ enclose any piece of program code in PRE
|>tags, without having to remove `<' and `&'.
|
|There's no way to represent the string </x inside CDATA. None. So
|if your program includes that string (or ]]>) you're out of luck.

Yes, the characters "</" followed by a letter may not occur in an
element declared as CDATA, but how often will that happen? All
programming languages I know, except for SGML, use "<" and "&", but
none uses "</". (Btw. The string "]]>" is OK here.)

Aside:

The string "</" would not be special (but "]]>" would) in an
`unparsable marked section', another obscure SGML feature: you can
actually include CDATA anywhere, by enclosing it in <![ CDATA [...]]>,
like this:

<P>This is a normal paragraph, but it has some strange characters
in it and I'm too lazy to replace them with entities... <![ CDATA [
< > </ & <! <!-- ]]>

Bert

-- 
___________________________________________________________________________
####[ Bert Bos                     ]####[ Alfa-informatica,           ]####
####[ <bert@let.rug.nl>            ]####[ Rijksuniversiteit Groningen ]####
####[ http://www.let.rug.nl/~bert/ ]####[ Postbus 716                 ]####
####[                              ]####[ NL-9700 AS GRONINGEN        ]####
####[______________________________]####[_____________________________]####

+++ Hey! I'm a .signature virus. Help me and include me in your .sig file! +++