| 1 |
<refentry id="programlisting.element"> |
| 2 |
<?dbhtml filename="programlisting.html"?> |
| 3 |
<refentryinfo> |
| 4 |
<pubdate>$Date$</pubdate> |
| 5 |
<releaseinfo>$Revision$</releaseinfo> |
| 6 |
</refentryinfo> |
| 7 |
|
| 8 |
<refmeta> |
| 9 |
<indexterm><primary>elements</primary> |
| 10 |
<secondary>programlisting</secondary></indexterm> |
| 11 |
<refentrytitle>programlisting</refentrytitle> |
| 12 |
<refmiscinfo>Element</refmiscinfo> |
| 13 |
</refmeta> |
| 14 |
<refnamediv> |
| 15 |
<refname>programlisting</refname> |
| 16 |
<refpurpose>&programlisting.purpose;</refpurpose> |
| 17 |
</refnamediv> |
| 18 |
|
| 19 |
&programlisting.synopsis.gen; |
| 20 |
<refsect1 condition='ref.description'><title>Description</title> |
| 21 |
|
| 22 |
<para> |
| 23 |
A <sgmltag>ProgramListing</sgmltag> is a verbatim environment for program source or |
| 24 |
source fragment listings. <sgmltag>ProgramListing</sgmltag>s are often placed |
| 25 |
in <sgmltag>Example</sgmltag>s or <sgmltag>Figure</sgmltag>s so that they can be |
| 26 |
cross-referenced from the text. |
| 27 |
</para> |
| 28 |
|
| 29 |
<refsect2><title>Processing Expectations</title> |
| 30 |
<para> |
| 31 |
&format.block; &pexp.linespecific; <sgmltag>ProgramListing</sgmltag>s are usually |
| 32 |
displayed in a fixed width font. |
| 33 |
</para> |
| 34 |
|
| 35 |
<para> |
| 36 |
Other markup within a <sgmltag>ProgramListing</sgmltag> is recognized. |
| 37 |
Contrast |
| 38 |
this with systems like &LaTeX;, in which verbatim environments disable |
| 39 |
markup recognition. If you want to disable markup recognition, you |
| 40 |
must use a <glossterm>&CDATA; section</glossterm>: |
| 41 |
|
| 42 |
<programlisting> |
| 43 |
<![CDATA[ |
| 44 |
<programlisting> |
| 45 |
<![CDATA[ |
| 46 |
This is a programlisting so white space and line |
| 47 |
breaks are significant. But it is also a CDATA |
| 48 |
section so <emphasis>tags</emphasis> and &entities; |
| 49 |
are not recognized. The only markup that is recognized |
| 50 |
is the end-of-section marker, which is two |
| 51 |
"]"'s in a row followed by a >. |
| 52 |
]]> |
| 53 |
]]> |
| 54 |
<![CDATA[ |
| 55 |
</programlisting> |
| 56 |
]]> |
| 57 |
</programlisting> |
| 58 |
</para> |
| 59 |
|
| 60 |
<para> |
| 61 |
Two markup tags have |
| 62 |
special significance in <sgmltag>ProgramListing</sgmltag>s: <sgmltag>CO</sgmltag> |
| 63 |
and <sgmltag>LineAnnotation</sgmltag>. |
| 64 |
A <sgmltag>CO</sgmltag> identifies the location of a <sgmltag>Callout</sgmltag>. |
| 65 |
A <sgmltag>LineAnnotation</sgmltag> is a comment, added by the |
| 66 |
<emphasis>documentor</emphasis>—not the programmer. |
| 67 |
</para> |
| 68 |
</refsect2> |
| 69 |
|
| 70 |
<refsect2><title>Processing expectations</title> |
| 71 |
<para> |
| 72 |
&pexp.linespecific; |
| 73 |
</para> |
| 74 |
</refsect2> |
| 75 |
|
| 76 |
<refsect2 role='fu' revision="4.0"><title>&FutureChanges;</title> |
| 77 |
<para> |
| 78 |
|
| 79 |
&fu.interfacedefinition; |
| 80 |
</para> |
| 81 |
</refsect2> |
| 82 |
|
| 83 |
<refsect2 role='fu' revision="5.0"><title>&FutureChanges;</title> |
| 84 |
<para>The <literal>xml:space</literal> attribute is automatically |
| 85 |
provided in the XML DTD. |
| 86 |
</para> |
| 87 |
</refsect2> |
| 88 |
|
| 89 |
|
| 90 |
&programlisting.parents.gen; |
| 91 |
&programlisting.children.gen; |
| 92 |
</refsect1> |
| 93 |
<refsect1 condition='ref.elem.attrdesc'><title>Attributes</title> |
| 94 |
<variablelist> |
| 95 |
<varlistentry><term>format</term> |
| 96 |
<listitem> |
| 97 |
<para> |
| 98 |
The <sgmltag class="attribute">Format</sgmltag> attribute applies the |
| 99 |
<literal>linespecific</literal> notation to all <sgmltag>ProgramListing</sgmltag>s. |
| 100 |
All white space and line breaks must be preserved. |
| 101 |
</para> |
| 102 |
</listitem> |
| 103 |
</varlistentry> |
| 104 |
<varlistentry><term>linenumbering</term> |
| 105 |
<listitem> |
| 106 |
<para revision="4.0">Line numbering indicates whether or not the lines |
| 107 |
of a <sgmltag>ProgramListing</sgmltag> are to be automatically numbered. The details |
| 108 |
of numbering (every line or only selected lines, on the left or right, etc.) |
| 109 |
are left up to the processing application. Be aware that not all processors |
| 110 |
are capable of numbering lines.</para> |
| 111 |
</listitem> |
| 112 |
</varlistentry> |
| 113 |
<varlistentry><term>width</term> |
| 114 |
<listitem> |
| 115 |
<para> |
| 116 |
<sgmltag class="attribute">Width</sgmltag> specifies the width (in characters) |
| 117 |
of the longest line in this <sgmltag>ProgramListing</sgmltag> (formatters may use |
| 118 |
this value to determine scaling or rotation). |
| 119 |
</para> |
| 120 |
</listitem> |
| 121 |
</varlistentry> |
| 122 |
</variablelist> |
| 123 |
</refsect1> |
| 124 |
<refsect1 condition='ref.elem.seealso'><title>See Also</title> |
| 125 |
&programlisting.seealso.gen; |
| 126 |
</refsect1> |
| 127 |
<refsect1><title>Examples</title> |
| 128 |
|
| 129 |
&programlisting.example.seealso.gen; |
| 130 |
</refsect1> |
| 131 |
</refentry> |
| 132 |
|