line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PerlIO::via::StripHTML; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.008; |
4
|
1
|
|
|
1
|
|
19769
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
64
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
6
|
1
|
|
|
1
|
|
4003
|
use HTML::Parser 3.00; |
|
1
|
|
|
|
|
7362
|
|
|
1
|
|
|
|
|
303
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = 0.04; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub PUSHED { |
11
|
1
|
|
|
1
|
0
|
1490
|
my ($class, $mode) = @_; |
12
|
1
|
50
|
|
|
|
5
|
return -1 if $mode ne 'r'; |
13
|
|
|
|
|
|
|
# The following variables are updated / accessed via the closures below |
14
|
1
|
|
|
|
|
3
|
my $buffer = ''; # internal buffer for this layer |
15
|
1
|
|
|
|
|
3
|
my %inside = (); |
16
|
|
|
|
|
|
|
bless { |
17
|
2
|
|
|
2
|
|
13
|
buffer => sub : lvalue { $buffer }, |
18
|
|
|
|
|
|
|
parser => new HTML::Parser( |
19
|
|
|
|
|
|
|
api_version => 3, |
20
|
|
|
|
|
|
|
marked_sections => 1, |
21
|
|
|
|
|
|
|
start_h => [ |
22
|
|
|
|
|
|
|
sub { |
23
|
9
|
100
|
|
9
|
|
38
|
$buffer .= "\n" if $_[0] =~ /^[bt]r$/; |
24
|
9
|
50
|
|
|
|
19
|
$buffer .= "\n\n" if $_[0] eq 'p'; |
25
|
9
|
|
|
|
|
38
|
++$inside{$_[0]}; |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
'tagname', |
28
|
|
|
|
|
|
|
], |
29
|
|
|
|
|
|
|
end_h => [ |
30
|
7
|
|
|
7
|
|
25
|
sub { --$inside{$_[0]} }, |
31
|
|
|
|
|
|
|
'tagname', |
32
|
|
|
|
|
|
|
], |
33
|
|
|
|
|
|
|
text_h => [ |
34
|
|
|
|
|
|
|
sub { |
35
|
17
|
100
|
66
|
17
|
|
112
|
$buffer .= $_[0] unless $inside{script} || $inside{style}; |
36
|
|
|
|
|
|
|
}, |
37
|
1
|
|
|
|
|
27
|
'dtext', |
38
|
|
|
|
|
|
|
], |
39
|
|
|
|
|
|
|
), |
40
|
|
|
|
|
|
|
}, $class; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub FILL { |
44
|
2
|
|
|
2
|
0
|
180
|
my ($self, $fh) = @_; |
45
|
2
|
|
|
|
|
34
|
my $line = <$fh>; |
46
|
2
|
100
|
|
|
|
11
|
return undef unless defined $line; |
47
|
1
|
|
|
|
|
9
|
$self->{buffer}->() = ''; |
48
|
1
|
50
|
|
|
|
23
|
$self->{parser}->parse($line) or return undef; |
49
|
1
|
|
|
|
|
5
|
$self->{parser}->eof; |
50
|
1
|
|
|
|
|
4
|
return $self->{buffer}->(); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |