line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Template::Plugin::PodSimple - simple Pod::Simple plugin for TT |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
[% USE PodSimple %] |
8
|
|
|
|
|
|
|
[% PodSimple.parse('format',string_containing_pod_or_filename) %] |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 DESCRIPTION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
[% SET somepod = "
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
the name
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
somepod
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
";
|
25
|
|
|
|
|
|
|
USE PodSimple;
|
26
|
|
|
|
|
|
|
%]
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
[% PodSimple.parse('Text', somepod, 76) %] |
29
|
|
|
|
|
|
|
[% PodSimple.parse('xml', somepod) %] |
30
|
|
|
|
|
|
|
[% mySimpleTree = PodSimple.parse('tree', somepod ) %] |
31
|
|
|
|
|
|
|
[% PodSimple.parse('html', somepod, 'pod_link_prefix','man_link_prefix') %] |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Text translates to L. |
34
|
|
|
|
|
|
|
When dealing with text, the 3rd argument is the value for C< $Text::Wrap::columns >. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
xMl translates to L. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
tree translates to L, |
39
|
|
|
|
|
|
|
and the tree B is what's returned. |
40
|
|
|
|
|
|
|
This is what you want to use if you want to create your own formatter. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
htMl translates to L. |
43
|
|
|
|
|
|
|
When dealing with htMl, the 3rd and 4th arguments are |
44
|
|
|
|
|
|
|
is used to prefix all non-local LEEinks, |
45
|
|
|
|
|
|
|
by temporarily overriding |
46
|
|
|
|
|
|
|
C<< *Pod::Simple::HTML::do_pod_link >>. |
47
|
|
|
|
|
|
|
and |
48
|
|
|
|
|
|
|
C<< *Pod::Simple::HTML::do_man_link >>. |
49
|
|
|
|
|
|
|
pod_link_prefix is "?" by default. |
50
|
|
|
|
|
|
|
man_link_prefix is C<< http://man.linuxquestions.org/index.php?type=2&query= >> |
51
|
|
|
|
|
|
|
by default. |
52
|
|
|
|
|
|
|
The prefix always gets html escaped by Pod::Simple. |
53
|
|
|
|
|
|
|
An example man link is C<< L >>. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 SEE ALSO |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
L, |
60
|
|
|
|
|
|
|
L. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 BUGS
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
To report bugs, go to
|
65
|
|
|
|
|
|
|
Ehttp://rt.cpan.org/NoAuth/Bugs.html?Dist=Template-Plugin-PodSimpleE
|
66
|
|
|
|
|
|
|
or send mail to Ebug-Template-Plugin-PodSimple#rt.cpan.orgE. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 LICENSE |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Copyright (c) 2003 by D.H. (PodMaster). All rights reserved.
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it
|
73
|
|
|
|
|
|
|
under the same terms as Perl itself. The LICENSE file contains the full
|
74
|
|
|
|
|
|
|
text of the license.
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
package Template::Plugin::PodSimple; |
79
|
1
|
|
|
1
|
|
23400
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
80
|
1
|
|
|
1
|
|
3182
|
use Pod::Simple; |
|
1
|
|
|
|
|
39460
|
|
|
1
|
|
|
|
|
34
|
|
81
|
1
|
|
|
1
|
|
12
|
use Carp 'croak';
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
76
|
|
82
|
1
|
|
|
1
|
|
6
|
use base qw[ Template::Plugin ];
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1377
|
|
83
|
1
|
|
|
1
|
|
8105
|
use vars '$VERSION'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
866
|
|
84
|
|
|
|
|
|
|
$VERSION = sprintf "%d.%03d", q$Revision: 1.10 $ =~ /(\d+).(\d+)/g; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my %map = ( |
88
|
|
|
|
|
|
|
tree => 'SimpleTree', |
89
|
|
|
|
|
|
|
html => 'HTML', |
90
|
|
|
|
|
|
|
text => 'Text', |
91
|
|
|
|
|
|
|
xml => 'XMLOutStream', |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
my $pod_link_prefix = ''; |
95
|
|
|
|
|
|
|
my $man_link_prefix = ''; |
96
|
|
|
|
|
|
|
sub _do_man_link { |
97
|
0
|
|
|
0
|
|
|
my($self, $link) = @_; |
98
|
0
|
|
|
|
|
|
my $to = $link->attr('to'); |
99
|
0
|
|
|
|
|
|
$to =~ s/\(\d+\)$//; |
100
|
0
|
|
|
|
|
|
return $man_link_prefix.$self->unicode_escape_url($to); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
sub _do_pod_link { |
103
|
0
|
|
|
0
|
|
|
my($self, $link) = @_; |
104
|
0
|
|
|
|
|
|
my $to = $link->attr('to'); |
105
|
0
|
|
|
|
|
|
my $section = $link->attr('section'); |
106
|
|
|
|
|
|
|
return undef unless( # should never happen |
107
|
0
|
0
|
0
|
|
|
|
(defined $to and length $to) or |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
108
|
|
|
|
|
|
|
(defined $section and length $section) |
109
|
|
|
|
|
|
|
); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# if(defined $to and length $to) { |
112
|
|
|
|
|
|
|
# $to = $self->resolve_pod_page_link($to, $section); |
113
|
|
|
|
|
|
|
# return undef unless defined $to and length $to; |
114
|
|
|
|
|
|
|
# resolve_pod_page_link returning undef is how it |
115
|
|
|
|
|
|
|
# can signal that it gives up on making a link |
116
|
|
|
|
|
|
|
# (I pass it the section value, but I don't see a |
117
|
|
|
|
|
|
|
# particular reason it'd use it.) |
118
|
|
|
|
|
|
|
# } |
119
|
|
|
|
|
|
|
|
120
|
0
|
0
|
0
|
|
|
|
if(defined $section and length($section .= '')) { |
121
|
0
|
|
|
|
|
|
$section =~ tr/ /_/; |
122
|
0
|
|
|
|
|
|
$section =~ tr/\x00-\x1F\x80-\x9F//d if 'A' eq chr(65); |
123
|
0
|
|
|
|
|
|
$section = $self->unicode_escape_url($section); |
124
|
|
|
|
|
|
|
# Turn char 1234 into "(1234)" |
125
|
0
|
0
|
|
|
|
|
$section = '_' unless length $section; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
foreach my $it ($to, $section) { |
129
|
0
|
0
|
|
|
|
|
$it =~ s/([^\._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/sprintf('%%%02X',ord($1))/eg |
|
0
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
if defined $it; |
131
|
|
|
|
|
|
|
# Yes, stipulate the list without a range, so that this can work right on |
132
|
|
|
|
|
|
|
# all charsets that this module happens to run under. |
133
|
|
|
|
|
|
|
# Altho, hmm, what about that ord? Presumably that won't work right |
134
|
|
|
|
|
|
|
# under non-ASCII charsets. Something should be done about that. |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
0
|
0
|
0
|
|
|
|
my $out = $to if defined $to and length $to; |
138
|
0
|
0
|
0
|
|
|
|
$out .= "#" . $section if defined $section and length $section; |
139
|
0
|
0
|
|
|
|
|
return undef unless length $out; |
140
|
0
|
|
|
|
|
|
return $pod_link_prefix.$out; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub parse { |
144
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
145
|
0
|
|
|
|
|
|
my $class = lc shift; |
146
|
0
|
|
0
|
|
|
|
$pod_link_prefix = $_[1] || '?'; |
147
|
0
|
|
0
|
|
|
|
$man_link_prefix = $_[2] || 'http://man.linuxquestions.org/index.php?type=2&query='; |
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
my $somestring=""; |
150
|
0
|
|
|
|
|
|
my $new; |
151
|
|
|
|
|
|
|
|
152
|
0
|
0
|
|
|
|
|
unless( exists $INC{"lib/Pod/Simple/$map{$class}.pm"} ){ |
153
|
0
|
|
|
|
|
|
eval "require Pod::Simple::$map{$class};"; |
154
|
0
|
0
|
|
|
|
|
croak("Template::Plugin::PodSimple could not load Pod::Simple::$map{$class} : $@ $!") |
155
|
|
|
|
|
|
|
if $@; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
$new = "Pod::Simple::$map{$class}"->new(); |
159
|
|
|
|
|
|
|
|
160
|
0
|
0
|
|
|
|
|
croak("`$class' not recognized by Template::Plugin::PodSimple $@ $!") |
161
|
|
|
|
|
|
|
unless defined $new; |
162
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
$new->output_string( \$somestring ); |
164
|
|
|
|
|
|
|
|
165
|
0
|
0
|
0
|
|
|
|
local *Pod::Simple::HTML::do_pod_link = \&_do_pod_link |
166
|
|
|
|
|
|
|
and |
167
|
|
|
|
|
|
|
local *Pod::Simple::HTML::do_man_link = \&_do_man_link |
168
|
|
|
|
|
|
|
if $class eq 'html'; |
169
|
|
|
|
|
|
|
|
170
|
0
|
0
|
|
|
|
|
local $Text::Wrap::columns = $_[1] if $class eq 'text'; |
171
|
|
|
|
|
|
|
|
172
|
0
|
0
|
|
|
|
|
if( $_[0] =~ /\n/ ){ |
173
|
0
|
|
|
|
|
|
$new->parse_string_document( $_[0] ); |
174
|
|
|
|
|
|
|
} else { |
175
|
0
|
|
|
|
|
|
$new->parse_file($_[0]); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
0
|
0
|
|
|
|
|
$somestring = $new->root if $class eq 'tree'; |
179
|
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
return $somestring; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
1; |
185
|
|
|
|
|
|
|
__END__ |