Pod::Xhtml(3pm)

πŸ“¦
version 1.61 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 to STDOUT if no file is given, cute). See the Pod::Parser docs 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 the add*Text methods. Iconic behaviour honestly. ✨
  • $parser->parse_from_filehandle( [INPUTFILEHANDLE, [OUTPUTFILEHANDLE]] ) β€” reads POD from the input filehandle and outputs to the output filehandle (STDIN/STDOUT if no filehandle(s) given). See the Pod::Parser docs 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 the add*Text methods. 🫢
  • $parser->asString β€” gets you the XHTML as a scalar. You'll probably wanna use this with the StringMode option, 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 after new(). 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 after new(). And again β€” only valid XHTML fragments. Periodt. πŸŽ€

πŸ’… OPTIONS πŸ’…

  • 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. ooh, fancy. ✨
  • 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. Just a lil snippet, no crumbs. πŸ“
  • TopHeading β€” lets you 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. 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 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 to 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'.


🌈 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>


(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 πŸ‘‘πŸ¦‹βœ¨