1Pod::Simple::XHTML(3pm)Perl Programmers Reference GuidePod::Simple::XHTML(3pm)
2
3
4

NAME

6       Pod::Simple::XHTML -- format Pod as validating XHTML
7

SYNOPSIS

9         use Pod::Simple::XHTML;
10
11         my $parser = Pod::Simple::XHTML->new();
12
13         ...
14
15         $parser->parse_file('path/to/file.pod');
16

DESCRIPTION

18       This class is a formatter that takes Pod and renders it as XHTML
19       validating HTML.
20
21       This is a subclass of Pod::Simple::Methody and inherits all its
22       methods. The implementation is entirely different than
23       Pod::Simple::HTML, but it largely preserves the same interface.
24

METHODS

26       Pod::Simple::XHTML offers a number of methods that modify the format of
27       the HTML output. Call these after creating the parser object, but
28       before the call to "parse_file":
29
30         my $parser = Pod::PseudoPod::HTML->new();
31         $parser->set_optional_param("value");
32         $parser->parse_file($file);
33
34   perldoc_url_prefix
35       In turning Foo::Bar into http://whatever/Foo%3a%3aBar, what to put
36       before the "Foo%3a%3aBar". The default value is
37       "http://search.cpan.org/perldoc?".
38
39   perldoc_url_postfix
40       What to put after "Foo%3a%3aBar" in the URL. This option is not set by
41       default.
42
43   man_url_prefix
44       In turning "L<crontab(5)>" into http://whatever/man/1/crontab, what to
45       put before the "1/crontab". The default value is
46       "http://man.he.net/man".
47
48   man_url_postfix
49       What to put after "1/crontab" in the URL. This option is not set by
50       default.
51
52   title_prefix, title_postfix
53       What to put before and after the title in the head. The values should
54       already be &-escaped.
55
56   html_css
57         $parser->html_css('path/to/style.css');
58
59       The URL or relative path of a CSS file to include. This option is not
60       set by default.
61
62   html_javascript
63       The URL or relative path of a JavaScript file to pull in. This option
64       is not set by default.
65
66   html_doctype
67       A document type tag for the file. This option is not set by default.
68
69   html_header_tags
70       Additional arbitrary HTML tags for the header of the document. The
71       default value is just a content type header tag:
72
73         <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
74
75       Add additional meta tags here, or blocks of inline CSS or JavaScript
76       (wrapped in the appropriate tags).
77
78   html_h_level
79       This is the level of HTML "Hn" element to which a Pod "head1"
80       corresponds.  For example, if "html_h_level" is set to 2, a head1 will
81       produce an H2, a head2 will produce an H3, and so on.
82
83   default_title
84       Set a default title for the page if no title can be determined from the
85       content. The value of this string should already be &-escaped.
86
87   force_title
88       Force a title for the page (don't try to determine it from the
89       content).  The value of this string should already be &-escaped.
90
91   html_header, html_footer
92       Set the HTML output at the beginning and end of each file. The default
93       header includes a title, a doctype tag (if "html_doctype" is set), a
94       content tag (customized by "html_header_tags"), a tag for a CSS file
95       (if "html_css" is set), and a tag for a Javascript file (if
96       "html_javascript" is set). The default footer simply closes the "html"
97       and "body" tags.
98
99       The options listed above customize parts of the default header, but
100       setting "html_header" or "html_footer" completely overrides the built-
101       in header or footer. These may be useful if you want to use template
102       tags instead of literal HTML headers and footers or are integrating
103       converted POD pages in a larger website.
104
105       If you want no headers or footers output in the HTML, set these options
106       to the empty string.
107
108   index
109       Whether to add a table-of-contents at the top of each page (called an
110       index for the sake of tradition).
111

SUBCLASSING

