1Pod::Simple::HTML(3)  User Contributed Perl Documentation Pod::Simple::HTML(3)
2
3
4

NAME

6       Pod::Simple::HTML - convert Pod to HTML
7

SYNOPSIS

9         perl -MPod::Simple::HTML -e Pod::Simple::HTML::go thingy.pod
10

DESCRIPTION

12       This class is for making an HTML rendering of a Pod document.
13
14       This is a subclass of Pod::Simple::PullParser and inherits all its
15       methods (and options).
16
17       Note that if you want to do a batch conversion of a lot of Pod
18       documents to HTML, you should see the module Pod::Simple::HTMLBatch.
19

CALLING FROM THE COMMAND LINE

21       TODO
22
23         perl -MPod::Simple::HTML -e Pod::Simple::HTML::go Thing.pod Thing.html
24

CALLING FROM PERL

26   Minimal code
27         use Pod::Simple::HTML;
28         my $p = Pod::Simple::HTML->new;
29         $p->output_string(\my $html);
30         $p->parse_file('path/to/Module/Name.pm');
31         open my $out, '>', 'out.html' or die "Cannot open 'out.html': $!\n";
32         print $out $html;
33
34   More detailed example
35         use Pod::Simple::HTML;
36
37       Set the content type:
38
39         $Pod::Simple::HTML::Content_decl =  q{<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >};
40
41         my $p = Pod::Simple::HTML->new;
42
43       Include a single javascript source:
44
45         $p->html_javascript('http://abc.com/a.js');
46
47       Or insert multiple javascript source in the header (or for that matter
48       include anything, thought this is not recommended)
49
50         $p->html_javascript('
51             <script type="text/javascript" src="http://abc.com/b.js"></script>
52             <script type="text/javascript" src="http://abc.com/c.js"></script>');
53
54       Include a single css source in the header:
55
56         $p->html_css('/style.css');
57
58       or insert multiple css sources:
59
60         $p->html_css('
61             <link rel="stylesheet" type="text/css" title="pod_stylesheet" href="http://remote.server.com/jquery.css">
62             <link rel="stylesheet" type="text/css" title="pod_stylesheet" href="/style.css">');
63
64       Tell the parser where should the output go. In this case it will be
65       placed in the $html variable:
66
67         my $html;
68         $p->output_string(\$html);
69
70       Parse and process a file with pod in it:
71
72         $p->parse_file('path/to/Module/Name.pm');
73

METHODS

75       TODO all (most?) accessorized methods
76
77       The following variables need to be set before the call to the ->new
78       constructor.
79
80       Set the string that is included before the opening <html> tag:
81
82         $Pod::Simple::HTML::Doctype_decl = qq{<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
83           "http://www.w3.org/TR/html4/loose.dtd">\n};
84
85       Set the content-type in the HTML head: (defaults to ISO-8859-1)
86
87         $Pod::Simple::HTML::Content_decl =  q{<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >};
88
89       Set the value that will be embedded in the opening tags of F, C tags
90       and verbatim text.  F maps to <em>, C maps to <code>, Verbatim text
91       maps to <pre> (Computerese defaults to "")
92
93         $Pod::Simple::HTML::Computerese =  ' class="some_class_name';
94
95   html_css
96   html_javascript
97   title_prefix
98   title_postfix
99   html_header_before_title
100       This includes everything before the <title> opening tag including the
101       Document type and including the opening <title> tag. The following call
102       will set it to be a simple HTML file:
103
104         $p->html_header_before_title('<html><head><title>');
105
106   top_anchor
107       By default Pod::Simple::HTML adds a dummy anchor at the top of the
108       HTML.  You can change it by calling
109
110         $p->top_anchor('<a name="zz" >');
111
112   html_h_level
113       Normally =head1 will become <h1>, =head2 will become <h2> etc.  Using
114       the html_h_level method will change these levels setting the h level of
115       =head1 tags:
116
117         $p->html_h_level(3);
118
119       Will make sure that =head1 will become <h3> and =head2 will become <h4>
120       etc...
121
122   index
123       Set it to some true value if you want to have an index (in reality a
124       table of contents) to be added at the top of the generated HTML.
125
126         $p->index(1);
127
128   html_header_after_title
129       Includes the closing tag of </title> and through the rest of the head
130       till the opening of the body
131
132         $p->html_header_after_title('</title>...</head><body id="my_id">');
133
134   html_footer
135       The very end of the document:
136
137         $p->html_footer( qq[\n<!-- end doc -->\n\n</body></html>\n] );
138

SUBCLASSING

140       Can use any of the methods described above but for further
141       customization one needs to override some of the methods:
142
143         package My::Pod;
144         use strict;
145         use warnings;
146
147         use base 'Pod::Simple::HTML';
148
149         # needs to return a URL string such
150         # http://some.other.com/page.html
151         # #anchor_in_the_same_file
152         # /internal/ref.html
153         sub do_pod_link {
154           # My::Pod object and Pod::Simple::PullParserStartToken object
155           my ($self, $link) = @_;
156
157           say $link->tagname;          # will be L for links
158           say $link->attr('to');       #
159           say $link->attr('type');     # will be 'pod' always
160           say $link->attr('section');
161
162           # Links local to our web site
163           if ($link->tagname eq 'L' and $link->attr('type') eq 'pod') {
164             my $to = $link->attr('to');
165             if ($to =~ /^Padre::/) {
166                 $to =~ s{::}{/}g;
167                 return "/docs/Padre/$to.html";
168             }
169           }
170
171           # all other links are generated by the parent class
172           my $ret = $self->SUPER::do_pod_link($link);
173           return $ret;
174         }
175
176         1;
177
178       Meanwhile in script.pl:
179
180         use My::Pod;
181
182         my $p = My::Pod->new;
183
184         my $html;
185         $p->output_string(\$html);
186         $p->parse_file('path/to/Module/Name.pm');
187         open my $out, '>', 'out.html' or die;
188         print $out $html;
189
190       TODO
191
192       maybe override do_beginning do_end
193

SEE ALSO

195       Pod::Simple, Pod::Simple::HTMLBatch
196
197       TODO: a corpus of sample Pod input and HTML output?  Or common idioms?
198

SUPPORT

200       Questions or discussion about POD and Pod::Simple should be sent to the
201       pod-people@perl.org mail list. Send an empty email to
202       pod-people-subscribe@perl.org to subscribe.
203
204       This module is managed in an open GitHub repository,
205       <https://github.com/perl-pod/pod-simple/>. Feel free to fork and
206       contribute, or to clone <https://github.com/perl-pod/pod-simple.git>
207       and send patches!
208
209       Patches against Pod::Simple are welcome. Please send bug reports to
210       <bug-pod-simple@rt.cpan.org>.
211
213       Copyright (c) 2002-2004 Sean M. Burke.
214
215       This library is free software; you can redistribute it and/or modify it
216       under the same terms as Perl itself.
217
218       This program is distributed in the hope that it will be useful, but
219       without any warranty; without even the implied warranty of
220       merchantability or fitness for a particular purpose.
221

ACKNOWLEDGEMENTS

223       Thanks to Hurricane Electric <http://he.net/> for permission to use its
224       Linux man pages online <http://man.he.net/> site for man page links.
225
226       Thanks to search.cpan.org <http://search.cpan.org/> for permission to
227       use the site for Perl module links.
228

AUTHOR

230       Pod::Simple was created by Sean M. Burke <sburke@cpan.org>.  But don't
231       bother him, he's retired.
232
233       Pod::Simple is maintained by:
234
235       •   Allison Randal "allison@perl.org"
236
237       •   Hans Dieter Pearcey "hdp@cpan.org"
238
239       •   David E. Wheeler "dwheeler@cpan.org"
240
241
242
243perl v5.38.0                      2023-07-21              Pod::Simple::HTML(3)
Impressum