6.1.��In-Line Display of Code and Markups

A How-To Recipe

Jeff Elpern


Task

You want to refer to a programming instruction or a DocBook tag, or other XML tag, within the text of a paragraph.

Solution

The <code> is used to identify running text that is a programming instruction or XML tag fragment. The solutions that use the <code> tag are presented below. In the section called ���IN-Line Code��� An, the in-line display of a programming statement is presented. DocBook and XML tags are handled the section called ���In-Line DocBook and XML Tags���.

IN-Line Code

Use <code>

Example��1.��<code> for In-Line Code

Almost all manuals on Basic start with the <code>PRINT "HELLO WORLD"</code> instruction.

Produces the following display:

Figure��1.��Published output of Example��1, ���<code> for In-Line Code���

Almost all manuals on Basic start with the PRINT "HELLO WORLD" instruction.


In-Line DocBook and XML Tags

As discussed in the section called ���Listing DocBook Content and other XML Markup��� displaying DocBook or other XML markup requires the use of CDATA markup or the substitution of a character entity.

Below are two markup alternatives that generate the same result.

This markup substitutes decimal character entity for the brackets - "&#60;" for < and "&#62;" for >:

Example��2.��Entity Codes for In-Line Special Characters

To display a DocBook markup fragment use the <code> &#60;programlisting&#62; </code> tag.

Or, this markup uses the CDATA identifier so that with brackets around the tag are processed as characters:

Example��3.��CDATA for In-Line Special Characters

To display a DocBook markup fragment use the <code> <![CDATA[<programlisting>]]> </code> tag.

Both of which produce the line below:

Figure��2.��Published output of Example��2, ���Entity Codes for In-Line Special Characters��� and Example��3, ���CDATA for In-Line Special Characters���

To display a DocBook markup fragment use the <programlisting> tag.


Reference Material

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