line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::Spell; |
2
|
5
|
|
|
5
|
|
353406
|
use 5.008; |
|
5
|
|
|
|
|
58
|
|
3
|
5
|
|
|
5
|
|
31
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
111
|
|
4
|
5
|
|
|
5
|
|
21
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
1329
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.24'; # TRIAL |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
6
|
|
|
6
|
1
|
7295
|
my ( $class, %args ) = @_; |
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
|
|
22
|
my $no_wide_chars = delete $args{no_wide_chars}; |
12
|
6
|
50
|
|
|
|
21
|
my $debug = exists $args{debug} ? delete $args{debug} : $ENV{PERL_POD_SPELL_DEBUG}; |
13
|
|
|
|
|
|
|
|
14
|
6
|
|
33
|
|
|
21
|
my $stopwords = $args{stopwords} || do { |
15
|
|
|
|
|
|
|
require Pod::Wordlist; |
16
|
|
|
|
|
|
|
Pod::Wordlist->new( |
17
|
|
|
|
|
|
|
_is_debug => $debug, |
18
|
|
|
|
|
|
|
no_wide_chars => $no_wide_chars |
19
|
|
|
|
|
|
|
) |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
6
|
|
|
|
|
576
|
my $parser = Pod::Spell::_Processor->new; |
23
|
6
|
|
|
|
|
33
|
$parser->stopwords($stopwords); |
24
|
6
|
|
|
|
|
54
|
$parser->_is_debug($debug); |
25
|
6
|
|
|
|
|
51
|
$parser->output_fh(\*STDOUT); |
26
|
|
|
|
|
|
|
|
27
|
6
|
|
|
|
|
42
|
my %self = ( |
28
|
|
|
|
|
|
|
processor => $parser, |
29
|
|
|
|
|
|
|
stopwords => $stopwords, |
30
|
|
|
|
|
|
|
debug => $debug, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
6
|
|
|
|
|
27
|
bless \%self, $class |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
2
|
100
|
|
2
|
|
292
|
sub _is_debug { (shift)->{debug} ? 1 : 0; } |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
1
|
1
|
36
|
sub stopwords { (shift)->{stopwords} } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub parse_from_file { |
41
|
0
|
|
|
0
|
1
|
0
|
shift->{processor}->parse_from_file(@_) |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub parse_from_filehandle { |
45
|
4
|
|
|
4
|
1
|
1742
|
shift->{processor}->parse_from_file(@_) |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
package # Hide from indexing |
49
|
|
|
|
|
|
|
Pod::Spell::_Processor; |
50
|
5
|
|
|
5
|
|
777
|
use parent 'Pod::Simple'; |
|
5
|
|
|
|
|
525
|
|
|
5
|
|
|
|
|
27
|
|
51
|
|
|
|
|
|
|
|
52
|
5
|
|
|
5
|
|
135391
|
use Text::Wrap (); |
|
5
|
|
|
|
|
11697
|
|
|
5
|
|
|
|
|
2752
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__PACKAGE__->_accessorize(qw( |
55
|
|
|
|
|
|
|
stopwords |
56
|
|
|
|
|
|
|
_is_debug |
57
|
|
|
|
|
|
|
)); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub new { |
60
|
6
|
|
|
6
|
|
15
|
my $class = shift; |
61
|
6
|
|
|
|
|
45
|
my $self = $class->SUPER::new(@_); |
62
|
6
|
|
|
|
|
178
|
$self->accept_targets('stopwords'); |
63
|
6
|
|
|
|
|
124
|
return $self; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my %track_elements = ( |
67
|
|
|
|
|
|
|
for => 1, |
68
|
|
|
|
|
|
|
Verbatim => 1, |
69
|
|
|
|
|
|
|
L => 1, |
70
|
|
|
|
|
|
|
C => 1, |
71
|
|
|
|
|
|
|
F => 1, |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _handle_element_start { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
75
|
38
|
|
|
38
|
|
12843
|
my ($self, $element_name, $attr) = @_; |
76
|
|
|
|
|
|
|
$self->{buffer} = '' |
77
|
38
|
100
|
|
|
|
101
|
if !defined $self->{buffer}; |
78
|
|
|
|
|
|
|
|
79
|
38
|
100
|
|
|
|
99
|
if ($track_elements{$element_name}) { |
80
|
13
|
|
|
|
|
19
|
push @{ $self->{in_element} }, [ $element_name, $attr ]; |
|
13
|
|
|
|
|
38
|
|
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _handle_text { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
85
|
36
|
|
|
36
|
|
272
|
my ($self, $text) = @_; |
86
|
|
|
|
|
|
|
|
87
|
36
|
|
|
|
|
49
|
my $in = $self->{in_element}; |
88
|
36
|
100
|
100
|
|
|
109
|
if ($in && @$in) { |
89
|
14
|
|
|
|
|
18
|
my ($element_name, $attr) = @{$in->[-1]}; |
|
14
|
|
|
|
|
27
|
|
90
|
|
|
|
|
|
|
## no critic (ControlStructures::ProhibitCascadingIfElse) |
91
|
14
|
100
|
66
|
|
|
62
|
if ($element_name eq 'for' && $attr->{target_matching} eq 'stopwords') { |
|
|
100
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# this will match both for/begin and stopwords/:stopwords |
93
|
|
|
|
|
|
|
|
94
|
6
|
50
|
|
|
|
16
|
print "Stopword para: <$text>\n" |
95
|
|
|
|
|
|
|
if $self->_is_debug; |
96
|
6
|
|
|
|
|
226
|
$self->stopwords->learn_stopwords($text); |
97
|
6
|
|
|
|
|
21
|
return; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
# totally ignore verbatim sections |
100
|
|
|
|
|
|
|
elsif ($element_name eq 'Verbatim') { |
101
|
1
|
|
|
|
|
3
|
return; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
elsif ($element_name eq 'L') { |
104
|
|
|
|
|
|
|
return |
105
|
1
|
50
|
|
|
|
6
|
if $attr->{'content-implicit'}; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
elsif ($element_name eq 'C' || $element_name eq 'F') { |
108
|
|
|
|
|
|
|
# maintain word boundaries |
109
|
6
|
100
|
|
|
|
18
|
my $pre = $text =~ s{\A\s+}{} ? ' ' : ''; |
110
|
6
|
100
|
|
|
|
18
|
my $post = $text =~ s{\s+\z}{} ? ' ' : ''; |
111
|
|
|
|
|
|
|
# if _ is joined with text before or after, it will be treated as |
112
|
|
|
|
|
|
|
# a Perl token and the entire word ignored |
113
|
6
|
50
|
|
|
|
18
|
$text = $pre . (length $text ? '_' : '') . $post; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
28
|
|
|
|
|
72
|
$self->{buffer} .= $text; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub _handle_element_end { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
121
|
38
|
|
|
38
|
|
819
|
my ($self, $element_name) = @_; |
122
|
|
|
|
|
|
|
|
123
|
38
|
|
|
|
|
52
|
my $in = $self->{in_element}; |
124
|
38
|
100
|
100
|
|
|
153
|
if ($in && @$in && $in->[-1][0] eq $element_name) { |
|
|
|
100
|
|
|
|
|
125
|
13
|
|
|
|
|
18
|
pop @$in; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
return |
129
|
38
|
100
|
|
|
|
139
|
if $element_name !~ m{\A(?:Para|head\d|item-.*|over-block)\z}; |
130
|
|
|
|
|
|
|
|
131
|
18
|
|
|
|
|
31
|
my $buffer = delete $self->{buffer}; |
132
|
18
|
100
|
66
|
|
|
75
|
if (!defined $buffer || !length $buffer) { |
133
|
3
|
|
|
|
|
27
|
return; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
15
|
|
|
|
|
38
|
my $fh = $self->output_fh; |
137
|
|
|
|
|
|
|
|
138
|
15
|
|
|
|
|
91
|
my $out = $self->stopwords->strip_stopwords($buffer); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# maintain exact output of older Pod::Parser based implementation |
141
|
15
|
100
|
|
|
|
38
|
print { $fh } "\n" |
|
4
|
|
|
|
|
38
|
|
142
|
|
|
|
|
|
|
if $element_name ne 'Para'; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
return |
145
|
15
|
100
|
|
|
|
38
|
if !length $out; |
146
|
|
|
|
|
|
|
|
147
|
12
|
|
|
|
|
20
|
local $Text::Wrap::huge = 'overflow'; ## no critic ( Variables::ProhibitPackageVars ) |
148
|
12
|
|
|
|
|
25
|
print { $fh } Text::Wrap::wrap( '', '', $out ) . "\n\n"; |
|
12
|
|
|
|
|
47
|
|
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
1; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
__END__ |