programlisting

$Revision: 1666 $

$Date: 2002-06-12 07:19:37 -0400 (Wed, 12 Jun 2002) $

programlisting — A literal listing of all or part of a program

Synopsis

Mixed Content Model

programlisting ::=
(%para.char.mix;|co|coref|lineannotation|textobject)*

Attributes

Common attributes

Name

Type

Default

widthCDATANone
linenumbering
Enumeration:
numbered
unnumbered
None
languageCDATANone
xml:space
Enumeration:
preserve
None
continuation
Enumeration:
continues
restarts
None
format
Enumerated notation:
linespecific
"linespecific"
startinglinenumberCDATANone

Parameter Entities

The following parameter entities contain programlisting:

Parameter Entities
%admon.mix;%bookcomponent.content;%component.mix;
%divcomponent.mix;%example.mix;%figure.mix;
%footnote.mix;%glossdef.mix;%indexdivcomponent.mix;
%legalnotice.mix;%linespecific.class;%listpreamble.mix;
%para.mix;%qandaset.mix;%refcomponent.mix;
%revdescription.mix;%sidebar.mix;%tabentry.mix;
%tbl.entry.mdl;%textobject.mix; 

Description

A ProgramListing is a verbatim environment for program source or source fragment listings. ProgramListings are often placed in Examples or Figures so that they can be cross-referenced from the text.

Processing Expectations

Formatted as a displayed block. This element is displayed “verbatim”; whitespace and linebreaks within this element are significant. ProgramListings are usually displayed in a fixed width font.

Other markup within a ProgramListing is recognized. Contrast this with systems like LaTeX, in which verbatim environments disable markup recognition. If you want to disable markup recognition, you must use a CDATA section:


<programlisting>
<![CDATA[
This is a programlisting so white       space and line
breaks are significant.  But it is also a CDATA
section so <emphasis>tags</emphasis> and &entities;
are not recognized.  The only markup that is recognized
is the end-of-section marker, which is two
"]"'s in a row followed by a >.

]]>

</programlisting>

Two markup tags have special significance in ProgramListings: CO and LineAnnotation. A CO identifies the location of a Callout. A LineAnnotation is a comment, added by the documentor—not the programmer.

Processing expectations

This element is displayed “verbatim”; whitespace and linebreaks within this element are significant.

Future Changes

The InterfaceDefinition element will be discarded in DocBook V4.0. It will no longer be available in the content model of this element.

Future Changes

The xml:space attribute is automatically provided in the XML DTD.

Attributes

format

The Format attribute applies the linespecific notation to all ProgramListings. All white space and line breaks must be preserved.

linenumbering

[4.0]Line numbering indicates whether or not the lines of a ProgramListing are to be automatically numbered. The details of numbering (every line or only selected lines, on the left or right, etc.) are left up to the processing application. Be aware that not all processors are capable of numbering lines.

width

Width specifies the width (in characters) of the longest line in this ProgramListing (formatters may use this value to determine scaling or rotation).

See Also

computeroutput, lineannotation, literallayout, screen, screenshot, synopsis, userinput.

Examples

For examples, see example, informalexample, programlistingco, refentry.