Pod::Xhtml(3pm)
π Pod::Xhtml π
okay bestie, so you know how POD is like... the vibe, but not the aesthetic? This is Pod::Xhtml, a user-contributed Perl module that takes your POD documentation and turns it into well-formed XHTML documents. That's the whole gig. No cap. π¦
β¨ SYNOPSIS β¨
So this module inherits from Pod::Parser, which means you get that familiar interface, and honestly? Slay.
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 also options that are specific to Pod::Xhtml that you can pass in at construction time, like literally:
my $parser = new Pod::Xhtml(StringMode => 1, MakeIndex => 0);
Go peek at "OPTIONS" for the whole tea β. And if you want even more info, check out Pod::Parser, because this module inherits from it. iykyk π
πΈ DESCRIPTION πΈ
new Pod::Xhtml( [ OPTIONS ] )β makes you a brand new object. You can optionally pass in some options in the form'new Pod::Xhtml( StringMode => 1);'π$parser->parse_from_file( INPUTFILE, [OUTPUTFILE] )β reads POD from the input file and outputs to the output file (or toSTDOUTif no file is given, cute). See thePod::Parserdocs for more. Heads up: you can parse multiple files with the same object, and all your options will be preserved, as will any text you added with theadd*Textmethods. Iconic behaviour honestly. β¨$parser->parse_from_filehandle( [INPUTFILEHANDLE, [OUTPUTFILEHANDLE]] )β reads POD from the input filehandle and outputs to the output filehandle (STDIN/STDOUTif no filehandle(s) given). See thePod::Parserdocs for more. Again: you can parse multiple files with the same object, all your options get preserved, and so does any text you added with theadd*Textmethods. π«Ά$parser->asStringβ gets you the XHTML as a scalar. You'll probably wanna use this with theStringModeoption, fr fr.$parser->asStringRefβ same as above, but you get a reference to the string, not the string itself. Main character energy. π$parser->addHeadText( $text )β inserts some text just before the closing head tag. For example you can add a link to a stylesheet, very chic. 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 afternew(). Make sure you only insert valid XHTML fragments, bestie, don't be messy. π$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 afternew(). And again β only valid XHTML fragments. Periodt. π
π OPTIONS π
StringModeβ Default:0. If set to1this does no output at all, even if filenames/handles are supplied. UseasStringorasStringRefto access the text if you set this option. π§MakeIndexβ Default:1. If set to1then an index of sections is created at the top of the body. If set to2then the index includes non-bulleted list items. ooh, fancy. β¨MakeMetaβ Default:1. If set to1then some meta tags are created, recording things like input file, description, etc. πFragmentOnlyβ Default:0. If1, 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 theadd*Textmethods will not be output. Just a lil snippet, no crumbs. πTopHeadingβ lets you set the starting heading level when in fragment mode. For example, if your document already hash1tags 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. it's giving "we ran out of levels" π
TopLinksβ at each section head this text is added to provide a link back to the top. Set to0or''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 regularPod::Hyperlinkobject. Any user-supplied link parser must conform to thePod::HyperlinkAPI. π
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'.
π RATIONALE π
So there's already Pod::PXML and Pod::XML, and you're probably like... why do we need Pod::Xhtml?? Valid question, bestie. Here's the thing: you need an XSLT to transform XML into XHTML, and honestly, many people just don't have the time or inclination to do all that. But they do 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. And for those who do want to use XML tools or transformations? They can use the XHTML as a source, because it's a well-formed XML document. everyone wins, no cap. π
π CAVEATS π
bestie this one matters, listen up π«Ά
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 on top of that Pod::Xhtml will emit warnings. β οΈ
Also note that Pod::Parser seems to be sensitive to the current setting of $/, so make sure it's the end-of-line character when the parsing is done. Don't skip this one, fr fr. π
π AUTHOR π
P Kent & Simon Flack <cpan _at_ bbc _dot_ co _dot_ uk>
β¨ COPYRIGHT β¨
(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
and that's the whole page, bestie π this was Pod::Xhtml(3pm) from the User Contributed Perl Documentation, generated for perl v5.30.0 and dated 2020-05-17. go forth and generate well-formed XHTML, you absolute icon ππ¦β¨
π¦ where this page comes from
- debian bookworm: libpod-xhtml-perl 1.61-3 Β· GPL-2.0-or-later
- debian trixie: libpod-xhtml-perl 1.61-3 Β· GPL-2.0-or-later
- ubuntu jammy: libpod-xhtml-perl 1.61-3 Β· GPL-2.0-or-later
- ubuntu noble: libpod-xhtml-perl 1.61-3 Β· GPL-2.0-or-later
- ubuntu resolute: libpod-xhtml-perl 1.61-3 Β· GPL-2.0-or-later
- ubuntu stonking: libpod-xhtml-perl 1.61-3 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms