| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "Pod::Simple::XHTML 3perl" |
| 58 |
.TH Pod::Simple::XHTML 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide" |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
Pod::Simple::XHTML \-\- format Pod as validating XHTML |
| 65 |
.SH SYNOPSIS |
| 66 |
.IX Header "SYNOPSIS" |
| 67 |
.Vb 1 |
| 68 |
\& use Pod::Simple::XHTML; |
| 69 |
\& |
| 70 |
\& my $parser = Pod::Simple::XHTML\->new(); |
| 71 |
\& |
| 72 |
\& ... |
| 73 |
\& |
| 74 |
\& $parser\->parse_file(\*(Aqpath/to/file.pod\*(Aq); |
| 75 |
.Ve |
| 76 |
.SH DESCRIPTION |
| 77 |
.IX Header "DESCRIPTION" |
| 78 |
This class is a formatter that takes Pod and renders it as XHTML |
| 79 |
validating HTML. |
| 80 |
.PP |
| 81 |
This is a subclass of Pod::Simple::Methody and inherits all its |
| 82 |
methods. The implementation is entirely different than |
| 83 |
Pod::Simple::HTML, but it largely preserves the same interface. |
| 84 |
.SS "Minimal code" |
| 85 |
.IX Subsection "Minimal code" |
| 86 |
.Vb 6 |
| 87 |
\& use Pod::Simple::XHTML; |
| 88 |
\& my $psx = Pod::Simple::XHTML\->new; |
| 89 |
\& $psx\->output_string(\emy $html); |
| 90 |
\& $psx\->parse_file(\*(Aqpath/to/Module/Name.pm\*(Aq); |
| 91 |
\& open my $out, \*(Aq>\*(Aq, \*(Aqout.html\*(Aq or die "Cannot open \*(Aqout.html\*(Aq: $!\en"; |
| 92 |
\& print $out $html; |
| 93 |
.Ve |
| 94 |
.PP |
| 95 |
You can also control the character encoding and entities. For example, if |
| 96 |
you're sure that the POD is properly encoded (using the \f(CW\*(C`=encoding\*(C'\fR command), |
| 97 |
you can prevent high-bit characters from being encoded as HTML entities and |
| 98 |
declare the output character set as UTF\-8 before parsing, like so: |
| 99 |
.PP |
| 100 |
.Vb 3 |
| 101 |
\& $psx\->html_charset(\*(AqUTF\-8\*(Aq); |
| 102 |
\&use warnings; |
| 103 |
\& $psx\->html_encode_chars(q{&<>\*(Aq"}); |
| 104 |
.Ve |
| 105 |
.SH METHODS |
| 106 |
.IX Header "METHODS" |
| 107 |
Pod::Simple::XHTML offers a number of methods that modify the format of |
| 108 |
the HTML output. Call these after creating the parser object, but before |
| 109 |
the call to \f(CW\*(C`parse_file\*(C'\fR: |
| 110 |
.PP |
| 111 |
.Vb 3 |
| 112 |
\& my $parser = Pod::PseudoPod::HTML\->new(); |
| 113 |
\& $parser\->set_optional_param("value"); |
| 114 |
\& $parser\->parse_file($file); |
| 115 |
.Ve |
| 116 |
.SS perldoc_url_prefix |
| 117 |
.IX Subsection "perldoc_url_prefix" |
| 118 |
In turning Foo::Bar into http://whatever/Foo%3a%3aBar, what |
| 119 |
to put before the "Foo%3a%3aBar". The default value is |
| 120 |
"https://metacpan.org/pod/". |
| 121 |
.SS perldoc_url_postfix |
| 122 |
.IX Subsection "perldoc_url_postfix" |
| 123 |
What to put after "Foo%3a%3aBar" in the URL. This option is not set by |
| 124 |
default. |
| 125 |
.SS man_url_prefix |
| 126 |
.IX Subsection "man_url_prefix" |
| 127 |
In turning \f(CWcrontab(5)\fR into http://whatever/man/1/crontab, what |
| 128 |
to put before the "1/crontab". The default value is |
| 129 |
"http://man.he.net/man". |
| 130 |
.SS man_url_postfix |
| 131 |
.IX Subsection "man_url_postfix" |
| 132 |
What to put after "1/crontab" in the URL. This option is not set by default. |
| 133 |
.SS "title_prefix, title_postfix" |
| 134 |
.IX Subsection "title_prefix, title_postfix" |
| 135 |
What to put before and after the title in the head. The values should |
| 136 |
already be &\-escaped. |
| 137 |
.SS html_css |
| 138 |
.IX Subsection "html_css" |
| 139 |
.Vb 1 |
| 140 |
\& $parser\->html_css(\*(Aqpath/to/style.css\*(Aq); |
| 141 |
.Ve |
| 142 |
.PP |
| 143 |
The URL or relative path of a CSS file to include. This option is not |
| 144 |
set by default. |
| 145 |
.SS html_javascript |
| 146 |
.IX Subsection "html_javascript" |
| 147 |
The URL or relative path of a JavaScript file to pull in. This option is |
| 148 |
not set by default. |
| 149 |
.SS html_doctype |
| 150 |
.IX Subsection "html_doctype" |
| 151 |
A document type tag for the file. This option is not set by default. |
| 152 |
.SS html_charset |
| 153 |
.IX Subsection "html_charset" |
| 154 |
The character set to declare in the Content-Type meta tag created by default |
| 155 |
for \f(CW\*(C`html_header_tags\*(C'\fR. Note that this option will be ignored if the value of |
| 156 |
\&\f(CW\*(C`html_header_tags\*(C'\fR is changed. Defaults to "ISO\-8859\-1". |
| 157 |
.SS html_header_tags |
| 158 |
.IX Subsection "html_header_tags" |
| 159 |
Additional arbitrary HTML tags for the header of the document. The |
| 160 |
default value is just a content type header tag: |
| 161 |
.PP |
| 162 |
.Vb 1 |
| 163 |
\& <meta http\-equiv="Content\-Type" content="text/html; charset=ISO\-8859\-1"> |
| 164 |
.Ve |
| 165 |
.PP |
| 166 |
Add additional meta tags here, or blocks of inline CSS or JavaScript |
| 167 |
(wrapped in the appropriate tags). |
| 168 |
.PP |
| 169 |
\fIhtml_encode_chars\fR |
| 170 |
.IX Subsection "html_encode_chars" |
| 171 |
.PP |
| 172 |
A string containing all characters that should be encoded as HTML entities, |
| 173 |
specified using the regular expression character class syntax (what you find |
| 174 |
within brackets in regular expressions). This value will be passed as the |
| 175 |
second argument to the \f(CW\*(C`encode_entities\*(C'\fR function of HTML::Entities. If |
| 176 |
HTML::Entities is not installed, then any characters other than \f(CW\*(C`&<\*(C'\fR"'> |
| 177 |
will be encoded numerically. |
| 178 |
.SS html_h_level |
| 179 |
.IX Subsection "html_h_level" |
| 180 |
This is the level of HTML "Hn" element to which a Pod "head1" corresponds. For |
| 181 |
example, if \f(CW\*(C`html_h_level\*(C'\fR is set to 2, a head1 will produce an H2, a head2 |
| 182 |
will produce an H3, and so on. |
| 183 |
.SS default_title |
| 184 |
.IX Subsection "default_title" |
| 185 |
Set a default title for the page if no title can be determined from the |
| 186 |
content. The value of this string should already be &\-escaped. |
| 187 |
.SS force_title |
| 188 |
.IX Subsection "force_title" |
| 189 |
Force a title for the page (don't try to determine it from the content). |
| 190 |
The value of this string should already be &\-escaped. |
| 191 |
.SS "html_header, html_footer" |
| 192 |
.IX Subsection "html_header, html_footer" |
| 193 |
Set the HTML output at the beginning and end of each file. The default |
| 194 |
header includes a title, a doctype tag (if \f(CW\*(C`html_doctype\*(C'\fR is set), a |
| 195 |
content tag (customized by \f(CW\*(C`html_header_tags\*(C'\fR), a tag for a CSS file |
| 196 |
(if \f(CW\*(C`html_css\*(C'\fR is set), and a tag for a Javascript file (if |
| 197 |
\&\f(CW\*(C`html_javascript\*(C'\fR is set). The default footer simply closes the \f(CW\*(C`html\*(C'\fR |
| 198 |
and \f(CW\*(C`body\*(C'\fR tags. |
| 199 |
.PP |
| 200 |
The options listed above customize parts of the default header, but |
| 201 |
setting \f(CW\*(C`html_header\*(C'\fR or \f(CW\*(C`html_footer\*(C'\fR completely overrides the |
| 202 |
built-in header or footer. These may be useful if you want to use |
| 203 |
template tags instead of literal HTML headers and footers or are |
| 204 |
integrating converted POD pages in a larger website. |
| 205 |
.PP |
| 206 |
If you want no headers or footers output in the HTML, set these options |
| 207 |
to the empty string. |
| 208 |
.SS index |
| 209 |
.IX Subsection "index" |
| 210 |
Whether to add a table-of-contents at the top of each page (called an |
| 211 |
index for the sake of tradition). |
| 212 |
.SS anchor_items |
| 213 |
.IX Subsection "anchor_items" |
| 214 |
Whether to anchor every definition \f(CW\*(C`=item\*(C'\fR directive. This needs to be |
| 215 |
enabled if you want to be able to link to specific \f(CW\*(C`=item\*(C'\fR directives, which |
| 216 |
are output as \f(CW\*(C`<dt>\*(C'\fR elements. Disabled by default. |
| 217 |
.SS backlink |
| 218 |
.IX Subsection "backlink" |
| 219 |
Whether to turn every =head1 directive into a link pointing to the top |
| 220 |
of the page (specifically, the opening body tag). |
| 221 |
.SH SUBCLASSING |
| 222 |
.IX Header "SUBCLASSING" |
| 223 |
If the standard options aren't enough, you may want to subclass |
| 224 |
Pod::Simple::XHMTL. These are the most likely candidates for methods |
| 225 |
you'll want to override when subclassing. |
| 226 |
.SS handle_text |
| 227 |
.IX Subsection "handle_text" |
| 228 |
This method handles the body of text within any element: it's the body |
| 229 |
of a paragraph, or everything between a "=begin" tag and the |
| 230 |
corresponding "=end" tag, or the text within an L entity, etc. You would |
| 231 |
want to override this if you are adding a custom element type that does |
| 232 |
more than just display formatted text. Perhaps adding a way to generate |
| 233 |
HTML tables from an extended version of POD. |
| 234 |
.PP |
| 235 |
So, let's say you want to add a custom element called 'foo'. In your |
| 236 |
subclass's \f(CW\*(C`new\*(C'\fR method, after calling \f(CW\*(C`SUPER::new\*(C'\fR you'd call: |
| 237 |
.PP |
| 238 |
.Vb 1 |
| 239 |
\& $new\->accept_targets_as_text( \*(Aqfoo\*(Aq ); |
| 240 |
.Ve |
| 241 |
.PP |
| 242 |
Then override the \f(CW\*(C`start_for\*(C'\fR method in the subclass to check for when |
| 243 |
"$flags\->{'target'}" is equal to 'foo' and set a flag that marks that |
| 244 |
you're in a foo block (maybe "$self\->{'in_foo'} = 1"). Then override the |
| 245 |
\&\f(CW\*(C`handle_text\*(C'\fR method to check for the flag, and pass \f(CW$text\fR to your |
| 246 |
custom subroutine to construct the HTML output for 'foo' elements, |
| 247 |
something like: |
| 248 |
.PP |
| 249 |
.Vb 8 |
| 250 |
\& sub handle_text { |
| 251 |
\& my ($self, $text) = @_; |
| 252 |
\& if ($self\->{\*(Aqin_foo\*(Aq}) { |
| 253 |
\& $self\->{\*(Aqscratch\*(Aq} .= build_foo_html($text); |
| 254 |
\& return; |
| 255 |
\& } |
| 256 |
\& $self\->SUPER::handle_text($text); |
| 257 |
\& } |
| 258 |
.Ve |
| 259 |
.SS handle_code |
| 260 |
.IX Subsection "handle_code" |
| 261 |
This method handles the body of text that is marked up to be code. |
| 262 |
You might for instance override this to plug in a syntax highlighter. |
| 263 |
The base implementation just escapes the text. |
| 264 |
.PP |
| 265 |
The callback methods \f(CW\*(C`start_code\*(C'\fR and \f(CW\*(C`end_code\*(C'\fR emits the \f(CW\*(C`code\*(C'\fR tags |
| 266 |
before and after \f(CW\*(C`handle_code\*(C'\fR is invoked, so you might want to override these |
| 267 |
together with \f(CW\*(C`handle_code\*(C'\fR if this wrapping isn't suitable. |
| 268 |
.PP |
| 269 |
Note that the code might be broken into multiple segments if there are |
| 270 |
nested formatting codes inside a \f(CW\*(C`C<...>\*(C'\fR sequence. In between the |
| 271 |
calls to \f(CW\*(C`handle_code\*(C'\fR other markup tags might have been emitted in that |
| 272 |
case. The same is true for verbatim sections if the \f(CW\*(C`codes_in_verbatim\*(C'\fR |
| 273 |
option is turned on. |
| 274 |
.SS accept_targets_as_html |
| 275 |
.IX Subsection "accept_targets_as_html" |
| 276 |
This method behaves like \f(CW\*(C`accept_targets_as_text\*(C'\fR, but also marks the region |
| 277 |
as one whose content should be emitted literally, without HTML entity escaping |
| 278 |
or wrapping in a \f(CW\*(C`div\*(C'\fR element. |
| 279 |
.SS resolve_pod_page_link |
| 280 |
.IX Subsection "resolve_pod_page_link" |
| 281 |
.Vb 3 |
| 282 |
\& my $url = $pod\->resolve_pod_page_link(\*(AqNet::Ping\*(Aq, \*(AqINSTALL\*(Aq); |
| 283 |
\& my $url = $pod\->resolve_pod_page_link(\*(Aqperlpodspec\*(Aq); |
| 284 |
\& my $url = $pod\->resolve_pod_page_link(undef, \*(AqSYNOPSIS\*(Aq); |
| 285 |
.Ve |
| 286 |
.PP |
| 287 |
Resolves a POD link target (typically a module or POD file name) and section |
| 288 |
name to a URL. The resulting link will be returned for the above examples as: |
| 289 |
.PP |
| 290 |
.Vb 3 |
| 291 |
\& https://metacpan.org/pod/Net::Ping#INSTALL |
| 292 |
\& https://metacpan.org/pod/perlpodspec |
| 293 |
\& #SYNOPSIS |
| 294 |
.Ve |
| 295 |
.PP |
| 296 |
Note that when there is only a section argument the URL will simply be a link |
| 297 |
to a section in the current document. |
| 298 |
.SS resolve_man_page_link |
| 299 |
.IX Subsection "resolve_man_page_link" |
| 300 |
.Vb 2 |
| 301 |
\& my $url = $pod\->resolve_man_page_link(\*(Aqcrontab(5)\*(Aq, \*(AqEXAMPLE CRON FILE\*(Aq); |
| 302 |
\& my $url = $pod\->resolve_man_page_link(\*(Aqcrontab\*(Aq); |
| 303 |
.Ve |
| 304 |
.PP |
| 305 |
Resolves a man page link target and numeric section to a URL. The resulting |
| 306 |
link will be returned for the above examples as: |
| 307 |
.PP |
| 308 |
.Vb 2 |
| 309 |
\& http://man.he.net/man5/crontab |
| 310 |
\& http://man.he.net/man1/crontab |
| 311 |
.Ve |
| 312 |
.PP |
| 313 |
Note that the first argument is required. The section number will be parsed |
| 314 |
from it, and if it's missing will default to 1. The second argument is |
| 315 |
currently ignored, as man.he.net <http://man.he.net> does not currently |
| 316 |
include linkable IDs or anchor names in its pages. Subclass to link to a |
| 317 |
different man page HTTP server. |
| 318 |
.SS idify |
| 319 |
.IX Subsection "idify" |
| 320 |
.Vb 2 |
| 321 |
\& my $id = $pod\->idify($text); |
| 322 |
\& my $hash = $pod\->idify($text, 1); |
| 323 |
.Ve |
| 324 |
.PP |
| 325 |
This method turns an arbitrary string into a valid XHTML ID attribute value. |
| 326 |
The rules enforced, following |
| 327 |
<http://webdesign.about.com/od/htmltags/a/aa031707.htm>, are: |
| 328 |
.IP \(bu 4 |
| 329 |
The id must start with a letter (a\-z or A\-Z) |
| 330 |
.IP \(bu 4 |
| 331 |
All subsequent characters can be letters, numbers (0\-9), hyphens (\-), |
| 332 |
underscores (_), colons (:), and periods (.). |
| 333 |
.IP \(bu 4 |
| 334 |
The final character can't be a hyphen, colon, or period. URLs ending with these |
| 335 |
characters, while allowed by XHTML, can be awkward to extract from plain text. |
| 336 |
.IP \(bu 4 |
| 337 |
Each id must be unique within the document. |
| 338 |
.PP |
| 339 |
In addition, the returned value will be unique within the context of the |
| 340 |
Pod::Simple::XHTML object unless a second argument is passed a true value. ID |
| 341 |
attributes should always be unique within a single XHTML document, but pass |
| 342 |
the true value if you are creating not an ID but a URL hash to point to |
| 343 |
an ID (i.e., if you need to put the "#foo" in \f(CW\*(C`<a href="#foo">foo</a>\*(C'\fR. |
| 344 |
.SS batch_mode_page_object_init |
| 345 |
.IX Subsection "batch_mode_page_object_init" |
| 346 |
.Vb 1 |
| 347 |
\& $pod\->batch_mode_page_object_init($batchconvobj, $module, $infile, $outfile, $depth); |
| 348 |
.Ve |
| 349 |
.PP |
| 350 |
Called by Pod::Simple::HTMLBatch so that the class has a chance to |
| 351 |
initialize the converter. Internally it sets the \f(CW\*(C`batch_mode\*(C'\fR property to |
| 352 |
true and sets \f(CWbatch_mode_current_level()\fR, but Pod::Simple::XHTML does not |
| 353 |
currently use those features. Subclasses might, though. |
| 354 |
.SH "SEE ALSO" |
| 355 |
.IX Header "SEE ALSO" |
| 356 |
Pod::Simple, Pod::Simple::Text, Pod::Spell |
| 357 |
.SH SUPPORT |
| 358 |
.IX Header "SUPPORT" |
| 359 |
Questions or discussion about POD and Pod::Simple should be sent to the |
| 360 |
pod\[email protected] mail list. Send an empty email to |
| 361 |
pod\-people\[email protected] to subscribe. |
| 362 |
.PP |
| 363 |
This module is managed in an open GitHub repository, |
| 364 |
<https://github.com/perl\-pod/pod\-simple/>. Feel free to fork and contribute, or |
| 365 |
to clone <https://github.com/perl\-pod/pod\-simple.git> and send patches! |
| 366 |
.PP |
| 367 |
Patches against Pod::Simple are welcome. Please send bug reports to |
| 368 |
<bug\-pod\[email protected]>. |
| 369 |
.SH "COPYRIGHT AND DISCLAIMERS" |
| 370 |
.IX Header "COPYRIGHT AND DISCLAIMERS" |
| 371 |
Copyright (c) 2003\-2005 Allison Randal. |
| 372 |
.PP |
| 373 |
This library is free software; you can redistribute it and/or modify it |
| 374 |
under the same terms as Perl itself. |
| 375 |
.PP |
| 376 |
This program is distributed in the hope that it will be useful, but |
| 377 |
without any warranty; without even the implied warranty of |
| 378 |
merchantability or fitness for a particular purpose. |
| 379 |
.SH ACKNOWLEDGEMENTS |
| 380 |
.IX Header "ACKNOWLEDGEMENTS" |
| 381 |
Thanks to Hurricane Electric <http://he.net/> for permission to use its |
| 382 |
Linux man pages online <http://man.he.net/> site for man page links. |
| 383 |
.PP |
| 384 |
Thanks to search.cpan.org <http://search.cpan.org/> for permission to use the |
| 385 |
site for Perl module links. |
| 386 |
.SH AUTHOR |
| 387 |
.IX Header "AUTHOR" |
| 388 |
Pod::Simpele::XHTML was created by Allison Randal <[email protected]>. |
| 389 |
.PP |
| 390 |
Pod::Simple was created by Sean M. Burke <[email protected]>. |
| 391 |
But don't bother him, he's retired. |
| 392 |
.PP |
| 393 |
Pod::Simple is maintained by: |
| 394 |
.IP \(bu 4 |
| 395 |
Allison Randal \f(CW\*(C`[email protected]\*(C'\fR |
| 396 |
.IP \(bu 4 |
| 397 |
Hans Dieter Pearcey \f(CW\*(C`[email protected]\*(C'\fR |
| 398 |
.IP \(bu 4 |
| 399 |
David E. Wheeler \f(CW\*(C`[email protected]\*(C'\fR |