summaryrefslogtreecommitdiffstats
path: root/upstream/debian-unstable/man3/Pod::Simple::HTML.3perl
blob: 37462a6d945a7fdef6b1a342b8ede7f9a1b81fa2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
.\" -*- mode: troff; coding: utf-8 -*-
.\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
.ie n \{\
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Pod::Simple::HTML 3perl"
.TH Pod::Simple::HTML 3perl 2024-05-30 "perl v5.38.2" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH NAME
Pod::Simple::HTML \- convert Pod to HTML
.SH SYNOPSIS
.IX Header "SYNOPSIS"
.Vb 1
\&  perl \-MPod::Simple::HTML \-e Pod::Simple::HTML::go thingy.pod
.Ve
.SH DESCRIPTION
.IX Header "DESCRIPTION"
This class is for making an HTML rendering of a Pod document.
.PP
This is a subclass of Pod::Simple::PullParser and inherits all its
methods (and options).
.PP
Note that if you want to do a batch conversion of a lot of Pod
documents to HTML, you should see the module Pod::Simple::HTMLBatch.
.SH "CALLING FROM THE COMMAND LINE"
.IX Header "CALLING FROM THE COMMAND LINE"
TODO
.PP
.Vb 1
\&  perl \-MPod::Simple::HTML \-e Pod::Simple::HTML::go Thing.pod Thing.html
.Ve
.SH "CALLING FROM PERL"
.IX Header "CALLING FROM PERL"
.SS "Minimal code"
.IX Subsection "Minimal code"
.Vb 6
\&  use Pod::Simple::HTML;
\&  my $p = Pod::Simple::HTML\->new;
\&  $p\->output_string(\emy $html);
\&  $p\->parse_file(\*(Aqpath/to/Module/Name.pm\*(Aq);
\&  open my $out, \*(Aq>\*(Aq, \*(Aqout.html\*(Aq or die "Cannot open \*(Aqout.html\*(Aq: $!\en";
\&  print $out $html;
.Ve
.SS "More detailed example"
.IX Subsection "More detailed example"
.Vb 1
\&  use Pod::Simple::HTML;
.Ve
.PP
Set the content type:
.PP
.Vb 1
\&  $Pod::Simple::HTML::Content_decl =  q{<meta http\-equiv="Content\-Type" content="text/html; charset=UTF\-8" >};
\&
\&  my $p = Pod::Simple::HTML\->new;
.Ve
.PP
Include a single javascript source:
.PP
.Vb 1
\&  $p\->html_javascript(\*(Aqhttp://abc.com/a.js\*(Aq);
.Ve
.PP
Or insert multiple javascript source in the header 
(or for that matter include anything, thought this is not recommended)
.PP
.Vb 3
\&  $p\->html_javascript(\*(Aq
\&      <script type="text/javascript" src="http://abc.com/b.js"></script>
\&      <script type="text/javascript" src="http://abc.com/c.js"></script>\*(Aq);
.Ve
.PP
Include a single css source in the header:
.PP
.Vb 1
\&  $p\->html_css(\*(Aq/style.css\*(Aq);
.Ve
.PP
or insert multiple css sources:
.PP
.Vb 3
\&  $p\->html_css(\*(Aq
\&      <link rel="stylesheet" type="text/css" title="pod_stylesheet" href="http://remote.server.com/jquery.css">
\&      <link rel="stylesheet" type="text/css" title="pod_stylesheet" href="/style.css">\*(Aq);
.Ve
.PP
Tell the parser where should the output go. In this case it will be placed in the \f(CW$html\fR variable:
.PP
.Vb 2
\&  my $html;
\&  $p\->output_string(\e$html);
.Ve
.PP
Parse and process a file with pod in it:
.PP
.Vb 1
\&  $p\->parse_file(\*(Aqpath/to/Module/Name.pm\*(Aq);
.Ve
.SH METHODS
.IX Header "METHODS"
TODO
all (most?) accessorized methods
.PP
The following variables need to be set \fBbefore\fR the call to the \->new constructor.
.PP
Set the string that is included before the opening <html> tag:
.PP
.Vb 2
\&  $Pod::Simple::HTML::Doctype_decl = qq{<!DOCTYPE HTML PUBLIC "\-//W3C//DTD HTML 4.01 Transitional//EN" 
\&         "http://www.w3.org/TR/html4/loose.dtd">\en};
.Ve
.PP
Set the content-type in the HTML head: (defaults to ISO\-8859\-1)
.PP
.Vb 1
\&  $Pod::Simple::HTML::Content_decl =  q{<meta http\-equiv="Content\-Type" content="text/html; charset=UTF\-8" >};
.Ve
.PP
Set the value that will be embedded in the opening tags of F, C tags and verbatim text.
F maps to <em>, C maps to <code>, Verbatim text maps to <pre> (Computerese defaults to "")
.PP
.Vb 1
\&  $Pod::Simple::HTML::Computerese =  \*(Aq class="some_class_name\*(Aq;
.Ve
.SS html_css
.IX Subsection "html_css"
.SS html_javascript
.IX Subsection "html_javascript"
.SS title_prefix
.IX Subsection "title_prefix"
.SS title_postfix
.IX Subsection "title_postfix"
.SS html_header_before_title
.IX Subsection "html_header_before_title"
This includes everything before the <title> opening tag including the Document type
and including the opening <title> tag. The following call will set it to be a simple HTML
file:
.PP
.Vb 1
\&  $p\->html_header_before_title(\*(Aq<html><head><title>\*(Aq);
.Ve
.SS top_anchor
.IX Subsection "top_anchor"
By default Pod::Simple::HTML adds a dummy anchor at the top of the HTML.
You can change it by calling
.PP
.Vb 1
\&  $p\->top_anchor(\*(Aq<a name="zz" >\*(Aq);
.Ve
.SS html_h_level
.IX Subsection "html_h_level"
Normally =head1 will become <h1>, =head2 will become <h2> etc.
Using the html_h_level method will change these levels setting the h level
of =head1 tags:
.PP
.Vb 1
\&  $p\->html_h_level(3);
.Ve
.PP
Will make sure that =head1 will become <h3> and =head2 will become <h4> etc...
.SS index
.IX Subsection "index"
Set it to some true value if you want to have an index (in reality a table of contents)
to be added at the top of the generated HTML.
.PP
.Vb 1
\&  $p\->index(1);
.Ve
.SS html_header_after_title
.IX Subsection "html_header_after_title"
Includes the closing tag of </title> and through the rest of the head
till the opening of the body
.PP
.Vb 1
\&  $p\->html_header_after_title(\*(Aq</title>...</head><body id="my_id">\*(Aq);
.Ve
.SS html_footer
.IX Subsection "html_footer"
The very end of the document:
.PP
.Vb 1
\&  $p\->html_footer( qq[\en<!\-\- end doc \-\->\en\en</body></html>\en] );
.Ve
.SH SUBCLASSING
.IX Header "SUBCLASSING"
Can use any of the methods described above but for further customization
one needs to override some of the methods:
.PP
.Vb 3
\&  package My::Pod;
\&  use strict;
\&  use warnings;
\&
\&  use base \*(AqPod::Simple::HTML\*(Aq;
\&
\&  # needs to return a URL string such
\&  # http://some.other.com/page.html
\&  # #anchor_in_the_same_file
\&  # /internal/ref.html
\&  sub do_pod_link {
\&    # My::Pod object and Pod::Simple::PullParserStartToken object
\&    my ($self, $link) = @_;
\&
\&    say $link\->tagname;          # will be L for links
\&    say $link\->attr(\*(Aqto\*(Aq);       # 
\&    say $link\->attr(\*(Aqtype\*(Aq);     # will be \*(Aqpod\*(Aq always
\&    say $link\->attr(\*(Aqsection\*(Aq);
\&
\&    # Links local to our web site
\&    if ($link\->tagname eq \*(AqL\*(Aq and $link\->attr(\*(Aqtype\*(Aq) eq \*(Aqpod\*(Aq) {
\&      my $to = $link\->attr(\*(Aqto\*(Aq);
\&      if ($to =~ /^Padre::/) {
\&          $to =~ s{::}{/}g;
\&          return "/docs/Padre/$to.html";
\&      }
\&    }
\&
\&    # all other links are generated by the parent class
\&    my $ret = $self\->SUPER::do_pod_link($link);
\&    return $ret;
\&  }
\&
\&  1;
.Ve
.PP
Meanwhile in script.pl:
.PP
.Vb 1
\&  use My::Pod;
\&
\&  my $p = My::Pod\->new;
\&
\&  my $html;
\&  $p\->output_string(\e$html);
\&  $p\->parse_file(\*(Aqpath/to/Module/Name.pm\*(Aq);
\&  open my $out, \*(Aq>\*(Aq, \*(Aqout.html\*(Aq or die;
\&  print $out $html;
.Ve
.PP
TODO
.PP
maybe override do_beginning do_end
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Pod::Simple, Pod::Simple::HTMLBatch
.PP
TODO: a corpus of sample Pod input and HTML output?  Or common
idioms?
.SH SUPPORT
.IX Header "SUPPORT"
Questions or discussion about POD and Pod::Simple should be sent to the
pod\-people@perl.org mail list. Send an empty email to
pod\-people\-subscribe@perl.org to subscribe.
.PP
This module is managed in an open GitHub repository,
<https://github.com/perl\-pod/pod\-simple/>. Feel free to fork and contribute, or
to clone <git://github.com/perl\-pod/pod\-simple.git> and send patches!
.PP
Patches against Pod::Simple are welcome. Please send bug reports to
<bug\-pod\-simple@rt.cpan.org>.
.SH "COPYRIGHT AND DISCLAIMERS"
.IX Header "COPYRIGHT AND DISCLAIMERS"
Copyright (c) 2002\-2004 Sean M. Burke.
.PP
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
.PP
This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.
.SH ACKNOWLEDGEMENTS
.IX Header "ACKNOWLEDGEMENTS"
Thanks to Hurricane Electric <http://he.net/> for permission to use its
Linux man pages online <http://man.he.net/> site for man page links.
.PP
Thanks to search.cpan.org <http://search.cpan.org/> for permission to use the
site for Perl module links.
.SH AUTHOR
.IX Header "AUTHOR"
Pod::Simple was created by Sean M. Burke <sburke@cpan.org>.
But don't bother him, he's retired.
.PP
Pod::Simple is maintained by:
.IP \(bu 4
Allison Randal \f(CW\*(C`allison@perl.org\*(C'\fR
.IP \(bu 4
Hans Dieter Pearcey \f(CW\*(C`hdp@cpan.org\*(C'\fR
.IP \(bu 4
David E. Wheeler \f(CW\*(C`dwheeler@cpan.org\*(C'\fR