line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CSS::Parse::Lite; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = 1.02; |
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
3501
|
use CSS::Parse; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
193
|
|
6
|
|
|
|
|
|
|
@ISA = qw(CSS::Parse); |
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
31
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
150
|
|
9
|
6
|
|
|
6
|
|
28
|
use warnings; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
135
|
|
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
6
|
|
31
|
use Carp; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
442
|
|
12
|
6
|
|
|
6
|
|
32
|
use CSS::Style; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
149
|
|
13
|
6
|
|
|
6
|
|
31
|
use CSS::Selector; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
138
|
|
14
|
6
|
|
|
6
|
|
28
|
use CSS::Property; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
8903
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# The main parser |
17
|
|
|
|
|
|
|
sub parse_string { |
18
|
7
|
|
|
7
|
0
|
11
|
my $self = shift; |
19
|
7
|
|
|
|
|
15
|
my $string = shift; |
20
|
|
|
|
|
|
|
|
21
|
7
|
|
|
|
|
121
|
$string =~ s/\r\n|\r|\n/ /g; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Split into styles |
24
|
7
|
|
|
|
|
123
|
foreach ( grep { /\S/ } split /(?<=\})/, $string ) { |
|
27
|
|
|
|
|
84
|
|
25
|
20
|
50
|
|
|
|
136
|
unless ( /^\s*([^{]+?)\s*\{(.*)\}\s*$/ ) { |
26
|
0
|
|
|
|
|
0
|
croak( "Invalid or unexpected style data '$_'" ); |
27
|
|
|
|
|
|
|
} |
28
|
20
|
|
|
|
|
43
|
$self->add_style($1, $2); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# add a style to the style list |
33
|
|
|
|
|
|
|
sub add_style { |
34
|
20
|
|
|
20
|
0
|
30
|
my $self = shift; |
35
|
20
|
|
|
|
|
39
|
my $style = shift; |
36
|
20
|
|
|
|
|
38
|
my $contents = shift; |
37
|
|
|
|
|
|
|
|
38
|
20
|
|
|
|
|
113
|
my $style_obj = new CSS::Style({ |
39
|
|
|
|
|
|
|
'adaptor' => $self->{parent}->{adaptor} |
40
|
|
|
|
|
|
|
}); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# parse the selectors |
43
|
20
|
|
|
|
|
91
|
for(split(/\s*,\s*/, $style)){ |
44
|
35
|
|
|
|
|
167
|
my $selector_obj = new CSS::Selector({'name' => $_}); |
45
|
35
|
|
|
|
|
103
|
$style_obj->add_selector($selector_obj); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# parse the properties |
49
|
20
|
|
|
|
|
67
|
foreach ( grep { /\S/ } split /\;/, $contents ) { |
|
40
|
|
|
|
|
163
|
|
50
|
31
|
50
|
|
|
|
186
|
unless ( /^\s*([\w._-]+)\s*:\s*(.*?)\s*$/ ) { |
51
|
0
|
|
|
|
|
0
|
croak( "Invalid or unexpected property '$_' in style '$style'" ); |
52
|
|
|
|
|
|
|
} |
53
|
31
|
|
|
|
|
239
|
my $property_obj = new CSS::Property({ |
54
|
|
|
|
|
|
|
'property' => $1, |
55
|
|
|
|
|
|
|
'value' => $2, |
56
|
|
|
|
|
|
|
'adaptor' => $style_obj->{adaptor}, |
57
|
|
|
|
|
|
|
}); |
58
|
31
|
|
|
|
|
88
|
$style_obj->add_property($property_obj); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
20
|
|
|
|
|
34
|
push @{$self->{parent}->{styles}}, $style_obj; |
|
20
|
|
|
|
|
127
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
CSS::Parse::Lite - A CSS::Parse module using regular expressions |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SYNOPSIS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
use CSS; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Create a css stylesheet |
77
|
|
|
|
|
|
|
my $CSS = CSS->new({'parser' => 'CSS::Parse::Lite'}); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 DESCRIPTION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This module is a parser for CSS.pm. Read the CSS.pm pod for more details |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Copyright (C) 2003-2004, Cal Henderson <cal@iamcal.com> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SEE ALSO |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
L<CSS>, http://www.w3.org/TR/REC-CSS1 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |