line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Presto::Client::ContentHandlers::HTML; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:MPERRY'; |
3
|
|
|
|
|
|
|
$App::Presto::Client::ContentHandlers::HTML::VERSION = '0.010'; |
4
|
|
|
|
|
|
|
# ABSTRACT: Handles deserializing of HTML responses |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
397
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
7
|
|
|
|
|
|
|
my $HAS_HTML_FORMATTEXT_WITHLINKS; |
8
|
|
|
|
|
|
|
BEGIN { |
9
|
1
|
|
|
1
|
|
220
|
eval 'use HTML::FormatText::WithLinks; $HAS_HTML_FORMATTEXT_WITHLINKS = 1;' |
|
1
|
|
|
1
|
|
276
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub can_deserialize { |
13
|
1
|
|
|
1
|
0
|
399
|
my $self = shift; |
14
|
1
|
|
|
|
|
1
|
my $content_type = shift; |
15
|
1
|
50
|
|
|
|
6
|
return unless $HAS_HTML_FORMATTEXT_WITHLINKS; |
16
|
0
|
|
|
|
|
|
return $content_type =~ m{^text/html}i; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub deserialize { |
20
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
21
|
0
|
|
|
|
|
|
my $content = shift; |
22
|
0
|
|
|
|
|
|
my $text; |
23
|
0
|
0
|
0
|
|
|
|
eval { $text = HTML::FormatText::WithLinks->format_string($content) || 1 } or do { |
|
0
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
warn "Unable to parse HTML: $@"; |
25
|
|
|
|
|
|
|
}; |
26
|
0
|
|
|
|
|
|
return $text; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
0
|
0
|
|
sub can_serialize { 0 } |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__END__ |