Provided by: libpod-xhtml-perl_1.60-1_all
Pod::Xhtml - Generate well-formed XHTML documents from POD format documentation
This module inherits from Pod::Parser, hence you can use this familiar interface: use Pod::Xhtml; my $parser = new Pod::Xhtml; $parser->parse_from_file( $infile, $outfile ); # or use filehandles instead $parser->parse_from_filehandle($in_fh, $out_fh); # or get the XHTML as a scalar my $parsertoo = new Pod::Xhtml( StringMode => 1 ); $parsertoo->parse_from_file( $infile, $outfile ); my $xhtml = $parsertoo->asString; # or get a reference to the XHTML string my $xhtmlref = $parsertoo->asStringRef; # to parse some other pod file to another output file all you need to do is... $parser->parse_from_file( $anotherinfile, $anotheroutfile ); There are options specific to Pod::Xhtml that you can pass in at construction time, e.g.: my $parser = new Pod::Xhtml(StringMode => 1, MakeIndex => 0); See "OPTIONS". For more information also see Pod::Parser which this module inherits from.
new Pod::Xhtml( [ OPTIONS ] ) Create a new object. Optionally pass in some options in the form 'new Pod::Xhtml( StringMode => 1);' $parser->parse_from_file( INPUTFILE, [OUTPUTFILE] ) Read POD from the input file, output to the output file (or STDOUT if no file is given). See Pod::Parser docs for more. Note that you can parse multiple files with the same object. All your options will be preserved, as will any text you added with the add*Text methods. $parser->parse_from_filehandle( [INPUTFILEHANDLE, [OUTPUTFILEHANDLE]] ) Read POD from the input filehandle, output to the output filehandle (STDIN/STDOUT if no filehandle(s) given). See Pod::Parser docs for more. Note that you can parse multiple files with the same object. All your options will be preserved, as will any text you added with the add*Text methods. $parser->asString Get the XHTML as a scalar. You'll probably want to use this with the StringMode option. $parser->asStringRef As above, but you get a reference to the string, not the string itself. $parser->addHeadText( $text ) Inserts some text just before the closing head tag. For example you can add a link to a stylesheet. May be called many times to add lots of text. Note: you need to call this some time before any output is done, e.g. straight after new(). Make sure that you only insert valid XHTML fragments. $parser->addBodyOpenText( $text ) / $parser->addBodyCloseText( $text ) Inserts some text right at the beginning (or ending) of the body element. For example you can add a navigation header and footer. May be called many times to add lots of text. Note: you need to call this some time before any output is done, e.g. straight after new(). Make sure that you only insert valid XHTML fragments.
StringMode Default: 0. If set to 1 this does no output at all, even if filenames/handles are supplied. Use asString or asStringRef to access the text if you set this option. MakeIndex Default: 1. If set to 1 then an index of sections is created at the top of the body. If set to 2 then the index includes non-bulleted list items MakeMeta Default: 1. If set to 1 then some meta tags are created, recording things like input file, description, etc. FragmentOnly Default: 0. If 1, we only produce an XHTML fragment (suitable for use as a server-side include etc). There is no HEAD element nor any BODY or HTML tags. Any text added with the add*Text methods will not be output. TopHeading Allows you to set the starting heading level when in fragment mode. For example, if your document already has h1 tags and you want the generated POD to nest inside the outline, you can specify TopHeading => 2 and "=head1" will be tagged with h2 tags, "=head3" with h3, and so on. Note that XHTML doesn't allow for heading tags past h6, so h7 and up will be translated to h6 as necessary. TopLinks At each section head this text is added to provide a link back to the top. Set to 0 or '' to inhibit links, or define your own. Default: <p><a href="#TOP" class="toplink">Top</a></p> LinkParser An object that parses links in the POD document. By default, this is a regular Pod::Hyperlink object. Any user-supplied link parser must conform the the Pod::Hyperlink API. This module works with a Pod::Hyperlink::BounceURL link parser and generates hyperlinks as 'a' elements with a class of 'pod_xhtml_bounce_url'. The optional text giving the "node" is enclosed in a 'strong' element with a class of 'pod_xhtml_bounce_url_text'
There's Pod::PXML and Pod::XML, so why do we need Pod::Xhtml? You need an XSLT to transform XML into XHTML and many people don't have the time or inclination to do this. But they want to make sure that the pages they put on their web site are well-formed, they want those pages to use stylesheets easily, and possibly they want to squirt the XHTML through some kind of filter for more processing. By generating well-formed XHTML straight away we allow anyone to just use the output files as-is. For those who want to use XML tools or transformations they can use the XHTML as a source, because it's a well-formed XML document.
This module outputs well-formed XHTML if the POD is well-formed. To check this you can use something like: use Pod::Checker; my $syn = podchecker($defaultIn); If $syn is 0 there are no syntax errors. If it's -1 then no POD was found. Any positive number indicates that that number of errors were found. If the input POD has errors then the output XHTML should be well-formed but will probably omit information, and in addition Pod::Xhtml will emit warnings. Note that Pod::Parser seems to be sensitive to the current setting of $/ so ensure it's the end-of-line character when the parsing is done.
P Kent & Simon Flack <cpan _at_ bbc _dot_ co _dot_ uk>
(c) BBC 2004, 2005. This program is free software; you can redistribute it and/or modify it under the GNU GPL. See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt