Mark up some literal text as such in order to make it easier
to tell the literal text from the surrounding body text.
This commit is contained in:
parent
9e1d1c1566
commit
bb532247a5
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=25616
1 changed files with 24 additions and 13 deletions
|
@ -946,14 +946,18 @@ nsgmls:example.sgml:6:8:E: end tag for "HEAD" which is not finished</screen>
|
|||
document.</para>
|
||||
|
||||
<para>You can also use general entities to enter characters that you
|
||||
could not otherwise include in an SGML document. For example, <
|
||||
and & cannot normally appear in an SGML document. When the SGML
|
||||
parser sees the < symbol it assumes that a tag (either a start tag
|
||||
or an end tag) is about to appear, and when it sees the & symbol
|
||||
could not otherwise include in an SGML document. For example,
|
||||
<literal><</literal> and <literal>&</literal> cannot
|
||||
normally appear in an SGML document. When the SGML
|
||||
parser sees the <literal><</literal>
|
||||
symbol it assumes that a tag (either a start tag
|
||||
or an end tag) is about to appear, and when it sees the
|
||||
<literal>&</literal> symbol
|
||||
it assumes the next text will be the name of an entity.</para>
|
||||
|
||||
<para>Fortunately, you can use the two general entities &lt; and
|
||||
&amp; whenever you need to include one or other of these.</para>
|
||||
<para>Fortunately, you can use the two general entities
|
||||
<literal>&lt;</literal> and <literal>&amp;</literal>
|
||||
whenever you need to include one or other of these.</para>
|
||||
|
||||
<para>A general entity can only be defined within an SGML context.
|
||||
Typically, this is done immediately after the DOCTYPE
|
||||
|
@ -1369,22 +1373,28 @@ nsgmls:example.sgml:6:8:E: end tag for "HEAD" which is not finished</screen>
|
|||
|
||||
<para><literal>CDATA</literal> is for <quote>Character Data</quote>.
|
||||
If the parser is in this content model then it is expecting to see
|
||||
characters, and characters only. In this model the < and &
|
||||
characters, and characters only. In this model the
|
||||
<literal><</literal> and <literal>&</literal>
|
||||
symbols lose their special status, and will be treated as ordinary
|
||||
characters.</para>
|
||||
|
||||
<para><literal>RCDATA</literal> is for <quote>Entity references and
|
||||
character data</quote> If the parser is in this content model then it
|
||||
is expecting to see characters <emphasis>and</emphasis> entities.
|
||||
< loses its special status, but & will still be treated as
|
||||
<literal><</literal> loses its special status, but
|
||||
<literal>&</literal> will still be treated as
|
||||
starting the beginning of a general entity.</para>
|
||||
|
||||
<para>This is particularly useful if you are including some verbatim
|
||||
text that contains lots of < and & characters. While you
|
||||
could go through the text ensuring that every < is converted to a
|
||||
&lt; and every & is converted to a &amp;, it can be
|
||||
text that contains lots of <literal><</literal> and
|
||||
<literal>&</literal> characters. While you
|
||||
could go through the text ensuring that every
|
||||
<literal><</literal> is converted to a
|
||||
<literal>&lt;</literal> and every <literal>&</literal>
|
||||
is converted to a <literal>&amp;</literal>, it can be
|
||||
easier to mark the section as only containing CDATA. When the SGML
|
||||
parser encounters this it will ignore the < and & symbols
|
||||
parser encounters this it will ignore the
|
||||
<literal><</literal> and <literal>&</literal> symbols
|
||||
embedded in the content.</para>
|
||||
|
||||
<note>
|
||||
|
@ -1402,7 +1412,8 @@ nsgmls:example.sgml:6:8:E: end tag for "HEAD" which is not finished</screen>
|
|||
<title>Using a CDATA marked section</title>
|
||||
|
||||
<programlisting><para>Here is an example of how you would include some text
|
||||
that contained many &lt; and &amp; symbols. The sample
|
||||
that contained many <literal>&lt;</literal>
|
||||
and <literal>&amp;</literal> symbols. The sample
|
||||
text is a fragment of HTML. The surrounding text (<para> and
|
||||
<programlisting>) are from DocBook.</para>
|
||||
|
||||
|
|
Loading…
Reference in a new issue