Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DocBook: Specifying code or markup

You can specify equations using <equation> and also several others, but what tag must be used to specify code? More specifically, PHP, HTML, CSS and Javascript? Is there a plugin that you can use with OxygenXML to add these features automatically? I need to output as PDF.

like image 243
coderama Avatar asked Aug 14 '09 17:08

coderama


1 Answers

I'm working on a project which uses docbook, and has examples in PHP.

The examples in PHP are using programlisting tag, like this :

<programlisting language="php"><![CDATA[<?php

// Here goes the PHP code

]]></programlisting>

Note the language attribute.
It is used later by another tool to add syntax-coloration, when generating the ouput (for HTML output, at least)


For examples that are not specific to one programming language, like configuration files, we are using the screen tag ; for instance, for a part of an Apache-related config file, an example would be :

<screen><![CDATA[# Setup Listening Port
NameVirtualHost *:80

# Ensure "localhost" is preserved unchanged pointed
# to the default document root for our system.
<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /var/www
</VirtualHost>]]></screen>


Quoting their documentations :

A programlisting is a verbatim environment for program source or source fragment listings. The programlistings are often placed in examples or figures so that they can be cross-referenced from the text.

And :

A screen is a verbatim environment for displaying text that the user might see on a computer terminal. It is often used to display the results of a command.

Having less specific semantic overtones, screen is often used wherever a verbatim presentation is desired, but the semantic of programlisting is inappropriate.

So, these two seem quite appropriate.

like image 147
Pascal MARTIN Avatar answered Sep 19 '22 06:09

Pascal MARTIN