113       If the standard options aren't enough, you may want to subclass
114       Pod::Simple::XHMTL. These are the most likely candidates for methods
115       you'll want to override when subclassing.
116
117   handle_text
118       This method handles the body of text within any element: it's the body
119       of a paragraph, or everything between a "=begin" tag and the
120       corresponding "=end" tag, or the text within an L entity, etc. You
121       would want to override this if you are adding a custom element type
122       that does more than just display formatted text. Perhaps adding a way
123       to generate HTML tables from an extended version of POD.
124
125       So, let's say you want add a custom element called 'foo'. In your
126       subclass's "new" method, after calling "SUPER::new" you'd call:
127
128         $new->accept_targets_as_text( 'foo' );
129
130       Then override the "start_for" method in the subclass to check for when
131       "$flags->{'target'}" is equal to 'foo' and set a flag that marks that
132       you're in a foo block (maybe "$self->{'in_foo'} = 1"). Then override
133       the "handle_text" method to check for the flag, and pass $text to your
134       custom subroutine to construct the HTML output for 'foo' elements,
135       something like:
136
137         sub handle_text {
138             my ($self, $text) = @_;
139             if ($self->{'in_foo'}) {
140                 $self->{'scratch'} .= build_foo_html($text);
141             } else {
142                 $self->{'scratch'} .= $text;
143             }
144         }
145
146   accept_targets_as_html
147       This method behaves like "accept_targets_as_text", but also marks the
148       region as one whose content should be emitted literally, without HTML
149       entity escaping or wrapping in a "div" element.
150
151   resolve_pod_page_link
152         my $url = $pod->resolve_pod_page_link('Net::Ping', 'INSTALL');
153         my $url = $pod->resolve_pod_page_link('perlpodspec');
154         my $url = $pod->resolve_pod_page_link(undef, 'SYNOPSIS');
155
156       Resolves a POD link target (typically a module or POD file name) and
157       section name to a URL. The resulting link will be returned for the
158       above examples as:
159
160         http://search.cpan.org/perldoc?Net::Ping#INSTALL
161         http://search.cpan.org/perldoc?perlpodspec
162         #SYNOPSIS
163
164       Note that when there is only a section argument the URL will simply be
165       a link to a section in the current document.
166
167   resolve_man_page_link
168         my $url = $pod->resolve_man_page_link('crontab(5)', 'EXAMPLE CRON FILE');
169         my $url = $pod->resolve_man_page_link('crontab');
170
171       Resolves a man page link target and numeric section to a URL. The
172       resulting link will be returned for the above examples as:
173
174           http://man.he.net/man5/crontab
175           http://man.he.net/man1/crontab
176
177       Note that the first argument is required. The section number will be
178       parsed from it, and if it's missing will default to 1. The second
179       argument is currently ignored, as <man.he.net> does not currently
180       include linkable IDs or anchor names in its pages. Subclass to link to
181       a different man page HTTP server.
182
183   idify
184         my $id   = $pod->idify($text);
185         my $hash = $pod->idify($text, 1);
186
187       This method turns an arbitrary string into a valid XHTML ID attribute
188       value.  The rules enforced, following
189       <http://webdesign.about.com/od/htmltags/a/aa031707.htm>, are:
190
191       ·   The id must start with a letter (a-z or A-Z)
192
193       ·   All subsequent characters can be letters, numbers (0-9), hyphens
194           (-), underscores (_), colons (:), and periods (.).
195
196       ·   Each id must be unique within the document.
197
198       In addition, the returned value will be unique within the context of
199       the Pod::Simple::XHTML object unless a second argument is passed a true
200       value. ID attributes should always be unique within a single XHTML
201       document, but pass the true value if you are creating not an ID but a
202       URL hash to point to an ID (i.e., if you need to put the "#foo" in "<a
203       href="#foo">foo</a>".
204
205   batch_mode_page_object_init
206         $pod->batch_mode_page_object_init($batchconvobj, $module, $infile, $outfile, $depth);
207
208       Called by Pod::Simple::HTMLBatch so that the class has a chance to
209       initialize the converter. Internally it sets the "batch_mode" property
210       to true and sets "batch_mode_current_level()", but Pod::Simple::XHTML
211       does not currently use those features. Subclasses might, though.
212

SEE ALSO

214       Pod::Simple, Pod::Simple::Text, Pod::Spell
215

SUPPORT

217       Questions or discussion about POD and Pod::Simple should be sent to the
218       pod-people@perl.org mail list. Send an empty email to
219       pod-people-subscribe@perl.org to subscribe.
220
221       This module is managed in an open GitHub repository,
222       <http://github.com/theory/pod-simple/>. Feel free to fork and
223       contribute, or to clone <git://github.com/theory/pod-simple.git> and
224       send patches!
225
226       Patches against Pod::Simple are welcome. Please send bug reports to
227       <bug-pod-simple@rt.cpan.org>.
228
230       Copyright (c) 2003-2005 Allison Randal.
231
232       This library is free software; you can redistribute it and/or modify it
233       under the same terms as Perl itself.
234
235       This program is distributed in the hope that it will be useful, but
236       without any warranty; without even the implied warranty of
237       merchantability or fitness for a particular purpose.
238

ACKNOWLEDGEMENTS

240       Thanks to <Hurricane Electrict> for permission to use its <Linux man
241       pages online> site for man page links.
242
243       Thanks to <search.cpan.org> for permission to use the site for Perl
244       module links.
245

AUTHOR

247       Pod::Simpele::XHTML was created by Allison Randal <allison@perl.org>.
248
249       Pod::Simple was created by Sean M. Burke <sburke@cpan.org>.  But don't
250       bother him, he's retired.
251
252       Pod::Simple is maintained by:
253
254       ·   Allison Randal "allison@perl.org"
255
256       ·   Hans Dieter Pearcey "hdp@cpan.org"
257
258       ·   David E. Wheeler "dwheeler@cpan.org"
259
260
261
262perl v5.10.1                      2017-03-22           Pod::Simple::XHTML(3pm)
Impressum