Chapter��6.��Listings and In-Line Display of Code and Markup

Styles for Code and Markup

Stuff goes here.

Examples

Examples pulled from other reference documents

Program Listings, Scripts, and XML type files

Example��6.1.��Listing Markup Code

How to list code blocks with DocBook Markup

<![CDATA[ ... ]]>

Thus this markup:

<programlisting><![CDATA[ <emphasis>text</emphasis> ]]></programlisting>

Produces this:

 <emphasis>text</emphasis> 
[Note]Note

This use of CDATA markup is very time saving when displaying large sections of DocBook code. The alternative is to escape every less and grater than sign on the markup - time consuming and hard to maintain.

See Writing Documentation Using DocBook:Using DocBook at CERN, Chapter 7, Example 7.3

Example��6.2.��Program Listing with Line Numbers

Simple program listing with linenumbers

<programlisting linenumbering="numbered">
10 PRINT "HELLO WORLD"
20 GOTO 10
</programlisting>

Produces the following:

  1 10 PRINT "HELLO WORLD"
  2          20 GOTO 10 

Program List with Callouts

Better example in XSLT book

sub do_nothing_useful {
    my($a, $b, $c);
                                                           
    $a = new A;
    
    $a->does_nothing_either();
                                                           
    $b = new B; 

    $c = "frog";
                                                           
    return ($a, $c);
}

1

These are calls to the constructor new in the object classes.

2

This function returns a two-element list.

3

The destructor (DESTROY) for the object $b will be called automatically for this object since there can be no other references to it outside this function.

Program Linst with Callout - in code
 
#ifndef _My_Parser_h_  1 
#define _My_Parser_h_
#include "MyFetch.h"   2
class My_Parser  3
{
public:
        //
        // Construction/Destruction
        //
        My_Parser();  3  4
        virtual      ~My_Parser() = 0;
        virtual int  parse(MyFetch &fetcher) = 0;
};
#endif

1

Make this conditional.

2

Load necessary constants.

3

Define new class

Univ/CIE/KA/StrucDoc/HowToBookProto/ChapCode (last edited 2015-03-06 18:11:25 by localhost)