line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (c) 2000-2003 by Steven McDougall. This module is free |
2
|
|
|
|
|
|
|
# software; you can redistribute it and/or modify it under the same |
3
|
|
|
|
|
|
|
# terms as Perl itself. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Pod::Tree::Pod; |
6
|
2
|
|
|
2
|
|
4770840
|
use 5.006; |
|
2
|
|
|
|
|
15
|
|
7
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
78
|
|
8
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
144
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.31'; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
580
|
use IO::File; |
|
2
|
|
|
|
|
9616
|
|
|
2
|
|
|
|
|
281
|
|
13
|
2
|
|
|
2
|
|
452
|
use Pod::Tree; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
1606
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
6
|
|
|
6
|
1
|
108
|
my ( $class, $tree, $dest ) = @_; |
17
|
6
|
50
|
|
|
|
16
|
defined $dest or die "Pod::Tree::Pod::new: not enough arguments\n"; |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
|
|
|
13
|
my $file = _resolve_dest($dest); |
20
|
|
|
|
|
|
|
|
21
|
6
|
|
|
|
|
20
|
my $pod = { |
22
|
|
|
|
|
|
|
tree => $tree, |
23
|
|
|
|
|
|
|
root => $tree->get_root, |
24
|
|
|
|
|
|
|
file => $file, |
25
|
|
|
|
|
|
|
interior => 0, |
26
|
|
|
|
|
|
|
link => 0 |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
|
29
|
6
|
|
|
|
|
17
|
bless $pod, $class; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _resolve_dest { |
33
|
6
|
|
|
6
|
|
10
|
my $dest = shift; |
34
|
|
|
|
|
|
|
|
35
|
6
|
50
|
|
|
|
17
|
ref $dest and return $dest; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
0
|
my $fh = IO::File->new; |
38
|
0
|
0
|
|
|
|
0
|
$fh->open(">$dest") or die "Pod::Tree::Pod::new: Can't open $dest: $!\n"; |
39
|
0
|
|
|
|
|
0
|
$fh; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub translate { |
43
|
6
|
|
|
6
|
1
|
22
|
my $pod = shift; |
44
|
6
|
|
|
|
|
11
|
my $root = $pod->{root}; |
45
|
6
|
|
|
|
|
14
|
$pod->_emit_children($root); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _emit_children { |
49
|
204
|
|
|
204
|
|
291
|
my ( $pod, $node ) = @_; |
50
|
|
|
|
|
|
|
|
51
|
204
|
|
|
|
|
344
|
my $children = $node->get_children; |
52
|
|
|
|
|
|
|
|
53
|
204
|
|
|
|
|
319
|
for my $child (@$children) { |
54
|
410
|
|
|
|
|
647
|
$pod->_emit_node($child); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _emit_siblings { |
59
|
42
|
|
|
42
|
|
69
|
my ( $pod, $node ) = @_; |
60
|
|
|
|
|
|
|
|
61
|
42
|
|
|
|
|
84
|
my $siblings = $node->get_siblings; |
62
|
|
|
|
|
|
|
|
63
|
42
|
|
|
|
|
70
|
for my $sibling (@$siblings) { |
64
|
47
|
|
|
|
|
71
|
$pod->_emit_node($sibling); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _emit_node { |
69
|
497
|
|
|
497
|
|
701
|
my ( $pod, $node ) = @_; |
70
|
497
|
|
|
|
|
678
|
my $type = $node->{type}; |
71
|
|
|
|
|
|
|
|
72
|
497
|
|
|
|
|
695
|
for ($type) { |
73
|
497
|
100
|
|
|
|
918
|
/code/ and $pod->_emit_code($node); |
74
|
497
|
100
|
|
|
|
767
|
/command/ and $pod->_emit_command($node); |
75
|
497
|
100
|
|
|
|
866
|
/for/ and $pod->_emit_for($node); |
76
|
497
|
100
|
|
|
|
777
|
/item/ and $pod->_emit_item($node); |
77
|
497
|
100
|
|
|
|
809
|
/list/ and $pod->_emit_list($node); |
78
|
497
|
100
|
|
|
|
860
|
/ordinary/ and $pod->_emit_ordinary($node); |
79
|
497
|
100
|
|
|
|
836
|
/sequence/ and $pod->_emit_sequence($node); |
80
|
497
|
100
|
|
|
|
1051
|
/text/ and $pod->_emit_text($node); |
81
|
497
|
100
|
|
|
|
1747
|
/verbatim/ and $pod->_emit_verbatim($node); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub _emit_code { |
86
|
2
|
|
|
2
|
|
3
|
my ( $pod, $node ) = @_; |
87
|
2
|
|
|
|
|
4
|
my $file = $pod->{file}; |
88
|
2
|
|
|
|
|
5
|
my $text = $node->get_text; |
89
|
|
|
|
|
|
|
|
90
|
2
|
|
|
|
|
7
|
$file->print($text); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _emit_command { |
94
|
23
|
|
|
23
|
|
38
|
my ( $pod, $node ) = @_; |
95
|
23
|
|
|
|
|
33
|
my $file = $pod->{file}; |
96
|
23
|
|
|
|
|
41
|
my $raw = $node->get_raw; |
97
|
|
|
|
|
|
|
|
98
|
23
|
|
|
|
|
47
|
$file->print($raw); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub _emit_for { |
102
|
3
|
|
|
3
|
|
6
|
my ( $pod, $node ) = @_; |
103
|
3
|
|
|
|
|
6
|
my $file = $pod->{file}; |
104
|
3
|
|
|
|
|
8
|
my $brackets = $node->get_brackets; |
105
|
|
|
|
|
|
|
|
106
|
3
|
|
|
|
|
8
|
$file->print( $brackets->[0] ); |
107
|
3
|
|
|
|
|
15
|
$file->print( $node->get_text ); |
108
|
3
|
100
|
|
|
|
18
|
$file->print( $brackets->[1] ) if $brackets->[1]; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub _emit_item { |
112
|
42
|
|
|
42
|
|
61
|
my ( $pod, $node ) = @_; |
113
|
42
|
|
|
|
|
52
|
my $file = $pod->{file}; |
114
|
|
|
|
|
|
|
|
115
|
42
|
|
|
|
|
99
|
$file->print("=item "); |
116
|
42
|
|
|
|
|
175
|
$pod->_emit_children($node); |
117
|
|
|
|
|
|
|
|
118
|
42
|
|
|
|
|
77
|
$pod->_emit_siblings($node); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub _emit_list { |
122
|
19
|
|
|
19
|
|
30
|
my ( $pod, $node ) = @_; |
123
|
19
|
|
|
|
|
27
|
my $file = $pod->{file}; |
124
|
|
|
|
|
|
|
|
125
|
19
|
|
|
|
|
37
|
my $over = $node->get_raw; |
126
|
19
|
|
|
|
|
45
|
$file->print($over); |
127
|
|
|
|
|
|
|
|
128
|
19
|
|
|
|
|
81
|
$pod->_emit_children($node); |
129
|
|
|
|
|
|
|
|
130
|
19
|
|
|
|
|
36
|
my $back = $node->get_back; |
131
|
19
|
100
|
|
|
|
46
|
$back |
132
|
|
|
|
|
|
|
and $file->print( $back->get_raw ); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub _emit_ordinary { |
136
|
88
|
|
|
88
|
|
137
|
my ( $pod, $node ) = @_; |
137
|
|
|
|
|
|
|
|
138
|
88
|
|
|
|
|
140
|
$pod->_emit_children($node); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub _emit_sequence { |
142
|
76
|
|
|
76
|
|
109
|
my ( $pod, $node ) = @_; |
143
|
|
|
|
|
|
|
|
144
|
76
|
|
|
|
|
92
|
$pod->{interior}++; |
145
|
|
|
|
|
|
|
|
146
|
76
|
|
|
|
|
137
|
for ( $node->get_letter ) { |
147
|
76
|
100
|
|
|
|
286
|
/I|B|C|E|F|S|X/ and $pod->_emit_element($node), last; |
148
|
27
|
50
|
|
|
|
406
|
/L/ and $pod->_emit_link($node), last; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
76
|
|
|
|
|
315
|
$pod->{interior}--; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub _emit_element { |
155
|
49
|
|
|
49
|
|
75
|
my ( $pod, $node ) = @_; |
156
|
|
|
|
|
|
|
|
157
|
49
|
|
|
|
|
84
|
my $letter = $node->get_letter; |
158
|
49
|
|
|
|
|
68
|
my $file = $pod->{file}; |
159
|
|
|
|
|
|
|
|
160
|
49
|
|
|
|
|
128
|
$file->print("$letter<"); |
161
|
49
|
|
|
|
|
239
|
$pod->_emit_children($node); |
162
|
49
|
|
|
|
|
83
|
$file->print(">"); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub _emit_link { |
166
|
27
|
|
|
27
|
|
55
|
my ( $pod, $node ) = @_; |
167
|
|
|
|
|
|
|
|
168
|
27
|
|
|
|
|
38
|
my $file = $pod->{file}; |
169
|
|
|
|
|
|
|
|
170
|
27
|
|
|
|
|
59
|
$file->print("L<"); |
171
|
|
|
|
|
|
|
|
172
|
27
|
|
|
|
|
112
|
my $children = $node->get_raw_kids; |
173
|
27
|
|
|
|
|
47
|
for my $child (@$children) { |
174
|
40
|
|
|
|
|
61
|
$pod->_emit_node($child); |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
27
|
|
|
|
|
51
|
$file->print(">"); |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub _emit_link_hide { |
181
|
0
|
|
|
0
|
|
0
|
my ( $pod, $node ) = @_; |
182
|
|
|
|
|
|
|
|
183
|
0
|
|
|
|
|
0
|
my $file = $pod->{file}; |
184
|
0
|
|
|
|
|
0
|
my $target = $node->get_target; |
185
|
0
|
|
|
|
|
0
|
my $page = $target->get_page; |
186
|
0
|
|
|
|
|
0
|
my $section = $target->get_section; |
187
|
0
|
0
|
|
|
|
0
|
my $slash = $section ? '/' : ''; |
188
|
0
|
|
|
|
|
0
|
my $link = "$page$slash$section"; |
189
|
|
|
|
|
|
|
|
190
|
0
|
0
|
|
|
|
0
|
if ( $link eq $node->get_deep_text ) { |
191
|
0
|
|
|
|
|
0
|
$file->print("L<"); |
192
|
0
|
|
|
|
|
0
|
$pod->_emit_children($node); |
193
|
0
|
|
|
|
|
0
|
$file->print(">"); |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
else { |
196
|
0
|
|
|
|
|
0
|
$pod->{link}++; |
197
|
|
|
|
|
|
|
|
198
|
0
|
|
|
|
|
0
|
$file->print("L<"); |
199
|
0
|
|
|
|
|
0
|
$pod->_emit_children($node); |
200
|
|
|
|
|
|
|
|
201
|
0
|
|
|
|
|
0
|
$page = $pod->_escape($page); |
202
|
0
|
|
|
|
|
0
|
$section = $pod->_escape($section); |
203
|
0
|
|
|
|
|
0
|
$file->print("|$page$slash$section>"); |
204
|
|
|
|
|
|
|
|
205
|
0
|
|
|
|
|
0
|
$pod->{link}--; |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub _emit_text { |
210
|
241
|
|
|
241
|
|
340
|
my ( $pod, $node ) = @_; |
211
|
241
|
|
|
|
|
322
|
my $file = $pod->{file}; |
212
|
241
|
|
|
|
|
453
|
my $text = $node->get_text; |
213
|
|
|
|
|
|
|
|
214
|
241
|
|
|
|
|
405
|
$text = $pod->_escape($text); |
215
|
241
|
|
|
|
|
451
|
$file->print($text); |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
sub _escape { |
219
|
241
|
|
|
241
|
|
359
|
my ( $pod, $text ) = @_; |
220
|
|
|
|
|
|
|
|
221
|
241
|
|
|
|
|
344
|
$text =~ s/^=(\w)/=Z<>$1/; |
222
|
|
|
|
|
|
|
|
223
|
241
|
100
|
|
|
|
385
|
if ( $pod->{interior} ) { |
224
|
76
|
|
|
|
|
98
|
$text =~ s/([A-Z])$1E/g; |
225
|
76
|
|
|
|
|
109
|
$text =~ s/>/E/g; |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
241
|
50
|
|
|
|
376
|
if ( $pod->{link} ) { |
229
|
0
|
|
|
|
|
0
|
$text =~ s(\|)(E)g; |
230
|
0
|
|
|
|
|
0
|
$text =~ s(/)(E)g; |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
241
|
|
|
|
|
356
|
$text =~ s/([\x80-\xff])/sprintf("E<%d>", ord($1))/eg; |
|
12
|
|
|
|
|
43
|
|
234
|
|
|
|
|
|
|
|
235
|
241
|
|
|
|
|
451
|
$text; |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
sub _emit_verbatim { |
239
|
3
|
|
|
3
|
|
7
|
my ( $pod, $node ) = @_; |
240
|
3
|
|
|
|
|
4
|
my $file = $pod->{file}; |
241
|
3
|
|
|
|
|
8
|
my $text = $node->get_text; |
242
|
|
|
|
|
|
|
|
243
|
3
|
|
|
|
|
9
|
$file->print($text); |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
1 |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
__END__ |