line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::DoCoMoCSS; |
2
|
2
|
|
|
2
|
|
628
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
65
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
50
|
|
4
|
2
|
|
|
2
|
|
855
|
use CSS::Tiny::Style; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use CSS::Tiny; |
6
|
|
|
|
|
|
|
use File::Spec; |
7
|
|
|
|
|
|
|
use Carp; |
8
|
|
|
|
|
|
|
use HTML::Selector::XPath 'selector_to_xpath'; |
9
|
|
|
|
|
|
|
use XML::LibXML; |
10
|
|
|
|
|
|
|
use XML::LibXML::XPathContext; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
|
|
|
|
|
|
my $class = shift; |
16
|
|
|
|
|
|
|
my %args = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
unless (exists $args{base_dir}) { |
19
|
|
|
|
|
|
|
croak "base_dir is required"; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
bless {%args}, $class; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub apply { |
26
|
|
|
|
|
|
|
my ($self, $content) = @_; |
27
|
|
|
|
|
|
|
croak "HTML::DoCoMoCSS->apply is instance method" unless ref $self; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# escape Numeric character reference. |
30
|
|
|
|
|
|
|
$content =~ s/(\d+);/HTMLCSSINLINERESCAPE$1::::::::/g; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $xml = XML::LibXML->new(); |
33
|
|
|
|
|
|
|
my $doc = $xml->parse_string($content); |
34
|
|
|
|
|
|
|
my $xc = XML::LibXML::XPathContext->new($doc); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $root = $doc->documentElement(); |
37
|
|
|
|
|
|
|
my $namespace = $root->getAttribute('xmlns'); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $namespace_prefix = ''; |
40
|
|
|
|
|
|
|
if ( $namespace ) { |
41
|
|
|
|
|
|
|
# xhtml |
42
|
|
|
|
|
|
|
$xc->registerNs('x', $namespace); |
43
|
|
|
|
|
|
|
$namespace_prefix = 'x:'; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# read css from |