Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  POD::DOCBOOK (3)

.ds Aq ’


Pod::DocBook - Convert Pod data to DocBook SGML



  use Pod::DocBook;
  my $parser = Pod::DocBook->new (title             => My Article,
                                  doctype           => article,
                                  fix_double_quotes => 1,
                                  spaces            => 3);

  $parser->parse_from_file (my_article.pod, my_article.sgml);


Pod::DocBook is a module for translating Pod-formatted documents to DocBook 4.2 SGML (see <>). It is primarily a back end for <B>pod2docbookB>, but, as a Pod::Parser subclass, it can be used on its own. The only public extensions to the Pod::Parser interface are options available to new():
doctype This option sets the output document’s doctype. The currently supported types are <B>articleB>, <B>chapterB>, <B>refentryB> and <B>sectionB>. Special processing is performed when the doctype is set to <B>refentryB> (see Document Types). You must set this option in order to get valid DocBook output.
fix_double_quotes If this option is set to a true value, pairs of double quote characters (’"’) in ordinary paragraphs will be replaced with <B><quote>B> and <B></quote>B>. See Ordinary Paragraphs for details.
header If this option is set to a true value, Pod::DocBook will emit a DOCTYPE as the first line of output.
spaces Pod::DocBook produces pretty-printed output. This option sets the number of spaces per level of indentation in the output.
title This option sets the output document’s title.
The rest of this document only describes issues specific to Pod::DocBook; for details on invoking the parser, specifically the new(), parse_from_file() and parse_from_filehandle() methods, see Pod::Parser.


Pod is a deceptively simple format; it is easy to learn and very straightforward to use, but it is suprisingly expressive. Nevertheless, it is not nearly as expressive or complex as DocBook. In most cases, given some Pod, the analogous DocBook markup is obvious, but not always. This section describes how Pod::DocBook treats Pod input so that Pod authors may make informed choices. In every case, Pod::DocBook strives to make easy things easy and hard things possible.

The primary motivation behind Pod::DocBook is to facilitate single-source publishing. That is, you should be able to generate man pages, web pages, PDF and PostScript documents, or any other format your SGML and/or Pod tools can produce, from the same Pod source, without the need for hand-editing any intermediate files. This may not always be possible, or you may simply choose to render Pod to DocBook and use that as your single source. To satisfy the first requirement, Pod::DocBook always processes the entire Pod source and tries very hard to produce valid DocBook markup, even in the presence of malformed Pod (see DIAGNOSTICS). To satisfy the second requirement (and to be a little nifty), Pod::DocBook pretty-prints its output. If you’re curious about what specific output to expect, read on.

    Document Types

DocBook’s structure is very modular; many of its document types can be embedded directly into other documents. Accordingly, Pod::DocBook will generate four different document types: <B>articleB>, <B>chapterB>, <B>refentryB>, and <B>sectionB>. This makes it easy, for instance, to write all the chapters of a book in separate Pod documents, translate them into DocBook markup and later glue them together before processing the entire book. You could do the same with each section in an article, or you could write the entire article in a single Pod document. Other document types, such as <B>bookB> and <B>setB>, do not map easily from Pod, because they require structure for which there is no Pod equivalent. But given sections and chapters, making larger documents becomes much simpler.

The <B>refentryB> document type is a little different from the others. Sections, articles, and chapters are essentially composed of nested sections. But a refentry has specialized elements for the NAME and SYNOPSIS sections. To accommodate this, Pod::DocBook performs extra processing on the Pod source when the <B>doctypeB> is set to <B>refentryB>. You probably don’t have to do anything to your document to assist the processing; typical man page conventions cover the requirements. Just make sure that the NAME and SYNOPSIS headers are both <B>=head1B>s, that NAME and SYNOPSIS are both uppercase, and that <B>=head1 NAMEB> is the first line of Pod source.

    Ordinary Paragraphs

Ordinary paragraphs in a Pod document translate naturally to DocBook paragraphs. Specifically, after any formatting codes are processed, the characters <, > and & are translated to their respective SGML character entities, and the paragraph is wrapped in <B><para>B> and <B></para>B>.

For example, given this Pod paragraph:

  Here is some text with I<italics> & an ampersand.

Pod::DocBook would produce DocBook markup similar to this:

    Here is some text with <emphasis role="italic">italics</emphasis>
    & an ampersand.

Depending on your final output format, you may sometimes want double quotes in ordinary paragraphs to show up ultimately as smart quotes (little 66s and 99s). Pod::DocBook offers a convenient mechanism for handling double quotes in ordinary paragraphs and letting your SGML toolchain manage their presentation: the <B>fix_double_quotesB> option to new(). If this option is set to a true value, Pod::DocBook will replace pairs of double quotes in ordinary paragraphs (and only in ordinary paragraphs) with <B><quote>B> and <B></quote>B>.

For example, given this Pod paragraph:

  Here is some text with I<italics> & an "ampersand".

Pod::DocBook, with <B>fix_double_quotesB> set, would produce DocBook markup similar to this:

    Here is some text with <emphasis role="italic">italics</emphasis>
    & an <quote>ampersand</quote>.

If you have a paragraph with an odd number of double quotes, the last one will be left untouched, which may or may not be what you want. If you have such a document, replace the unpaired double quote character with <B>E<quot>B>, and Pod::DocBook should be able to give you the output you expect. Also, if you have any <B>=begin docbookB> ... <B>=end docbookB> regions (see Embedded DocBook Markup) in your Pod, you are responsible for managing your own quotes in those regions.

    Verbatim Paragraphs

Verbatim paragraphs translate even more naturally; perlpodspec mandates that absolutely no processing should be performed on them. So Pod::DocBook simply marks them as CDATA and wraps them in <B><screen>B> and <B></screen>B>. They are not indented the way ordinary paragraphs are, because they treat whitespace as significant.

For example, given this verbatim paragraph (imagine there’s leading whitespace in the source):

  my $i = 10;
  while (<> && $i--) {
      print "$i: $_";

Pod::DocBook would produce DocBook markup similar to this:

  <screen><![CDATA[my $i = 10;
  while (<> && $i--) {
      print "$i: $_";
  }]] ></screen>

Multiple contiguous verbatim paragraphs are treated as a single screen element, with blank lines separating the paragraphs, as dictated by perlpodspec.

    Command Paragraphs

=head1 Heading Text
=head2 Heading Text
=head3 Heading Text
=head4 Heading Text All of the Pod heading commands produce DocBook section elements, with the heading text as titles. Pod::DocBook (perlpod) only allows for 4 heading levels, but DocBook allows arbitrary nesting; see Embedded DocBook Markup if you need more than 4 levels. Pod::DocBook only looks at relative heading levels to determine nesting. For example, this bit of Pod:

  =head1 1

  Contents of section 1

  =head2 1.1

  Contents of section 1.1

and this bit of Pod:

  =head1 1

  Contents of section 1

  =head3 1.1

  Contents of section 1.1

both produce the same DocBook markup, which will look something like this:

  <section id="article-My-Article-1"><title>1</title>
      Contents of section 1
    <section id="article-My-Article-1-1"><title>1.1</title>
        Contents of section 1.1

Note that Pod::DocBook automatically generates section identifiers from your doctype, document title and section title. It does the same when you make internal links (see Formatting Codes, ensuring that if you supply the same link text as you did for the section title, the resulting identifiers will be the same.

=over indentlevel
=item stuff...
=back =over ... =back regions are somewhat complex, in that they can lead to a variety of DocBook constructs. In every case, indentlevel is ignored by Pod::DocBook, since that’s best left to your stylesheets.

An =over ... =back region with no =items represents indented text and maps directly to a DocBook blockquote element. Given this source:

  =over 4

  This text should be indented.


Pod::DocBook will produce DocBook markup similar to this:

      This text should be indented.

Inside an =over ... =back region, =item commands generate lists. The text that follows the first =item determines the type of list that will be output:
o * (an asterisk) produces <B><itemizedlist>B>
o 1 or 1. produces <B><orderedlist numeration=arabic>B>
o a or a. produces <B><orderedlist numeration=loweralpha>B>
o A or A. produces <B><orderedlist numeration=upperalpha>B>
o i or i. produces <B><orderedlist numeration=lowerroman>B>
o I or I. produces <B><orderedlist numeration=upperroman>B>
o anything else produces <B><variablelist>B>

Since the output from each of these is relatively verbose, the best way to see examples is to actually render some Pod into DocBook.

=cut Pod::Parser recognizes these commands, and, therefore, so does Pod::DocBook, but they don’t produce any output.
=begin formatname
=end formatname
=for formatname text... Pod::DocBook supports two formats: <B>docbookB>, explained in Embedded DocBook Markup, and <B>tableB>, explained in Simple Tables.
=encoding encodingname This command is currently not supported. If Pod::DocBook encounters a document that contains =encoding, it will ignore the command and report an error (unknown command ‘%s’ at line %d in file %s).
Embedded DocBook Markup

There are a wide range of DocBook structures for which there is no Pod equivalent. For these, you will have to provide your own markup using <B>=begin docbookB> ... <B>=end docbookB> or <B>=for docbook ...B>. Pod::DocBook will directly output whatever text you provide, unprocessed, so it’s up to you to ensure that it’s valid DocBook.

Images, footnotes and many inline elements are obvious candidates for embedded markup. Another possible use is nesting sections more than four-deep. For example, given this source:

  =head1  1

  This is Section 1

  =head2 1.1

  This is Section 1.1

  =head3 1.1.1

  This is Section 1.1.1


  This is Section

  =begin docbook

  <para>This is Section</para>

  =end docbook

Pod::DocBook will generate DocBook markup similar to this:

    <section id="article-My-Article-1"><title>1</title>
        This is Section 1
      <section id="article-My-Article-1-1"><title>1.1</title>
          This is Section 1.1
        <section id="article-My-Article-1-1-1"><title>1.1.1</title>
            This is Section 1.1.1
          <section id="article-My-Article-1-1-1-1"><title></title>
              This is Section
  <para>This is Section</para>

Simple Tables

Pod::DocBook also provides a mechanism for generating basic tables with <B>=begin tableB> and <B>=end docbookB>. If you have simple tabular data or a CSV file exported from some application, Pod::DocBook makes it easy to generate a table from your data. The syntax is intended to be simple, so DocBook’s entire table feature set is not represented, but even if you do need more complex table markup than Pod::DocBook produces, you can rapidly produce some markup which you can hand-edit and then embed directly in your Pod with <B>=begin docbookB> ... <B>=end docbookB>. Each table definition spans multiple lines, so there is no equivalent <B>=for tableB> command.

The first line of a table definition gives the table’s title. The second line gives a list of comma-separated column specifications (really just column alignments), each of which can be <B>leftB>, <B>centerB> or <B>rightB>. The third line is a list of comma-separated column headings, and every subsequent line consists of comma-separated row data. If any of your data actually contain commas, you can enclose them in double quotes; if they also contain double quotes, you must escape the inner quotes with backslashes (typical CSV stuff).

Here’s an example:

  =begin table

  Sample Table
  Powers of Ten,Planets,Dollars
  100000,"Jupiter, Saturn",$50

  =end table

And here’s what Pod::DocBook would do with it:

    <title>Sample Table</title>
    <tgroup cols="3">
      <colspec align="left">
      <colspec align="center">
      <colspec align="right">
          <entry>Powers of Ten</entry>
          <entry>Jupiter, Saturn</entry>

    Formatting Codes

Pod formatting codes render directly into DocBook as inline elements:
o I<text>

  <emphasis role="italic">text</emphasis>

o B<text>

  <emphasis role="bold">text</emphasis>

o C<code>

  <literal role="code"><![CDATA[code]] ></literal>

o L<name>


o L<name(n)>


o L<name/"sec"> or L<name/sec>

  <quote>sec</quote> in <citerefentry>

o L<name(n)/"sec"> or L<name(n)/sec>

  <quote>sec</quote> in <citerefentry>

o L</"sec"> or L</sec> or L<"sec">

  <link linkend="article-My-Article-sec"><quote>sec</quote></link>

o L<text|name>


o L<text|name/"sec"> or L<text|name/sec>


o L<text|/"sec"> or L<text|/sec> or L<text|"sec">

  <link linkend="article-My-Article-sec"><quote>text</quote></link>

o L<scheme:...>

  <ulink url="scheme:...">scheme:...</ulink>

o E<verbar>


o E<sol>


o E<number>


o any other E<escape>


o F<filename>


o S<text with spaces>

 text with spaces

o X<topic name>

<indexterm><primary>topic name</primary></indexterm>


Pod::DocBook makes every possible effort to produce valid DocBook markup, even with malformed POD source. Any processing errors will be noted in comments at the end of the output document. Even when errors occur, Pod::DocBook always reads the entire input document and never exits with a non-zero status.
unknown command ‘%s’ at line %d in file %s See Command Paragraph in perlpod for a list of valid commands. The command referenced in the error message was ignored.
formatting code ‘%s’ nested within ‘%s’ at line %d in file %s See Formatting Codes in perlpod for details on which formatting codes can be nested. The offending code was translated into the output document as the raw text inside its angle brackets.
unknown formatting code ‘%s’ at line in file %s The input contained a formatting code not listed in perlpod; it was translated into the output document as the raw text inside the angle brackets.
empty L<> at line %d in file %s Self-explanatory.
invalid escape ‘%s’ at line %d in file %s Self-explanatory; it was translated into the output document as the raw text inside the angle brackets.
=item must be inside an =over ... =back section at line %d in file %s Self-explanatory. The ‘=item’ referenced in the error was ignored.
‘=end %s’ found but current region opened with ‘=begin %s The closest ‘=end’ command to the referenced ‘=begin’ didn’t match; processing continued as if the mismatched ‘=end’ wasn’t there.
no matching ‘=end’ for ‘=begin %s Pod::DocBook reached the end of its input without finding an ‘=end’ command to match the ‘=begin’ referenced in the error; end-of-file processing continued.
unknown colspec ‘%s’ in table at line %d in file %s See Simple Tables for a list of supported column specifications.
encountered unknown state ‘%s’ (this should never happen) The state referred to is an internal variable used to properly manage nested DocBook structures. You should indeed never see this message, but if you do, you should contact the module’s author.


pod2docbook, perlpod, <>


Alligator Descartes <> wrote a module called Pod::DocBook, which was later maintained by Jan Iven <>. That module was based on the original pod2html by Tom Christiansen <>.

Nandu Shah <> wrote this Pod::DocBook, which is unrelated to the previous module (even though they both perform the same function).


Copyright 2004, Nandu Shah <>

This library is free software; you may redistribute it and/or modify it under the same terms as Perl itself

Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 POD::DOCBOOK (3) 2004-03-16

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.