line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Feature; |
2
|
6
|
|
|
6
|
|
3271
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
191
|
|
3
|
6
|
|
|
6
|
|
31
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
165
|
|
4
|
6
|
|
|
6
|
|
3190
|
use HTML::Feature::FrontParser; |
|
6
|
|
|
|
|
20
|
|
|
6
|
|
|
|
|
53
|
|
5
|
6
|
|
|
6
|
|
3647
|
use HTML::Feature::Engine; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use base qw(HTML::Feature::Base); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors($_) for qw(_front_parser _engine); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '3.00011'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
|
|
|
|
|
|
my $class = shift; |
14
|
|
|
|
|
|
|
my %args = @_; |
15
|
|
|
|
|
|
|
my $self = $class->SUPER::new( config => \%args ); |
16
|
|
|
|
|
|
|
$self->_setup; |
17
|
|
|
|
|
|
|
return $self; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub parse { |
21
|
|
|
|
|
|
|
my $self = shift; |
22
|
|
|
|
|
|
|
my $whatever = shift; |
23
|
|
|
|
|
|
|
my $url = shift; |
24
|
|
|
|
|
|
|
my $html = $self->front_parser->parse($whatever); |
25
|
|
|
|
|
|
|
if ( !$url and $self->{base_url} ) { |
26
|
|
|
|
|
|
|
$url = $self->{base_url}; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
my $result = $self->engine->run( \$html, $url ); |
29
|
|
|
|
|
|
|
return $result; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub parse_url { |
33
|
|
|
|
|
|
|
my $self = shift; |
34
|
|
|
|
|
|
|
$self->parse(@_); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub parse_response { |
38
|
|
|
|
|
|
|
my $self = shift; |
39
|
|
|
|
|
|
|
$self->parse(@_); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub parse_html { |
43
|
|
|
|
|
|
|
my $self = shift; |
44
|
|
|
|
|
|
|
$self->parse(@_); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _setup { |
48
|
|
|
|
|
|
|
my $self = shift; |
49
|
|
|
|
|
|
|
$self->front_parser( HTML::Feature::FrontParser->new( context => $self ) ); |
50
|
|
|
|
|
|
|
$self->engine( HTML::Feature::Engine->new( context => $self ) ); |
51
|
|
|
|
|
|
|
if ( !$self->{not_encode} ) { |
52
|
|
|
|
|
|
|
$self->{enc_type} ||= "utf8"; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
#--- |
57
|
|
|
|
|
|
|
# accessor methods |
58
|
|
|
|
|
|
|
#--- |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub front_parser { |
61
|
|
|
|
|
|
|
my $self = shift; |
62
|
|
|
|
|
|
|
my $args = shift; |
63
|
|
|
|
|
|
|
if ( !$args ) { |
64
|
|
|
|
|
|
|
$self->_front_parser; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
else { |
67
|
|
|
|
|
|
|
$self->_front_parser($args); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub engine { |
72
|
|
|
|
|
|
|
my $self = shift; |
73
|
|
|
|
|
|
|
my $args = shift; |
74
|
|
|
|
|
|
|
if ( !$args ) { |
75
|
|
|
|
|
|
|
$self->_engine; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
else { |
78
|
|
|
|
|
|
|
$self->_engine($args); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
__END__ |