line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Grok::Parser::Pod5; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
2
|
|
|
2
|
|
30969
|
$App::Grok::Parser::Pod5::AUTHORITY = 'cpan:HINRIK'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
$App::Grok::Parser::Pod5::VERSION = '0.26'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
71
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
81
|
|
10
|
2
|
|
|
2
|
|
13
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
103
|
|
11
|
2
|
|
|
2
|
|
1322
|
use File::Temp qw<tempfile>; |
|
2
|
|
|
|
|
34387
|
|
|
2
|
|
|
|
|
852
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my %formatter = ( |
14
|
|
|
|
|
|
|
text => 'Pod::Text', |
15
|
|
|
|
|
|
|
ansi => 'Pod::Text::Ansi', |
16
|
|
|
|
|
|
|
xhtml => 'Pod::Xhtml', |
17
|
|
|
|
|
|
|
pod => 'Pod::Perldoc::ToPod', |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
1
|
|
|
1
|
1
|
21
|
my ($package, %self) = @_; |
22
|
1
|
|
|
|
|
8
|
return bless \%self, $package; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub render_file { |
26
|
2
|
|
|
2
|
1
|
10
|
my ($self, $file, $format) = @_; |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
7
|
my $form = $formatter{$format}; |
29
|
2
|
50
|
|
|
|
10
|
die __PACKAGE__ . " doesn't support the '$format' format" if !defined $form; |
30
|
2
|
|
|
|
|
192
|
eval "require $form"; |
31
|
2
|
50
|
|
|
|
74881
|
die $@ if $@; |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
12
|
my $done = ''; |
34
|
|
|
|
|
|
|
## no critic (InputOutput::RequireBriefOpen) |
35
|
2
|
50
|
|
1
|
|
59
|
open my $out_fh, '>', \$done or die "Can't open output filehandle: $!"; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
36
|
|
|
|
|
|
|
|
37
|
2
|
50
|
|
|
|
2207
|
if ($form eq 'Pod::Perldoc::ToPod') { |
38
|
0
|
|
|
|
|
0
|
my ($temp_fh, $temp) = tempfile(); |
39
|
0
|
|
|
|
|
0
|
my $pod = do { local $/ = undef; scalar <$file> }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
40
|
0
|
|
|
|
|
0
|
print $temp_fh $pod; |
41
|
0
|
|
|
|
|
0
|
$file = $temp; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else { |
44
|
2
|
50
|
|
|
|
16
|
binmode $out_fh, ':utf8' if $form ne 'Pod::Perldoc::ToPod'; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
2
|
|
|
|
|
24
|
$form->new->parse_from_file($file, $out_fh); |
48
|
2
|
|
|
|
|
12697
|
close $out_fh; |
49
|
2
|
|
|
|
|
18
|
return $done; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub render_string { |
53
|
0
|
|
|
0
|
1
|
0
|
my ($self, $string, $format) = @_; |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
0
|
open my $handle, '<', \$string or die "Can't open input filehandle: $!"; |
56
|
0
|
|
|
|
|
0
|
my $result = $self->render_file($handle, $format); |
57
|
0
|
|
|
|
|
0
|
close $handle; |
58
|
0
|
|
|
|
|
0
|
return $result; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=encoding utf8 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 NAME |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
App::Grok::Parser::Pod5 - A Pod 5 backend for grok |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 METHODS |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 C<new> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This is the constructor. It currently takes no arguments. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 C<render_file> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Takes two arguments, a filename and the name of an output format. Returns |
78
|
|
|
|
|
|
|
a string containing the rendered document. It will C<die> if there is an |
79
|
|
|
|
|
|
|
error. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 C<render_string> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Takes two arguments, a string and the name of an output format. Returns |
84
|
|
|
|
|
|
|
a string containing the rendered document. It will C<die> if there is an |
85
|
|
|
|
|
|
|
error. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 AUTHOR |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Hinrik Ãrn Sigurðsson, L<hinrik.sig@gmail.com> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Copyright 2009 Hinrik Ãrn Sigurðsson |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
C<grok> is distributed under the terms of the Artistic License 2.0. |
96
|
|
|
|
|
|
|
For more details, see the full text of the license in the file F<LICENSE> |
97
|
|
|
|
|
|
|
that came with this distribution. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |