The usual DocBook element for source code is the programlisting
. One of the optional attributes for
a programlisting is the language. If you set the language attribute to
cpp or to java, then the source code will be highlighted
accordingly.
Here, for example, is a programlisting with no language value set.
#include <iostream> using namespace std; /* A simple program */ int main() { cout << "Hello World!" << endl; return 0; // Zero denotes a normal termination }
and here is the same listing with a language attribute of cpp:
#include <iostream> using namespace std; /* A simple program */ int main() { cout << "Hello World!" << endl; return 0; // Zero denotes a normal termination }