line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::Advent; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
302778
|
use strict; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
756
|
|
4
|
8
|
|
|
8
|
|
43
|
use warnings; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
291
|
|
5
|
8
|
|
|
8
|
|
40
|
use base qw(Pod::Simple); |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
24145
|
|
6
|
8
|
|
|
8
|
|
456876
|
use Perl::Tidy; |
|
8
|
|
|
|
|
2477427
|
|
|
8
|
|
|
|
|
1097
|
|
7
|
8
|
|
|
8
|
|
75
|
use Cwd; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
588
|
|
8
|
8
|
|
|
8
|
|
134
|
use File::Basename(); |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
227
|
|
9
|
8
|
|
|
8
|
|
42
|
use HTML::Entities(); |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
34805
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.24'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @mode; |
14
|
|
|
|
|
|
|
our $section; |
15
|
|
|
|
|
|
|
our %data; |
16
|
|
|
|
|
|
|
our %blocks; |
17
|
|
|
|
|
|
|
our %M_values_seen; |
18
|
|
|
|
|
|
|
our $BODY_ONLY; |
19
|
|
|
|
|
|
|
our $speller; |
20
|
|
|
|
|
|
|
our @misspelled; |
21
|
|
|
|
|
|
|
our %footnotes; |
22
|
|
|
|
|
|
|
our @PERLTIDY_ARGV = qw/ -npro -html -pre /; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__PACKAGE__->__reset(); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub __reset(){ |
27
|
77
|
|
|
77
|
|
177
|
my $self = shift; |
28
|
|
|
|
|
|
|
|
29
|
77
|
|
|
|
|
192
|
@mode = (); |
30
|
77
|
|
|
|
|
147
|
$section = ''; |
31
|
77
|
|
|
|
|
4653
|
%data = ( |
32
|
|
|
|
|
|
|
title => undef, |
33
|
|
|
|
|
|
|
author => undef, |
34
|
|
|
|
|
|
|
year => (localtime)[5]+1900, |
35
|
|
|
|
|
|
|
day => 0, |
36
|
|
|
|
|
|
|
body => '', |
37
|
|
|
|
|
|
|
file => undef, |
38
|
|
|
|
|
|
|
css_url => '../style.css', |
39
|
|
|
|
|
|
|
isAdvent => 1, |
40
|
|
|
|
|
|
|
); |
41
|
77
|
|
|
|
|
673
|
%blocks = ( |
42
|
|
|
|
|
|
|
code => '', |
43
|
|
|
|
|
|
|
codeNNN => '', |
44
|
|
|
|
|
|
|
pre => '', |
45
|
|
|
|
|
|
|
sourced_file => '', |
46
|
|
|
|
|
|
|
sourced_desc => '', |
47
|
|
|
|
|
|
|
); |
48
|
77
|
|
|
|
|
161
|
%M_values_seen = (); |
49
|
77
|
|
|
|
|
135
|
$BODY_ONLY = 0; |
50
|
77
|
|
|
|
|
123
|
$speller = undef; |
51
|
77
|
|
|
|
|
120
|
eval { |
52
|
77
|
|
|
|
|
55874
|
require Text::Aspell; |
53
|
0
|
|
|
|
|
0
|
$speller = Text::Aspell->new; |
54
|
0
|
|
|
|
|
0
|
$speller->set_option('lang','en_US'); |
55
|
|
|
|
|
|
|
}; |
56
|
77
|
50
|
|
|
|
595
|
$self->spellcheck_enabled or warn "Couldn't load Text::Aspell -- spellchecking disabled."; |
57
|
77
|
|
|
|
|
234
|
@misspelled = (); |
58
|
77
|
|
|
|
|
239
|
%footnotes = (); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub spellcheck_enabled { |
62
|
216
|
|
|
216
|
1
|
84442
|
my $self = shift; |
63
|
216
|
50
|
|
|
|
7505
|
return ref($speller) eq 'Text::Aspell' ? 1 : 0; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub new { |
67
|
69
|
|
|
69
|
1
|
76347
|
my $self = shift; |
68
|
69
|
|
|
|
|
430
|
$self = $self->SUPER::new(@_); |
69
|
69
|
|
|
|
|
2276
|
$self->accept_codes( qw/A D M N P/ ); |
70
|
69
|
|
|
|
|
4860
|
$self->accept_targets_as_text( qw/advent_title advent_author advent_year advent_day/ ); |
71
|
69
|
|
|
|
|
2018
|
$self->accept_targets( qw/code codeNNN pre/ ); |
72
|
69
|
|
|
|
|
1307
|
$self->accept_targets_as_text( qw/quote eds footnote/ ); |
73
|
69
|
|
|
|
|
1678
|
$self->accept_directive_as_data('sourcedcode'); |
74
|
69
|
|
|
|
|
1467
|
$self->__reset(); |
75
|
69
|
|
|
|
|
212
|
return $self; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub css_url { |
79
|
3
|
|
|
3
|
1
|
1887
|
my $self = shift; |
80
|
3
|
100
|
|
|
|
10
|
if( scalar @_ ){ |
81
|
1
|
|
|
|
|
4
|
$data{css_url} = $_[0]; |
82
|
|
|
|
|
|
|
} |
83
|
3
|
|
|
|
|
9
|
return $data{css_url}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub parse_file { |
87
|
5
|
|
|
5
|
1
|
14906
|
my $self = shift; |
88
|
5
|
|
|
|
|
15
|
my $filename = shift; |
89
|
5
|
|
|
|
|
48
|
my $cwd = getcwd(); |
90
|
5
|
100
|
|
|
|
26
|
if( ! ref($filename) ){ # if it's a scalar, meaning a filename |
91
|
3
|
|
|
|
|
119
|
my( $f, $d) = File::Basename::fileparse($filename); |
92
|
3
|
|
|
|
|
11
|
$data{file} = $f; |
93
|
3
|
|
|
|
|
6
|
$filename = $f; |
94
|
3
|
|
|
|
|
35
|
chdir $d; |
95
|
|
|
|
|
|
|
} |
96
|
5
|
|
|
|
|
54
|
$self = $self->SUPER::parse_file($filename, @_); |
97
|
5
|
|
|
|
|
524
|
chdir $cwd; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub add { |
101
|
587
|
|
|
587
|
1
|
970
|
my $self = shift; |
102
|
587
|
|
|
|
|
793
|
my $s = shift; |
103
|
587
|
|
|
|
|
1984
|
$data{body} .= $s; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub nl { |
107
|
100
|
|
|
100
|
1
|
283
|
my $self = shift; |
108
|
100
|
|
|
|
|
198
|
$self->add("\n"); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub _handle_element_start { |
112
|
303
|
|
|
303
|
|
87930
|
my($parser, $element_name, $attr_hash_r) = @_; |
113
|
303
|
|
|
|
|
676
|
push @mode, $element_name; |
114
|
303
|
100
|
100
|
|
|
5356
|
if( $element_name eq 'Document' ){ |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
115
|
|
|
|
|
|
|
}elsif( $element_name eq 'head1' ){ |
116
|
5
|
|
|
|
|
21
|
$parser->add('<h1>'); |
117
|
|
|
|
|
|
|
}elsif( $element_name eq 'head2' ){ |
118
|
4
|
|
|
|
|
13
|
$parser->add('<h2>'); |
119
|
|
|
|
|
|
|
}elsif( $element_name eq 'head3' ){ |
120
|
2
|
|
|
|
|
7
|
$parser->add('<h3>'); |
121
|
|
|
|
|
|
|
}elsif( $element_name eq 'head4' ){ |
122
|
2
|
|
|
|
|
7
|
$parser->add('<h4>'); |
123
|
|
|
|
|
|
|
}elsif( $element_name eq 'Para' && $mode[-2] eq 'footnote' ){ |
124
|
|
|
|
|
|
|
# nothing |
125
|
|
|
|
|
|
|
}elsif( $element_name eq 'Para' && $mode[-2] ne 'for' ){ |
126
|
81
|
|
|
|
|
339
|
$parser->add('<p>'); |
127
|
|
|
|
|
|
|
}elsif( $element_name eq 'L' ){ |
128
|
4
|
|
|
|
|
26
|
$parser->add( sprintf('<a href="%s">',$attr_hash_r->{to}) ); |
129
|
|
|
|
|
|
|
}elsif( $element_name eq 'A' ){ |
130
|
|
|
|
|
|
|
}elsif( $element_name eq 'M' ){ |
131
|
7
|
|
|
|
|
19
|
$parser->add('<tt>'); |
132
|
|
|
|
|
|
|
}elsif( $element_name eq 'F' ){ |
133
|
4
|
|
|
|
|
11
|
$parser->add('<tt>'); |
134
|
|
|
|
|
|
|
}elsif( $element_name eq 'C' ){ |
135
|
2
|
|
|
|
|
8
|
$parser->add('<tt>'); |
136
|
|
|
|
|
|
|
}elsif( $element_name eq 'I' ){ |
137
|
10
|
|
|
|
|
30
|
$parser->add('<span style="font-style: italic">'); |
138
|
|
|
|
|
|
|
}elsif( $element_name eq 'B' ){ |
139
|
11
|
|
|
|
|
40
|
$parser->add('<span style="font-weight: bold">'); |
140
|
|
|
|
|
|
|
}elsif( $element_name eq 'for' && $attr_hash_r->{target} =~ /^advent_(\w+)$/ ){ |
141
|
13
|
|
|
|
|
53
|
$section = $1; |
142
|
|
|
|
|
|
|
}elsif( $element_name eq 'for' && $attr_hash_r->{target} eq 'footnote' ){ |
143
|
5
|
|
|
|
|
17
|
$mode[-1] = $attr_hash_r->{target}; |
144
|
5
|
|
|
|
|
16
|
$section = $attr_hash_r->{title}; |
145
|
5
|
100
|
|
|
|
37
|
my $n = delete $footnotes{$section} or die "footnote '$section' is not referenced."; |
146
|
4
|
|
|
|
|
26
|
$parser->add( sprintf '<p><a name="footnote_%s" id="footnote_%s"></a>%d. ', $section, $section, $n); |
147
|
|
|
|
|
|
|
}elsif( $element_name eq 'for' && $attr_hash_r->{target} eq 'quote' ){ |
148
|
2
|
|
|
|
|
6
|
$mode[-1] = $attr_hash_r->{target}; |
149
|
2
|
|
|
|
|
8
|
$parser->add('<blockquote>'); |
150
|
|
|
|
|
|
|
}elsif( $element_name eq 'for' && $attr_hash_r->{target} eq 'eds' ){ |
151
|
2
|
|
|
|
|
8
|
$mode[-1] = $attr_hash_r->{target}; |
152
|
2
|
|
|
|
|
9
|
$parser->add('<blockquote>'); |
153
|
|
|
|
|
|
|
}elsif( $element_name eq 'for' && $attr_hash_r->{target} eq 'code' ){ |
154
|
3
|
|
|
|
|
16
|
$section = $attr_hash_r->{target}; |
155
|
|
|
|
|
|
|
}elsif( $element_name eq 'for' && $attr_hash_r->{target} eq 'codeNNN' ){ |
156
|
2
|
|
|
|
|
11
|
$section = $attr_hash_r->{target}; |
157
|
|
|
|
|
|
|
}elsif( $element_name eq 'for' && $attr_hash_r->{target} eq 'pre' ){ |
158
|
4
|
|
|
|
|
12
|
$mode[-1] = $attr_hash_r->{target}; |
159
|
4
|
|
100
|
|
|
33
|
$section = $attr_hash_r->{title} || 'normal'; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub _handle_element_end { |
164
|
253
|
|
|
253
|
|
8052
|
my($parser, $element_name) = @_; |
165
|
253
|
|
|
|
|
635
|
my $mode = pop @mode; |
166
|
253
|
100
|
100
|
|
|
4105
|
if( $element_name eq 'Document' ){ |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
167
|
51
|
|
|
|
|
205
|
die "footnote '$_' is not defined" for keys %footnotes; |
168
|
100
|
100
|
|
|
|
483
|
my ($htmlTitle, $pageTitle) = $data{isAdvent} |
169
|
150
|
100
|
|
|
|
522
|
? ( sprintf('%d Perl Advent Calendar: %s',map {defined($_)?$_:''} @data{qw/year title/}), |
170
|
50
|
50
|
0
|
|
|
237
|
sprintf('<h1><a href="../">Perl Advent Calendar %d-12</a>-%02d</h1>'."\n".'<h2 align="center">%s</h2>',,map {defined($_)?$_:''} @data{qw/year day title/}) ) |
|
|
|
0
|
|
|
|
|
171
|
|
|
|
|
|
|
: ( $data{title}||'', |
172
|
|
|
|
|
|
|
sprintf('<h1>%s</h1>',$data{title}||'') ) |
173
|
|
|
|
|
|
|
; |
174
|
50
|
|
|
|
|
116
|
my $fmt = <<'EOF'; |
175
|
|
|
|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
176
|
|
|
|
|
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
177
|
|
|
|
|
|
|
<!-- Generated by Pod::Advent %s (Pod::Simple %s, Perl::Tidy %s) on %04d-%02d-%02d %02d:%02d:%02d --> |
178
|
|
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml"> |
179
|
|
|
|
|
|
|
<head> |
180
|
|
|
|
|
|
|
<title>%s</title> |
181
|
|
|
|
|
|
|
<link rel="stylesheet" href="%s" type="text/css" /> |
182
|
|
|
|
|
|
|
%s |
183
|
|
|
|
|
|
|
</head> |
184
|
|
|
|
|
|
|
<body> |
185
|
|
|
|
|
|
|
%s |
186
|
|
|
|
|
|
|
%s |
187
|
|
|
|
|
|
|
EOF |
188
|
50
|
|
|
|
|
1560
|
my @d = (localtime)[5,4,3,2,1,0]; $d[1]++; $d[0]+=1900; |
|
50
|
|
|
|
|
89
|
|
|
50
|
|
|
|
|
116
|
|
189
|
50
|
|
100
|
|
|
214
|
my $fh = $parser->output_fh() || \*STDOUT; |
190
|
50
|
100
|
|
|
|
80578
|
printf( $fh $fmt, |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
191
|
|
|
|
|
|
|
$Pod::Advent::VERSION, $Pod::Simple::VERSION, $Perl::Tidy::VERSION, |
192
|
|
|
|
|
|
|
@d[0..5], |
193
|
|
|
|
|
|
|
$htmlTitle, |
194
|
|
|
|
|
|
|
$data{css_url}, |
195
|
|
|
|
|
|
|
$data{file} ? qq{<link rel="alternate" type="text/plain" href="$data{file}" />} : "", |
196
|
|
|
|
|
|
|
$pageTitle, |
197
|
|
|
|
|
|
|
$data{author} ? qq{<h3 align="center">by $data{author}</h3>} : '', |
198
|
|
|
|
|
|
|
) unless $BODY_ONLY; |
199
|
50
|
|
|
|
|
32127
|
print $fh $data{body}; |
200
|
50
|
100
|
|
|
|
518
|
if( $data{file} ){ |
201
|
3
|
|
|
|
|
89
|
printf $fh '<div style="float: right; font-size: 10pt"><a href="%s">View Source (POD)</a></div><br />'."\n", $data{file}; |
202
|
|
|
|
|
|
|
} |
203
|
50
|
100
|
|
|
|
295
|
print $fh <<'EOF' unless $BODY_ONLY; |
204
|
|
|
|
|
|
|
</body> |
205
|
|
|
|
|
|
|
</html> |
206
|
|
|
|
|
|
|
EOF |
207
|
|
|
|
|
|
|
}elsif( $element_name eq 'head1' ){ |
208
|
5
|
|
|
|
|
14
|
$parser->add('</h1>'); |
209
|
5
|
|
|
|
|
15
|
$parser->nl; |
210
|
|
|
|
|
|
|
}elsif( $element_name eq 'head2' ){ |
211
|
4
|
|
|
|
|
12
|
$parser->add('</h2>'); |
212
|
4
|
|
|
|
|
10
|
$parser->nl; |
213
|
|
|
|
|
|
|
}elsif( $element_name eq 'head3' ){ |
214
|
2
|
|
|
|
|
9
|
$parser->add('</h3>'); |
215
|
2
|
|
|
|
|
5
|
$parser->nl; |
216
|
|
|
|
|
|
|
}elsif( $element_name eq 'head4' ){ |
217
|
2
|
|
|
|
|
16
|
$parser->add('</h4>'); |
218
|
2
|
|
|
|
|
11
|
$parser->nl; |
219
|
|
|
|
|
|
|
}elsif( $element_name eq 'Para' && $mode[-1] eq 'footnote' ){ |
220
|
5
|
|
|
|
|
11
|
$parser->add('<br>'); |
221
|
5
|
|
|
|
|
14
|
$parser->nl; |
222
|
|
|
|
|
|
|
}elsif( $element_name eq 'Para' && $mode[-1] ne 'for' ){ |
223
|
65
|
|
|
|
|
169
|
$parser->add('</p>'); |
224
|
65
|
|
|
|
|
193
|
$parser->nl; |
225
|
|
|
|
|
|
|
}elsif( $element_name eq 'for' && $mode eq 'quote' ){ |
226
|
2
|
|
|
|
|
9
|
$parser->add('</blockquote>'); |
227
|
2
|
|
|
|
|
5
|
$parser->nl; |
228
|
|
|
|
|
|
|
}elsif( $element_name eq 'for' && $mode eq 'eds' ){ |
229
|
2
|
|
|
|
|
8
|
$parser->add('</blockquote>'); |
230
|
2
|
|
|
|
|
13
|
$parser->nl; |
231
|
|
|
|
|
|
|
}elsif( $element_name eq 'for' && $mode eq 'footnote' ){ |
232
|
4
|
|
|
|
|
12
|
$parser->add('</p>'); |
233
|
4
|
|
|
|
|
48
|
$parser->nl; |
234
|
|
|
|
|
|
|
}elsif( $element_name eq 'for' && ($section eq 'code' || $section eq 'codeNNN') ){ |
235
|
5
|
|
|
|
|
8
|
my $s; |
236
|
5
|
|
|
|
|
41
|
$blocks{$section} =~ s/\s+$//; |
237
|
5
|
100
|
|
|
|
66
|
Perl::Tidy::perltidy( |
238
|
|
|
|
|
|
|
source => \$blocks{$section}, |
239
|
|
|
|
|
|
|
destination => \$s, |
240
|
|
|
|
|
|
|
argv => [ @PERLTIDY_ARGV, ($section=~/NNN/?'-nnn':()) ], |
241
|
|
|
|
|
|
|
); |
242
|
5
|
|
|
|
|
304707
|
$parser->add($s); |
243
|
5
|
|
|
|
|
32
|
$parser->nl; |
244
|
5
|
|
|
|
|
20
|
$blocks{$section} = ''; |
245
|
5
|
|
|
|
|
36
|
$section = ''; |
246
|
|
|
|
|
|
|
}elsif( $element_name eq 'for' && $mode eq 'pre' ){ |
247
|
4
|
|
|
|
|
30
|
$blocks{$section} =~ s/\s+$//s; |
248
|
4
|
|
|
|
|
14
|
$parser->add('<pre><span class="c">'); |
249
|
4
|
|
|
|
|
16
|
my $s = $blocks{$section}; |
250
|
4
|
100
|
|
|
|
19
|
$s = HTML::Entities::encode_entities($s) if $section eq 'encode_entities'; |
251
|
4
|
|
|
|
|
46
|
$parser->add( $s ); |
252
|
4
|
|
|
|
|
12
|
$parser->add('</span></pre>'); |
253
|
4
|
|
|
|
|
12
|
$parser->nl; |
254
|
4
|
|
|
|
|
10
|
$blocks{$section} = ''; |
255
|
4
|
|
|
|
|
16
|
$section = ''; |
256
|
|
|
|
|
|
|
}elsif( $element_name eq 'L' ){ |
257
|
4
|
|
|
|
|
12
|
$parser->add('</a>'); |
258
|
|
|
|
|
|
|
}elsif( $element_name eq 'M' ){ |
259
|
7
|
|
|
|
|
21
|
$parser->add('</tt>'); |
260
|
|
|
|
|
|
|
}elsif( $element_name eq 'A' ){ |
261
|
|
|
|
|
|
|
}elsif( $element_name eq 'F' ){ |
262
|
4
|
|
|
|
|
10
|
$parser->add('</tt>'); |
263
|
|
|
|
|
|
|
}elsif( $element_name eq 'C' ){ |
264
|
2
|
|
|
|
|
8
|
$parser->add('</tt>'); |
265
|
|
|
|
|
|
|
}elsif( $element_name eq 'I' ){ |
266
|
10
|
|
|
|
|
30
|
$parser->add('</span>'); |
267
|
|
|
|
|
|
|
}elsif( $element_name eq 'B' ){ |
268
|
11
|
|
|
|
|
34
|
$parser->add('</span>'); |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
sub _handle_text { |
273
|
203
|
|
|
203
|
|
4044
|
my($parser, $text) = @_; |
274
|
203
|
|
|
|
|
335
|
my $mode = $mode[-1]; |
275
|
203
|
|
|
|
|
270
|
my $out = ''; |
276
|
203
|
100
|
66
|
|
|
2473
|
if( $mode eq 'Verbatim' ){ |
|
|
100
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
277
|
1
|
|
|
|
|
2
|
my $s; |
278
|
1
|
|
|
|
|
10
|
Perl::Tidy::perltidy( |
279
|
|
|
|
|
|
|
source => \$text, |
280
|
|
|
|
|
|
|
destination => \$s, |
281
|
|
|
|
|
|
|
argv => [ @PERLTIDY_ARGV ], |
282
|
|
|
|
|
|
|
); |
283
|
1
|
|
|
|
|
12072
|
$out .= $s; |
284
|
|
|
|
|
|
|
}elsif( $mode eq 'C' ){ |
285
|
2
|
|
|
|
|
3
|
my $s; |
286
|
2
|
|
|
|
|
20
|
Perl::Tidy::perltidy( |
287
|
|
|
|
|
|
|
source => \$text, |
288
|
|
|
|
|
|
|
destination => \$s, |
289
|
|
|
|
|
|
|
argv => [ @PERLTIDY_ARGV ], |
290
|
|
|
|
|
|
|
); |
291
|
2
|
|
|
|
|
252208
|
$s =~ s#^<pre>\s*(.*?)\s*</pre>\s*$#$1#si; |
292
|
2
|
|
|
|
|
10
|
$out .= $s; |
293
|
|
|
|
|
|
|
}elsif( $mode eq 'N' ){ |
294
|
7
|
100
|
|
|
|
41
|
die "footnote '$text' is already referenced" if exists $footnotes{$text}; |
295
|
6
|
|
|
|
|
27
|
$footnotes{$text} = 1 + scalar keys %footnotes; |
296
|
6
|
|
|
|
|
36
|
$out .= sprintf '<sup><a href="#footnote_%s">%s</a></sup>', $text, $footnotes{$text}; |
297
|
|
|
|
|
|
|
}elsif( $mode eq 'P' ){ |
298
|
21
|
|
|
|
|
136
|
my ($year, $day, $label) = $text =~ m/^(\d{4})-(?:12-)?(\d{1,2})(?:\|(.+))?$/; |
299
|
21
|
|
|
|
|
689
|
my $CURYEAR = (localtime)[5] + 1900; |
300
|
21
|
100
|
66
|
|
|
423
|
die "invalid date from P<$text>" unless $year && 2000 <= $year && $year <= $CURYEAR && 1 <= $day && $day <= 25; |
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
301
|
6
|
100
|
|
|
|
41
|
$out .= sprintf '<a href="../../%d/%d/">%s</a>', |
302
|
|
|
|
|
|
|
$year, $day, ($label ? $label : sprintf '%d/%d', $year, $day); |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
}elsif( $mode eq 'sourcedcode' ){ |
305
|
3
|
100
|
|
|
|
206
|
die "bad filename '$text'" unless -r $text; |
306
|
2
|
|
|
|
|
9
|
$blocks{sourced_file} = $text; |
307
|
2
|
|
|
|
|
18
|
$out .= sprintf '<a name="%s" id="%s"></a><h2><a href="%s">%s</a></h2>', ($text)x4; |
308
|
2
|
|
|
|
|
4
|
my $s; |
309
|
2
|
|
|
|
|
19
|
Perl::Tidy::perltidy( |
310
|
|
|
|
|
|
|
source => $text, |
311
|
|
|
|
|
|
|
destination => \$s, |
312
|
|
|
|
|
|
|
argv => [ @PERLTIDY_ARGV, '-nnn' ], |
313
|
|
|
|
|
|
|
# formatter => bless( {file=>$text, dest => \$s}, 'Pod::Advent::Tidy' ), |
314
|
|
|
|
|
|
|
); |
315
|
2
|
|
|
|
|
45064
|
$s =~ s#^\s*(\d+) #<a name="$text.$1"></a>$&#mg; |
316
|
2
|
|
|
|
|
15
|
$out .= $s; |
317
|
|
|
|
|
|
|
}elsif( $mode eq 'Para' && $section ){ |
318
|
17
|
|
|
|
|
186
|
$data{$section} = $text; |
319
|
17
|
|
|
|
|
33
|
$section = ''; |
320
|
17
|
|
|
|
|
50
|
$parser->__spellcheck($text); |
321
|
17
|
100
|
|
|
|
119
|
$out .= $text if $mode[-2] eq 'footnote'; |
322
|
|
|
|
|
|
|
}elsif( $mode eq 'A' ){ |
323
|
8
|
|
|
|
|
11
|
my $href; |
324
|
8
|
|
|
|
|
34
|
($href, $text) = split /\|/, $text, 2; |
325
|
8
|
100
|
|
|
|
30
|
$text = $href unless defined $text; |
326
|
8
|
100
|
|
|
|
45
|
$parser->__spellcheck($text) unless $text =~ /^http/; |
327
|
8
|
|
|
|
|
42
|
$parser->add( sprintf('<a href="%s">%s</a>',$href,$text) ); |
328
|
|
|
|
|
|
|
}elsif( $mode eq 'M' ){ |
329
|
7
|
|
|
|
|
11
|
my($real, $alt); |
330
|
7
|
50
|
|
|
|
40
|
unless( ($real, $alt) = split /\|/, $text, 2 ){ |
331
|
0
|
|
|
|
|
0
|
$real = $text; |
332
|
|
|
|
|
|
|
} |
333
|
7
|
100
|
|
|
|
24
|
$alt = $real if !defined $alt; |
334
|
7
|
100
|
|
|
|
30
|
if( $M_values_seen{$real}++ ){ |
335
|
1
|
|
|
|
|
7
|
$parser->add( sprintf('<span title="%s">%s</span>', $real, $alt) ); |
336
|
|
|
|
|
|
|
}else{ |
337
|
6
|
|
|
|
|
45
|
$parser->add( sprintf('<a href="http://search.cpan.org/perldoc?%s" title="%s">%s</a>',$real,$real, $alt) ); |
338
|
|
|
|
|
|
|
} |
339
|
|
|
|
|
|
|
}elsif( $mode eq 'Data' && $section ){ |
340
|
12
|
|
|
|
|
51
|
$blocks{$section} .= $text . "\n\n"; |
341
|
|
|
|
|
|
|
}elsif( $mode eq 'F' ){ |
342
|
4
|
|
|
|
|
9
|
$out .= $text; |
343
|
|
|
|
|
|
|
}elsif( $mode eq 'L' ){ |
344
|
4
|
|
|
|
|
7
|
$out .= $text; |
345
|
|
|
|
|
|
|
}elsif( $mode eq 'D' ){ |
346
|
4
|
|
|
|
|
10
|
$out .= $text; |
347
|
|
|
|
|
|
|
}else{ |
348
|
113
|
|
|
|
|
302
|
$parser->__spellcheck($text); |
349
|
113
|
|
|
|
|
285
|
$out .= $text; |
350
|
|
|
|
|
|
|
} |
351
|
186
|
|
|
|
|
487
|
$parser->add( $out, undef ); |
352
|
|
|
|
|
|
|
} |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
sub __spellcheck { |
355
|
135
|
|
|
135
|
|
189
|
my $parser = shift; |
356
|
135
|
|
|
|
|
176
|
my $text = shift; |
357
|
135
|
50
|
|
|
|
315
|
return unless $parser->spellcheck_enabled; |
358
|
0
|
|
|
|
|
0
|
my $bad_ct = 0; |
359
|
0
|
|
|
|
|
0
|
foreach my $word ( split /\W+/, $text ){ |
360
|
0
|
0
|
0
|
|
|
0
|
next if $speller->check( $word ) || $word =~ /^\d+$/; |
361
|
0
|
|
|
|
|
0
|
push @misspelled, $word; |
362
|
0
|
|
|
|
|
0
|
$bad_ct++; |
363
|
|
|
|
|
|
|
} |
364
|
0
|
|
|
|
|
0
|
return $bad_ct; |
365
|
|
|
|
|
|
|
} |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
sub spelling_errors { |
368
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
369
|
1
|
|
|
|
|
7
|
return @misspelled; |
370
|
|
|
|
|
|
|
} |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
sub num_spelling_errors { |
373
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
374
|
1
|
|
|
|
|
7
|
return scalar @misspelled; |
375
|
|
|
|
|
|
|
} |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
1; # End of Pod::Advent |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
#package Pod::Advent::Tidy; |
380
|
|
|
|
|
|
|
#sub write_line { |
381
|
|
|
|
|
|
|
# my ( $self, $line_of_tokens ) = @_; |
382
|
|
|
|
|
|
|
# ${ $self->{dest} } .= sprintf q{<a name="%s.%s"></a>%4d %s}, |
383
|
|
|
|
|
|
|
# $self->{file}, |
384
|
|
|
|
|
|
|
# $line_of_tokens->{_line_number}, |
385
|
|
|
|
|
|
|
# $line_of_tokens->{_line_number}, |
386
|
|
|
|
|
|
|
# $line_of_tokens->{_line_text}, |
387
|
|
|
|
|
|
|
# ; |
388
|
|
|
|
|
|
|
#} |
389
|
|
|
|
|
|
|
#1; |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
__END__ |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
=pod |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
=head1 NAME |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
Pod::Advent - POD Formatter for The Perl Advent Calendar |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
=head1 VERSION |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
Version 0.24 |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
=head1 GETTING STARTED |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
Most likely, the included I<pod2advent> script is all you will need: |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
pod2advent entry.pod > entry.html |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
Where the .pod is written using the tags described below. There is also a quick start at L<http://search.cpan.org/dist/Pod-Advent/ex/getting_started.html>. |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
=head1 SYNOPSIS |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
Using this module directly: |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
use Pod::Advent; |
416
|
|
|
|
|
|
|
my $pod = shift @ARGV or die "need pod filename"; |
417
|
|
|
|
|
|
|
my $advent = Pod::Advent->new; |
418
|
|
|
|
|
|
|
$advent->parse_file( \*STDIN ); |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
Example POD: |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
=for advent_year 2009 |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
=for advent_day 32 |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
=for advent_title This is a sample |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
=for advent_author Your Name Here |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
Today's module M<My::Example> is featured on |
431
|
|
|
|
|
|
|
the A<http://example.com|Example Place> web site |
432
|
|
|
|
|
|
|
and is I<very> B<special>. |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
=sourcedcode example.pl |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
B<Getting Started:> |
437
|
|
|
|
|
|
|
See F<ex/getting_started.pod> and F<ex/getting_started.html> in the distribution for an initial template. |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
=head1 DESCRIPTION |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
This module provides a POD formatter that is designed to facilitate the create of submissions for The Perl Advent Calendar (L<http://perladvent.pm.org>) by providing authors with simple markup that will be automatically transformed to full-fill the specific formatting guidelines. This makes it easier for authors to provide calendar-ready submissions, and for the editors to save lots of time in editting submissions. |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
For example, 'file-, module and program names should be wrapped in <tt>,' and 'the code sample should be appended to the document from the results of a perltidy -nnn -html'. Both of these can be trivially accomplished: |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
This entry is for M<Foo::Bar> and the F<script.pl> program. |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
=sourcedcode mod0.pl |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
The meta-data of title, date (year & day), and author is now easy to specify as well, and is used to automatically generate the full HTML header (including style) that the calendar entries require before being posted. |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
See F<ex/sample.pod> and F<ex/sample.html> in the distribution for a fuller example. |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
=head1 SUPPORTED POD |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
General note: HTML code in the pod source will be left alone, so it's effectively passed through. For example, these two lines are identical: |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
B<blah> |
458
|
|
|
|
|
|
|
<b>blah</b> |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
This being POD, the former should be used. |
461
|
|
|
|
|
|
|
Where the html is useful is more for things w/o POD equivalents, |
462
|
|
|
|
|
|
|
like HTML encoding and writing C<&>, C<…>, C<—>, etc |
463
|
|
|
|
|
|
|
or using E<lt>BRE<gt>'s, E<lt>HRE<gt>'s, etc, |
464
|
|
|
|
|
|
|
or including images, comments, etc. |
465
|
|
|
|
|
|
|
Be aware that you may need to use the C<ZE<lt>E<gt>> pod code to prevent some cases of html use from being interpreted as POD. |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
=head2 Custom Codes |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
=head3 AE<lt>E<gt> |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
This is because POD doesn't support the case of LE<lt>http://example.com|ExampleE<gt>, so we introduce this AE<lt>E<gt> code for that exact purpose -- to generate E<lt>a href="URL"E<gt>TEXTE<lt>/aE<gt> hyperlinks. |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
A<http://perladvent.pm.org|The Perl Advent Calendar> |
474
|
|
|
|
|
|
|
A<http://perladvent.pm.org> |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
=head3 ME<lt>E<gt> |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
This is intended for module names. The first instance, it will <tt> it and hyperlink it to a F<http://search.cpan.org/perldoc?> url. All following instances will just <tt> it. Being just for module searches, any other searches can simply use the AE<lt>E<gt> code instead. |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
M<Pod::Simple> |
481
|
|
|
|
|
|
|
M<Pod::Simple|PS> |
482
|
|
|
|
|
|
|
A<http://search.cpan.org/search?query=Pod::Simple::Subclassing|Pod::Simple::Subclassing> |
483
|
|
|
|
|
|
|
A<http://search.cpan.org/search?dist=TimeDate|TimeDate> |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
=head3 NE<lt>E<gt> |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
Insert a superscript footnote reference. See L<"Footnotes">. |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
=head3 PE<lt>E<gt> |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
Link to a B<P>ast Advent Calendar entry. Syntax is I<E<lt>YYYY-DE<gt>>. I<YYYY-12-D> may also be used, as can I<E<lt>YYYY-D|labelE<gt>> (or both). |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
=head3 DE<lt>E<gt> |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
B<D>isables spellchecking for the contents, which can be a single word or a phrase (including other pod formatting). |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
=head2 Custom Directives |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
=head3 sourcedcode |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
Include the contents of a file formatted with Perl::Tidy (including line numbers). |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
=sourcedcode foo.pl |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
The line numbers are anchored, so you can refer to them with links: |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
A<#foo.pl.3|third line> |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
=head2 Custom Info Targets |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
=head3 advent_title |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
Specify the title of the submission. |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
=for advent_title Your Entry Title |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
=head3 advent_author |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
Specify the author of the submission. |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
=for advent_author Your Name Here |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
=head3 advent_year |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
Specify the year of the submission (defaults to current year). |
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
=for advent_year 2009 |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
=head3 advent_day |
531
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
Specify the day of the submission (if currently known). |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
=for advent_day 99 |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
=head2 Custom Block Targets |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
=head3 code |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
Display a code snippet (sends it through Perl::Tidy). |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
=begin code |
543
|
|
|
|
|
|
|
my $foo = Bar->new(); |
544
|
|
|
|
|
|
|
$foo->do_it; |
545
|
|
|
|
|
|
|
=end code |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
=head3 codeNNN |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
Same as L<code>, but with line numbers. |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
=begin codeNNN |
552
|
|
|
|
|
|
|
my $foo = Bar->new(); |
553
|
|
|
|
|
|
|
$foo->do_it; |
554
|
|
|
|
|
|
|
=end codeNNN |
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
=head3 pre [encode_entities] |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
Display a snippet (e.g. data, output, etc) as E<lt>PREE<gt>-formatted text (does not use Perl::Tidy). |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
=begin pre |
561
|
|
|
|
|
|
|
x,y,z |
562
|
|
|
|
|
|
|
1,2,3 |
563
|
|
|
|
|
|
|
2,4,9 |
564
|
|
|
|
|
|
|
3,8,27 |
565
|
|
|
|
|
|
|
=end pre |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
If C<encode_entities> parameter is specified, then the text will be processed by L<HTML::Entities>C<::encode_entities()>. This is especially handy/necessary if your text contains E<lt>'s or E<gt>'s. |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
=head3 quote |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
Processes POD and wraps it in a E<lt>BLOCKQUOTEE<gt> section. |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
=begin quote |
574
|
|
|
|
|
|
|
"Ho-Ho-Ho!" |
575
|
|
|
|
|
|
|
-- S.C. |
576
|
|
|
|
|
|
|
=end quote |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
=head3 eds |
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
Currently behaves exactly the same as L<quote>. |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
=begin eds |
583
|
|
|
|
|
|
|
The editors requested |
584
|
|
|
|
|
|
|
this directive. |
585
|
|
|
|
|
|
|
-- the management |
586
|
|
|
|
|
|
|
=end eds |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
=head3 footnote |
589
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
Define a footnote's content. See L<"Footnotes">. |
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
=head2 Footnotes |
593
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
A footnote consists of a pair of elements -- one is the L<"NE<lt>E<gt>"> code and one is the L<"footnote"> target. They are each pass a common identifier for the footnote. This way the author doesn't have to keep track of the numbering. |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
In this entry we talk about XYZ.N<foo> |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
... |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
=begin footnote foo |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
The interesting thing about this is B<bar>. |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
=end footnote |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
Note that the identifier is used for an anchor name (C<#footnote_foo>), so it must be C</^\w+$/>. |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
The reference will appear as a superscript number. The first instance of L<"NE<lt>E<gt>"> will be C<1>, the next C<2>, and so on. |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
=head2 Standard Codes |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
=head3 LE<lt>E<gt> |
613
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
Normal behavior. |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
=head3 FE<lt>E<gt> |
617
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
Normal behavior. Uses E<lt>ttE<gt> |
619
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
=head3 CE<lt>E<gt> |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
Uses E<lt>ttE<gt>. Sends text through Perl::Tidy. |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
=head3 IE<lt>E<gt> |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
Normal behavior: uses E<lt>IE<gt> |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
=head3 BE<lt>E<gt> |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
Normal behavior: uses E<lt>BE<gt> |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
=head2 Standard Directives |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
=head3 headN |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
Expected behavior (N=1..4): uses E<lt>headNE<gt> |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
=head1 METHODS |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
See L<Pod::Simple> for all of the inherited methods. Also see L<Pod::Simple::Subclassing> for more information. |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
=head2 new |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
Constructor. See L<Pod::Simple>. |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
=head2 parse_file |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
Overloaded from Pod::Simple -- if input is a filename, will add a link to it at the bottom of the generated HTML. |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
Also, if input is a filename, it will chdir to the filename's directory before parsing the file. Thus any files referenced (e.g. in a L<"sourcedcode"> tag) are expected to be relative to the .pod file itself. |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
=head2 css_url |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
Accessor/mutator for the stylesheet to use. Defaults to F<../style.css> |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
=head2 spellcheck_enabled |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
Returns a boolean of whether or not spellchecking will be done (depends on presence of L<Text::Aspell>). |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
=head2 num_spelling_errors |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
Returns the number of (possible) spelling errors found while parsing. |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
=head2 spelling_errors |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
Returns an array of the (possible) spelling errors found while parsing. |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
=head1 INTERNAL METHODS |
670
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
=head2 add |
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
Appends text to the output buffer. |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
=head2 nl |
676
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
Appends a newline onto the output buffer. |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
=head2 _handle_element_start |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
Overload of method to process start of an element. |
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
=head2 _handle_element_end |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
Overload of method to process end of an element. |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
=head2 _handle_text |
688
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
Overload of method to process handling of text. |
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
=head2 __reset |
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
Resets all of the internal (package) variables. |
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
=head2 __spellcheck |
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
Splits a chunk of text into words and runs it through Text::Aspell. |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
=head1 AUTHOR |
700
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
David Westbrook (CPAN: davidrw), C<< <dwestbrook at gmail.com> >> |
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
=head1 BUGS |
704
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-pod-advent at rt.cpan.org>, or through |
706
|
|
|
|
|
|
|
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Pod-Advent>. I will be notified, and then you'll |
707
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
708
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
=head1 SUPPORT |
710
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
712
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
perldoc Pod::Advent |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
You can also look for information at: |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
=over 4 |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Pod-Advent> |
722
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
724
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Pod-Advent> |
726
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
=item * CPAN Ratings |
728
|
|
|
|
|
|
|
|
729
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Pod-Advent> |
730
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
=item * Search CPAN |
732
|
|
|
|
|
|
|
|
733
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/Pod-Advent> |
734
|
|
|
|
|
|
|
|
735
|
|
|
|
|
|
|
=back |
736
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
=head1 SEE ALSO |
738
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
=over 4 |
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
=item * |
742
|
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
L<http://perladvent.pm.org> - The Perl Advent Calendar |
744
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
=item * |
746
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
L<http://perladvent.pm.org/2007/17> - The 2007-12-17 submission that discussed this application of Pod::Simple |
748
|
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
=item * |
750
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
L<Pod::Simple> - The base class for Pod::Advent |
752
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
=item * |
754
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
L<Pod::Simple::Subclassing> - Discusses the techniques that Pod::Advent is based on |
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
=item * |
758
|
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
L<perlpod> - POD documentation |
760
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
=item * |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
L<Perl::Tidy> - used for formatting code |
764
|
|
|
|
|
|
|
|
765
|
|
|
|
|
|
|
=item * |
766
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
L<Text::Aspell> - used for spellchecking |
768
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
=back |
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
772
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
The maintainers of The Perl Advent Calendar at L<http://perladvent.pm.org>. |
774
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
The 2007 editors, Bill Ricker & Jerrad Pierce, for reviewing and providing feedback on this concept. |
776
|
|
|
|
|
|
|
|
777
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
778
|
|
|
|
|
|
|
|
779
|
|
|
|
|
|
|
Copyright 2007-2011 David Westbrook, all rights reserved. |
780
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
782
|
|
|
|
|
|
|
under the same terms as Perl itself. |
783
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
=cut |