There are some things to watch out for when doing program listings. Let's say that we want to put the following fragment of code into DocBook:
#include <stdio.h> int main () { int count = 3; while (count—) printf ("Count is now %d\n", count); }
To do this you need to enclose it in a
programlisting
tag, and also make it into
CDATA
(i.e. literal text) so that
<stdio.h> isn't interpreted as an SGML
tag. The tags you need for this are:
<programlisting><![CDATA[ … ]]></programlisting>
The next thing to bear in mind is that Tab characters will not be expanded to spaces, so you will need to do all the indenting with spaces.
Warning |
There used to be a bug in openjade that caused incorrect TeX output for "—" (i.e. two dashes). This bug is fixed in CVS, and in the openjade-1.3-17 Red Hat Linux package. |