line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Swim::Pod; |
2
|
1
|
|
|
1
|
|
1194
|
use Pegex::Base; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
3
|
|
|
|
|
|
|
extends 'Swim::Markup'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub get_separator { |
6
|
0
|
|
|
0
|
0
|
|
my ($self, $node) = @_; |
7
|
0
|
|
|
|
|
|
$node = $node->[0] while ref($node) eq 'ARRAY'; |
8
|
0
|
0
|
|
|
|
|
return '' unless ref $node; |
9
|
0
|
0
|
|
|
|
|
$self->node_is_block($node) ? "\n" : ''; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub render_text { |
13
|
0
|
|
|
0
|
0
|
|
my ($self, $text) = @_; |
14
|
0
|
|
|
|
|
|
$text =~ s/\n/ /g; |
15
|
0
|
|
|
|
|
|
return $text; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub render_comment { |
19
|
0
|
|
|
0
|
0
|
|
my ($self, $node) = @_; |
20
|
0
|
0
|
|
|
|
|
if ($node !~ /\n/) { |
|
|
0
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
"=for comment $node\n"; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
elsif ($node !~ /\n\n/) { |
24
|
0
|
|
|
|
|
|
"=for comment\n$node\n"; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
else { |
27
|
0
|
|
|
|
|
|
"=begin comment\n$node\n=end\n"; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub render_para { |
32
|
0
|
|
|
0
|
0
|
|
my ($self, $node) = @_; |
33
|
0
|
|
|
|
|
|
my $out = $self->render($node); |
34
|
0
|
0
|
|
|
|
|
if ($self->option->{'wrap'}) { |
35
|
0
|
|
|
|
|
|
require Text::Autoformat; |
36
|
0
|
0
|
|
|
|
|
if ($out !~ /^=for /) { |
37
|
0
|
|
|
|
|
|
$out = Text::Autoformat::autoformat( |
38
|
|
|
|
|
|
|
$out, { |
39
|
|
|
|
|
|
|
right => 78, |
40
|
|
|
|
|
|
|
# XXX Seems to have a bug where it removes lines after |
41
|
|
|
|
|
|
|
# paragraphs: |
42
|
|
|
|
|
|
|
# ignore => sub { $_ =~ qr!\bhttps?://! }, |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
# Attempt to repair places where Text::Autoformat cuts http links: |
46
|
0
|
|
|
|
|
|
while ( |
47
|
|
|
|
|
|
|
$out =~ |
48
|
|
|
|
|
|
|
s{\ *\n?(L]*>)([.,!?:]?)(?:\ *\n?)} |
49
|
|
|
|
|
|
|
{\n$1$2$3\n}g |
50
|
0
|
|
|
|
|
|
) {}; |
51
|
|
|
|
|
|
|
while ( |
52
|
|
|
|
|
|
|
$out =~ |
53
|
|
|
|
|
|
|
s{(L<[^>]*)\n(\S[^>]*)} |
54
|
|
|
|
|
|
|
{$1$2}g |
55
|
0
|
|
|
|
|
|
) {}; |
56
|
0
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
chomp $out; |
58
|
0
|
|
|
|
|
|
return $out; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
return "$out\n"; |
61
|
0
|
|
|
0
|
0
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub render_blank { '' } |
64
|
0
|
|
|
0
|
0
|
|
|
65
|
0
|
0
|
|
|
|
|
sub render_title { |
66
|
0
|
0
|
|
|
|
|
my ($self, $node, $number) = @_; |
67
|
0
|
|
|
|
|
|
my ($name, $abstract) = ref $node ? @$node : (undef, $node); |
68
|
0
|
0
|
|
|
|
|
my $label = $self->option->{'pod-upper-head'} ? 'NAME' : 'Name'; |
69
|
0
|
|
|
|
|
|
$name = $self->render($name); |
70
|
0
|
|
|
|
|
|
if (defined $abstract) { |
71
|
|
|
|
|
|
|
$abstract = $self->render($abstract); |
72
|
|
|
|
|
|
|
"=head1 $label\n\n$name - $abstract\n"; |
73
|
0
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
else { |
75
|
|
|
|
|
|
|
"=head1 $name\n"; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
0
|
|
|
0
|
0
|
|
|
79
|
0
|
|
|
|
|
|
sub render_head { |
80
|
0
|
0
|
0
|
|
|
|
my ($self, $node, $number) = @_; |
81
|
0
|
|
|
|
|
|
my $out = $self->render($node); |
82
|
|
|
|
|
|
|
$out = uc($out) if $number eq '1' and $self->option->{'pod-upper-head'}; |
83
|
|
|
|
|
|
|
"=head$number $out\n"; |
84
|
|
|
|
|
|
|
} |
85
|
0
|
|
|
0
|
0
|
|
|
86
|
0
|
|
|
|
|
|
sub render_pref { |
87
|
0
|
|
|
|
|
|
my ($self, $node) = @_; |
88
|
0
|
|
|
|
|
|
my $out = $node; |
89
|
0
|
|
|
|
|
|
chomp $out; |
90
|
|
|
|
|
|
|
$out =~ s/^(.)/ $1/gm; |
91
|
|
|
|
|
|
|
"$out\n"; |
92
|
|
|
|
|
|
|
} |
93
|
0
|
|
|
0
|
0
|
|
|
94
|
0
|
|
|
|
|
|
sub render_bold { |
95
|
0
|
|
|
|
|
|
my ($self, $node) = @_; |
96
|
|
|
|
|
|
|
my $out = $self->render($node); |
97
|
|
|
|
|
|
|
$self->render_phrase(B => $out); |
98
|
|
|
|
|
|
|
} |
99
|
0
|
|
|
0
|
0
|
|
|
100
|
0
|
|
|
|
|
|
sub render_emph { |
101
|
0
|
|
|
|
|
|
my ($self, $node) = @_; |
102
|
|
|
|
|
|
|
my $out = $self->render($node); |
103
|
|
|
|
|
|
|
$self->render_phrase(I => $out); |
104
|
|
|
|
|
|
|
} |
105
|
0
|
|
|
0
|
0
|
|
|
106
|
0
|
|
|
|
|
|
sub render_del { |
107
|
0
|
|
|
|
|
|
my ($self, $node) = @_; |
108
|
|
|
|
|
|
|
my $out = $self->render($node); |
109
|
|
|
|
|
|
|
"--$out--"; |
110
|
|
|
|
|
|
|
} |
111
|
0
|
|
|
0
|
0
|
|
|
112
|
0
|
|
|
|
|
|
sub render_under { |
113
|
0
|
|
|
|
|
|
my ($self, $node) = @_; |
114
|
|
|
|
|
|
|
my $out = $self->render($node); |
115
|
|
|
|
|
|
|
"_${out}_"; |
116
|
|
|
|
|
|
|
} |
117
|
0
|
|
|
0
|
0
|
|
|
118
|
0
|
|
|
|
|
|
sub render_code { |
119
|
0
|
|
|
|
|
|
my ($self, $node) = @_; |
120
|
|
|
|
|
|
|
my $out = $self->render($node); |
121
|
|
|
|
|
|
|
$self->render_phrase(C => $out); |
122
|
|
|
|
|
|
|
} |
123
|
0
|
|
|
0
|
0
|
|
|
124
|
0
|
|
|
|
|
|
sub render_hyper { |
|
0
|
|
|
|
|
|
|
125
|
0
|
0
|
|
|
|
|
my ($self, $node) = @_; |
126
|
|
|
|
|
|
|
my ($link, $text) = @{$node}{qw(link text)}; |
127
|
|
|
|
|
|
|
(length $text == 0) |
128
|
|
|
|
|
|
|
? $self->render_phrase(L => $link) |
129
|
|
|
|
|
|
|
: $self->render_phrase(L => "$text|$link"); |
130
|
|
|
|
|
|
|
} |
131
|
0
|
|
|
0
|
0
|
|
|
132
|
0
|
|
|
|
|
|
sub render_link { |
|
0
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
my ($self, $node) = @_; |
134
|
|
|
|
|
|
|
my ($link, $text) = @{$node}{qw(link text)}; |
135
|
0
|
0
|
0
|
|
|
|
$link = $self->custom_link($link) |
136
|
0
|
0
|
|
|
|
|
if defined $self->meta and |
137
|
|
|
|
|
|
|
defined $self->meta->{'pod-custom-link'}; |
138
|
|
|
|
|
|
|
(length $text == 0) |
139
|
|
|
|
|
|
|
? $self->render_phrase(L => $link) |
140
|
|
|
|
|
|
|
: $self->render_phrase(L => "$text|$link"); |
141
|
|
|
|
|
|
|
} |
142
|
0
|
|
|
0
|
0
|
|
|
143
|
0
|
|
|
|
|
|
sub custom_link { |
144
|
0
|
0
|
|
|
|
|
my ($self, $link) = @_; |
145
|
|
|
|
|
|
|
my $customs = $self->meta->{'pod-custom-link'}; |
146
|
0
|
|
|
|
|
|
ref($customs) =~ 'ARRAY' |
147
|
|
|
|
|
|
|
or die "Meta 'pod-custom-array' must be an array of hashes"; |
148
|
0
|
0
|
|
|
|
|
for my $custom (@$customs) { |
149
|
|
|
|
|
|
|
my $regex = $custom->{match} |
150
|
0
|
0
|
|
|
|
|
or die "No 'match' regex for 'pod-custom-link' meta"; |
151
|
0
|
0
|
|
|
|
|
my $format = $custom->{format} |
152
|
0
|
|
|
|
|
|
or die "No 'format' string for 'pod-custom-link' meta"; |
153
|
|
|
|
|
|
|
my @captures = ($link =~ m/$regex/g) or next; |
154
|
0
|
|
|
|
|
|
return sprintf $format, @captures; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
return $link; |
157
|
|
|
|
|
|
|
} |
158
|
0
|
|
|
0
|
0
|
|
|
159
|
0
|
0
|
|
|
|
|
sub render_phrase { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
160
|
|
|
|
|
|
|
my ($self, $code, $text) = @_; |
161
|
|
|
|
|
|
|
($text !~ /[<>]/) ? "$code<$text>" : |
162
|
|
|
|
|
|
|
($text !~ /(<< | >>)/) ? "$code<< $text >>" : |
163
|
|
|
|
|
|
|
($text !~ /(<<< | >>>)/) ? "$code<<< $text >>>" : |
164
|
|
|
|
|
|
|
($text !~ /(<<<< | >>>>)/) ? "$code<<<< $text >>>>" : |
165
|
|
|
|
|
|
|
($text !~ /(<<<<< | >>>>>)/) ? "$code<<<<< $text >>>>>" : |
166
|
|
|
|
|
|
|
$text; |
167
|
|
|
|
|
|
|
} |
168
|
0
|
|
|
0
|
0
|
|
|
169
|
0
|
|
|
|
|
|
sub render_list { |
170
|
0
|
|
|
|
|
|
my ($self, $node) = @_; |
171
|
|
|
|
|
|
|
my $out = $self->render($node); |
172
|
|
|
|
|
|
|
"=over\n\n$out\n=back\n"; |
173
|
|
|
|
|
|
|
} |
174
|
0
|
|
|
0
|
0
|
|
|
175
|
0
|
|
|
|
|
|
sub render_item { |
176
|
0
|
|
|
|
|
|
my ($self, $node) = @_; |
177
|
0
|
0
|
|
|
|
|
my $item = shift @$node; |
178
|
0
|
|
|
|
|
|
my $out = "=item * " . $self->render($item) . "\n"; |
179
|
|
|
|
|
|
|
$out .= "\n" . $self->render($node) if @$node; |
180
|
|
|
|
|
|
|
$out; |
181
|
|
|
|
|
|
|
} |
182
|
0
|
|
|
0
|
0
|
|
|
183
|
0
|
|
0
|
|
|
|
sub render_olist { |
184
|
0
|
|
|
|
|
|
my ($self, $node) = @_; |
185
|
0
|
|
|
|
|
|
my $number = $self->{number} ||=[]; |
186
|
0
|
|
|
|
|
|
push @$number, 1; |
187
|
0
|
|
|
|
|
|
my $out = $self->render($node); |
188
|
|
|
|
|
|
|
pop @$number; |
189
|
|
|
|
|
|
|
"=over\n\n$out\n=back\n"; |
190
|
|
|
|
|
|
|
} |
191
|
0
|
|
|
0
|
0
|
|
|
192
|
0
|
|
|
|
|
|
sub render_oitem { |
193
|
0
|
|
|
|
|
|
my ($self, $node) = @_; |
194
|
0
|
|
|
|
|
|
my $item = shift @$node; |
195
|
0
|
0
|
|
|
|
|
my $out = "=item $self->{number}[-1].\n\n" . $self->render($item) . "\n"; |
196
|
0
|
|
|
|
|
|
$self->{number}[-1]++; |
197
|
|
|
|
|
|
|
$out .= "\n" . $self->render($node) if @$node; |
198
|
|
|
|
|
|
|
$out; |
199
|
|
|
|
|
|
|
} |
200
|
0
|
|
|
0
|
0
|
|
|
201
|
0
|
|
|
|
|
|
sub render_data { |
202
|
0
|
|
|
|
|
|
my ($self, $node) = @_; |
203
|
0
|
|
|
|
|
|
my $out = "=over\n\n"; |
204
|
0
|
|
|
|
|
|
for my $item (@$node) { |
205
|
0
|
|
|
|
|
|
my ($term, $def, $rest) = @$item; |
206
|
0
|
0
|
|
|
|
|
$term = $self->render($term); |
207
|
0
|
|
|
|
|
|
$out .= "=item $term\n\n"; |
208
|
|
|
|
|
|
|
if (length $def) { |
209
|
0
|
0
|
|
|
|
|
$out .= $self->render($def) . "\n\n"; |
210
|
0
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
if ($rest) { |
212
|
|
|
|
|
|
|
$out .= $self->render($rest) . "\n"; |
213
|
0
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
$out . "=back\n"; |
216
|
|
|
|
|
|
|
} |
217
|
0
|
|
|
0
|
0
|
|
|
218
|
0
|
|
|
|
|
|
sub render_complete { |
219
|
0
|
|
|
|
|
|
require Swim; |
220
|
|
|
|
|
|
|
my ($self, $out) = @_; |
221
|
|
|
|
|
|
|
chomp $out; |
222
|
|
|
|
|
|
|
<<"..." |
223
|
|
|
|
|
|
|
=pod |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=for comment |
226
|
|
|
|
|
|
|
DO NOT EDIT. This Pod was generated by Swim v$Swim::VERSION. |
227
|
|
|
|
|
|
|
See http://github.com/ingydotnet/swim-pm#readme |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=encoding utf8 |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
$out |
232
|
|
|
|
|
|
|
|
233
|
0
|
|
|
|
|
|
=cut |
234
|
|
|
|
|
|
|
... |
235
|
|
|
|
|
|
|
} |
236
|
0
|
|
|
0
|
0
|
|
|
237
|
0
|
|
|
|
|
|
sub phrase_func_image { |
238
|
|
|
|
|
|
|
my ($self, $args) = @_; |
239
|
|
|
|
|
|
|
sprintf qq{=for html\n\n\n}, $args; |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
1; |