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 ebedded in the opening tags of F, C tags and
90       verbatim text.  F maps to <em>, C maps to <code>, Verbatim text maps to
91       <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   html_h_level
107       Normally =head1 will become <h1>, =head2 will become <h2> etc.  Using
108       the html_h_level method will change these levels setting the h level of
109       =head1 tags:
110
111         $p->html_h_level(3);
112
113       Will make sure that =head1 will become <h3> and =head2 will become <h4>
114       etc...
115
116   index
117       Set it to some true value if you want to have an index (in reality a
118       table of contents) to be added at the top of the generated HTML.
119
120         $p->index(1);
121
122   html_header_after_title
123       Includes the closing tag of </title> and through the rest of the head
124       till the opening of the body
125
126         $p->html_header_after_title('</title>...</head><body id="my_id">');
127
128   html_footer
129       The very end of the document:
130
131         $p->html_footer( qq[\n<!-- end doc -->\n\n</body></html>\n] );
132

SUBCLASSING

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

SEE ALSO

189       Pod::Simple, Pod::Simple::HTMLBatch
190
191       TODO: a corpus of sample Pod input and HTML output?  Or common idioms?
192

SUPPORT

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

ACKNOWLEDGEMENTS

217       Thanks to Hurricane Electric <http://he.net/> for permission to use its
218       Linux man pages online <http://man.he.net/> site for man page links.
219
220       Thanks to search.cpan.org <http://search.cpan.org/> for permission to
221       use the site for Perl module links.
222

AUTHOR

224       Pod::Simple was created by Sean M. Burke <sburke@cpan.org>.  But don't
225       bother him, he's retired.
226
227       Pod::Simple is maintained by:
228
229       ·   Allison Randal "allison@perl.org"
230
231       ·   Hans Dieter Pearcey "hdp@cpan.org"
232
233       ·   David E. Wheeler "dwheeler@cpan.org"
234
235
236
237perl v5.16.3                      2013-05-03              Pod::Simple::HTML(3)
Impressum