line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Pod2Epub; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# App::Pod2Epub - Convert Pod to an ePub eBook. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Copyright 2010-2012, John McNamara, jmcnamara@cpan.org |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Documentation after __END__ |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
25263
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
14
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
15
|
1
|
|
|
1
|
|
1820
|
use Pod::Simple::XHTML; |
|
1
|
|
|
|
|
95739
|
|
|
1
|
|
|
|
|
54
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
14
|
use vars qw(@ISA $VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
346
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
@ISA = 'Pod::Simple::XHTML'; |
20
|
|
|
|
|
|
|
$VERSION = '0.05'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
############################################################################### |
23
|
|
|
|
|
|
|
# |
24
|
|
|
|
|
|
|
# new() |
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
# Simple constructor inheriting from Pod::Simple::XHTML. |
27
|
|
|
|
|
|
|
# |
28
|
|
|
|
|
|
|
sub new { |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
31
|
0
|
|
|
|
|
|
my $self = Pod::Simple::XHTML->new( @_ ); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Don't generate an XHTML index. We will use the ePub TOC instead. |
34
|
0
|
|
|
|
|
|
$self->index(0); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Add the default XHTML headers. |
37
|
0
|
|
|
|
|
|
$self->html_header( |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
qq{<?xml version="1.0" encoding="UTF-8"?>\n} |
40
|
|
|
|
|
|
|
. qq{<!DOCTYPE html\n} |
41
|
|
|
|
|
|
|
. qq{ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n} |
42
|
|
|
|
|
|
|
. qq{ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n} |
43
|
|
|
|
|
|
|
. qq{\n} |
44
|
|
|
|
|
|
|
. qq{<html xmlns="http://www.w3.org/1999/xhtml">\n} |
45
|
|
|
|
|
|
|
. qq{<head>\n} |
46
|
|
|
|
|
|
|
. qq{<title></title>\n} |
47
|
|
|
|
|
|
|
. qq{<meta http-equiv="Content-Type" } |
48
|
|
|
|
|
|
|
. qq{content="text/html; charset=iso-8859-1"/>\n} |
49
|
|
|
|
|
|
|
. qq{<link rel="stylesheet" href="../styles/style.css" } |
50
|
|
|
|
|
|
|
. qq{type="text/css"/>\n} |
51
|
|
|
|
|
|
|
. qq{</head>\n} |
52
|
|
|
|
|
|
|
. qq{\n} |
53
|
|
|
|
|
|
|
. qq{<body>\n} |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
bless $self, $class; |
58
|
0
|
|
|
|
|
|
return $self; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=pod |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
App::Pod2Epub - Convert Pod to an ePub eBook. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 DESCRIPTION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This module is used for converting Pod documents to ePub eBooks. The output eBook can be read on a variety of hardware and software eBook readers. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Pod is Perl's I<Plain Old Documentation> format, see L<http://perldoc.perl.org/perlpod.html>. EPub is an eBook format, see L<http://en.wikipedia.org/wiki/Epub>. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This module comes with a L<pod2epub> utility that will convert Pod to an ePub eBook. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SYNOPSIS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
To create a simple filter to convert Pod to an XHTML format suitable for inclusion in an ePub eBook. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
use strict; |
89
|
|
|
|
|
|
|
use App::Pod2Epub; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my $parser = App::Pod2Epub->new(); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
if (defined $ARGV[0]) { |
95
|
|
|
|
|
|
|
open IN, $ARGV[0] or die "Couldn't open $ARGV[0]: $!\n"; |
96
|
|
|
|
|
|
|
} else { |
97
|
|
|
|
|
|
|
*IN = *STDIN; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
if (defined $ARGV[1]) { |
101
|
|
|
|
|
|
|
open OUT, ">$ARGV[1]" or die "Couldn't open $ARGV[1]: $!\n"; |
102
|
|
|
|
|
|
|
} else { |
103
|
|
|
|
|
|
|
*OUT = *STDOUT; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
$parser->output_fh(*OUT); |
107
|
|
|
|
|
|
|
$parser->parse_file(*IN); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__END__ |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
To convert Pod to ePub using the installed C<pod2epub> utility: |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
pod2epub some_module.pm -o some_module.epub |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 USING THIS MODULE |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
At the moment this module isn't very useful on its own. It is mainly in existence as a backend for C<pod2epub>. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
It provides a framework to convert Pod documents to an XHTML format suitable for inclusion in an ePub eBook. The ePub creation is handled by L<EBook::EPUB> in C<pod2epub>. Future versions will move that functionality into this module so that it has a utility of its own. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 METHODS |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 new() |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The C<new> method is used to create a new C<App::Pod2Epub> object. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 Other methods |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
C<App::Pod2Epub> inherits all of the methods of its parent modules C<Pod::Simple> and C<Pod::Simple::XHTML>. See L<Pod::Simple> for more details if you need finer control over the output of this module. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 SEE ALSO |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
This module also installs a L<pod2epub> command line utility. See C<pod2epub --help> for details. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
L<EBook::EPUB>, a general module for generating EPUB documents. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
L<Pod::Simple::XHTML> which this module subclasses. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Thanks to Sean M. Burke and the past and current maintainers for C<Pod::Simple>. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Thanks to Oleksandr Tymoshenko for the excellent L<EBook::EPUB>. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 AUTHOR |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
John McNamara, C<jmcnamara@cpan.org> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Copyright 2010-2012 John McNamara. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
159
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
160
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. See L<http://dev.perl.org/licenses/> for more information. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |
163
|
|
|
|
|
|
|
|