line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
# a subclass of Pod::Simple to catch X and =head lines |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Mediawiki::POD::HTML; |
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
36263
|
use 5.008001; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
140
|
|
7
|
3
|
|
|
3
|
|
17
|
use base qw/Pod::Simple::HTML/; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
1806
|
|
8
|
3
|
|
|
3
|
|
110635
|
use Graph::Easy; |
|
3
|
|
|
|
|
509304
|
|
|
3
|
|
|
|
|
142
|
|
9
|
3
|
|
|
3
|
|
4124
|
use Graph::Easy::Parser; |
|
3
|
|
|
|
|
32849
|
|
|
3
|
|
|
|
|
179
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$VERSION = '0.04'; |
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
38
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
4012
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new |
16
|
|
|
|
|
|
|
{ |
17
|
6
|
|
|
6
|
1
|
839
|
my $class = shift; |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
|
|
|
67
|
my $self = Pod::Simple::HTML->new(@_); |
20
|
|
|
|
|
|
|
|
21
|
6
|
|
|
|
|
3156
|
$self->{_mediawiki_pod_html} = {}; |
22
|
6
|
|
|
|
|
16
|
my $storage = $self->{_mediawiki_pod_html}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# we do not need an index, we will generate it ourselves |
25
|
6
|
|
|
|
|
31
|
$self->index(0); |
26
|
|
|
|
|
|
|
|
27
|
6
|
|
|
|
|
53
|
$storage->{in_headline} = 0; |
28
|
6
|
|
|
|
|
19
|
$storage->{in_x} = 0; |
29
|
6
|
|
|
|
|
20
|
$storage->{in_graph} = 0; |
30
|
6
|
|
|
|
|
14
|
$storage->{headlines} = []; |
31
|
6
|
|
|
|
|
15
|
$storage->{graph_id} = 0; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# the text common to all graphs |
34
|
6
|
|
|
|
|
16
|
$storage->{graph_common} = ''; |
35
|
|
|
|
|
|
|
# the text of the current graph |
36
|
6
|
|
|
|
|
16
|
$storage->{cur_graph} = ''; |
37
|
|
|
|
|
|
|
|
38
|
6
|
|
|
|
|
17
|
$storage->{search} = 'http://cpan.uwinnipeg.ca/search?query=##KEYWORD##'; |
39
|
6
|
|
|
|
|
20
|
$storage->{search_space} = undef; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# we handle these, too: |
42
|
6
|
|
|
|
|
23
|
$self->accept_targets('graph', 'graph-common'); |
43
|
|
|
|
|
|
|
|
44
|
6
|
|
|
|
|
123
|
bless $self, $class; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _convert_graph |
48
|
|
|
|
|
|
|
{ |
49
|
|
|
|
|
|
|
# when we detect the end of a "graph" section, we create CSS+HTML from it: |
50
|
7
|
|
|
7
|
|
14
|
my ($self) = @_; |
51
|
|
|
|
|
|
|
|
52
|
7
|
|
|
|
|
15
|
my $storage = $self->{_mediawiki_pod_html}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# print "# Converting to graph:\n"; |
55
|
|
|
|
|
|
|
# print "# '$storage->{graph_common}'\n"; |
56
|
|
|
|
|
|
|
# print "# '$storage->{cur_graph}'\n"; |
57
|
|
|
|
|
|
|
|
58
|
7
|
|
|
|
|
73
|
my $parser = Graph::Easy::Parser->new(); |
59
|
|
|
|
|
|
|
|
60
|
7
|
|
|
|
|
416
|
my $graph = $parser->from_text( |
61
|
|
|
|
|
|
|
$storage->{graph_common} . "\n" . $storage->{cur_graph} ); |
62
|
|
|
|
|
|
|
|
63
|
7
|
|
|
|
|
15680
|
$graph->set_attribute('gid', $storage->{graph_id}++); |
64
|
|
|
|
|
|
|
|
65
|
7
|
|
|
|
|
906
|
$self->_my_output( '' ); |
66
|
7
|
|
|
|
|
185
|
$self->_my_output( $graph->as_html() ); |
67
|
|
|
|
|
|
|
|
68
|
7
|
|
|
|
|
226
|
$storage->{in_graph} = 0; |
69
|
7
|
|
|
|
|
157
|
$storage->{cur_graph} = ''; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
############################################################################# |
73
|
|
|
|
|
|
|
# overriden methods for parsing: |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _handle_element_start |
76
|
|
|
|
|
|
|
{ |
77
|
44
|
|
|
44
|
|
19256
|
my ($self, $element_name, $attr) = @_; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# print STDERR "start '$element_name'\n"; |
80
|
|
|
|
|
|
|
|
81
|
44
|
|
|
|
|
82
|
my $storage = $self->{_mediawiki_pod_html}; |
82
|
|
|
|
|
|
|
|
83
|
44
|
50
|
33
|
|
|
128
|
if ($element_name eq 'X' && $storage->{in_x} == 0) |
84
|
|
|
|
|
|
|
{ |
85
|
0
|
|
|
|
|
0
|
$storage->{in_x} = 1; |
86
|
0
|
|
|
|
|
0
|
$self->_my_output( ' Keywords: ' ); |
87
|
|
|
|
|
|
|
} |
88
|
44
|
50
|
33
|
|
|
251
|
if ($element_name ne 'X' && $storage->{in_x} != 0) |
89
|
|
|
|
|
|
|
{ |
90
|
|
|
|
|
|
|
# broken chain of X<> keywords |
91
|
0
|
|
|
|
|
0
|
$self->_my_output( '' ); |
92
|
0
|
|
|
|
|
0
|
$storage->{in_x} = 0; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
44
|
100
|
100
|
|
|
190
|
if ($storage->{in_graph_common} && $element_name !~ /^Data/i) |
96
|
|
|
|
|
|
|
{ |
97
|
5
|
|
|
|
|
14
|
$storage->{in_graph_common} = 0; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
44
|
100
|
100
|
|
|
163
|
if ($storage->{in_graph} && $element_name !~ /^Data/i) |
101
|
|
|
|
|
|
|
{ |
102
|
4
|
|
|
|
|
15
|
$self->_convert_graph(); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
# =for graph and =begin graph sections |
105
|
44
|
100
|
50
|
|
|
949
|
if ($element_name eq 'for' && ($attr->{target} || '') eq 'graph') |
|
|
|
100
|
|
|
|
|
106
|
|
|
|
|
|
|
{ |
107
|
7
|
|
|
|
|
14
|
$storage->{in_graph} = 1; |
108
|
7
|
|
|
|
|
17
|
$storage->{cur_graph} = ''; |
109
|
7
|
|
|
|
|
33
|
return; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# =for graph-common and =begin graph sections |
113
|
37
|
100
|
50
|
|
|
166
|
if ($element_name eq 'for' && ($attr->{target} || '') eq 'graph-common') |
|
|
|
66
|
|
|
|
|
114
|
|
|
|
|
|
|
{ |
115
|
5
|
|
|
|
|
13
|
$storage->{in_graph_common} = 1; |
116
|
5
|
|
|
|
|
14
|
$storage->{graph_common} = ''; |
117
|
5
|
|
|
|
|
23
|
return; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
32
|
100
|
|
|
|
141
|
if ($element_name =~ /^head/) |
121
|
|
|
|
|
|
|
{ |
122
|
7
|
|
|
|
|
15
|
push @{ $storage->{headlines} }, $element_name . ' '; |
|
7
|
|
|
|
|
22
|
|
123
|
7
|
|
|
|
|
16
|
$storage->{in_headline} = 1; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
32
|
|
|
|
|
144
|
$self->SUPER::_handle_element_start($element_name, $attr); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub _handle_element_end |
130
|
|
|
|
|
|
|
{ |
131
|
44
|
|
|
44
|
|
2122
|
my ($self, $element_name) = @_; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# print STDERR "end '$element_name'\n"; |
134
|
|
|
|
|
|
|
|
135
|
44
|
|
|
|
|
70
|
my $storage = $self->{_mediawiki_pod_html}; |
136
|
|
|
|
|
|
|
|
137
|
44
|
100
|
|
|
|
115
|
if ($element_name =~ /^head/) |
138
|
|
|
|
|
|
|
{ |
139
|
7
|
|
|
|
|
15
|
$storage->{in_headline} = 0; |
140
|
|
|
|
|
|
|
} |
141
|
44
|
100
|
|
|
|
105
|
if ($element_name eq 'Document') |
142
|
|
|
|
|
|
|
{ |
143
|
5
|
100
|
|
|
|
28
|
$self->_convert_graph() if $storage->{in_graph}; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
44
|
|
|
|
|
766
|
$self->SUPER::_handle_element_end($element_name); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub _handle_text { |
150
|
27
|
|
|
27
|
|
659
|
my ($self, $text) = @_; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# print STDERR "text '$text'\n"; |
153
|
|
|
|
|
|
|
|
154
|
27
|
|
|
|
|
46
|
my $storage = $self->{_mediawiki_pod_html}; |
155
|
27
|
100
|
|
|
|
84
|
if ($storage->{in_headline}) |
156
|
|
|
|
|
|
|
{ |
157
|
7
|
|
|
|
|
30
|
$storage->{headlines}->[-1] .= $text; |
158
|
|
|
|
|
|
|
} |
159
|
27
|
100
|
|
|
|
85
|
if ($storage->{in_graph}) |
160
|
|
|
|
|
|
|
{ |
161
|
11
|
|
|
|
|
26
|
$storage->{cur_graph} .= $text; |
162
|
11
|
|
|
|
|
31
|
return; |
163
|
|
|
|
|
|
|
} |
164
|
16
|
100
|
|
|
|
40
|
if ($storage->{in_graph_common}) |
165
|
|
|
|
|
|
|
{ |
166
|
5
|
|
|
|
|
12
|
$storage->{graph_common} .= $text; |
167
|
5
|
|
|
|
|
15
|
return; |
168
|
|
|
|
|
|
|
} |
169
|
11
|
50
|
|
|
|
28
|
if ($storage->{in_x}) |
170
|
|
|
|
|
|
|
{ |
171
|
0
|
|
|
|
|
0
|
my $url = $storage->{search}; |
172
|
0
|
|
|
|
|
0
|
my $t = $text; |
173
|
0
|
|
|
|
|
0
|
$t =~ s/&/∓/; |
174
|
0
|
|
|
|
|
0
|
$t =~ s/'/&squot;/; |
175
|
0
|
0
|
|
|
|
0
|
if ($url =~ /##KEYWORD##/) |
176
|
|
|
|
|
|
|
{ |
177
|
0
|
|
|
|
|
0
|
$url =~ s/##KEYWORD##/$t/g; |
178
|
0
|
0
|
|
|
|
0
|
$url =~ s/ /_/g unless defined $storage->{search_space}; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
else |
181
|
|
|
|
|
|
|
{ |
182
|
0
|
|
|
|
|
0
|
$url .= $t; |
183
|
0
|
0
|
|
|
|
0
|
$url =~ s/ /+/g unless defined $storage->{search_space}; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
# make spaces safe |
186
|
0
|
0
|
|
|
|
0
|
$url =~ s/ /$storage->{search_space}/g if defined $storage->{search_space}; |
187
|
0
|
|
|
|
|
0
|
$self->_my_output( "$text" ); |
188
|
0
|
|
|
|
|
0
|
return; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
11
|
|
|
|
|
49
|
$self->SUPER::_handle_text($text); |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub get_headlines |
195
|
|
|
|
|
|
|
{ |
196
|
5
|
|
|
5
|
1
|
20
|
my $self = shift; |
197
|
|
|
|
|
|
|
|
198
|
5
|
|
|
|
|
16
|
my $storage = $self->{_mediawiki_pod_html}; |
199
|
5
|
|
|
|
|
39
|
$storage->{headlines}; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub keyword_search_url |
203
|
|
|
|
|
|
|
{ |
204
|
1
|
|
|
1
|
1
|
467
|
my $self = shift; |
205
|
|
|
|
|
|
|
|
206
|
1
|
|
|
|
|
10
|
my $storage = $self->{_mediawiki_pod_html}; |
207
|
1
|
50
|
|
|
|
5
|
$storage->{search} = $_[0] if defined $_[0]; |
208
|
|
|
|
|
|
|
# can be undef, too |
209
|
1
|
50
|
|
|
|
4
|
$storage->{search_space} = $_[1] if defined @_ == 2; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
wantarray ? |
212
|
1
|
50
|
|
|
|
6
|
($storage->{search}, $storage->{search_space}) : $storage->{search}; |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub _my_output |
216
|
|
|
|
|
|
|
{ |
217
|
14
|
|
|
14
|
|
101945
|
my $self = shift; |
218
|
|
|
|
|
|
|
|
219
|
14
|
|
|
|
|
35
|
print {$self->{'output_fh'}} $_[0]; |
|
14
|
|
|
|
|
165
|
|
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
1; |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
__END__ |