line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CSS::Adaptor::Pretty; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = 1.01; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use CSS::Adaptor; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
6
|
|
|
|
|
|
|
@ISA = ('CSS::Adaptor'); |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
9
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
214
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub output_rule { |
12
|
1
|
|
|
1
|
1
|
2
|
my ($self, $rule) = @_; |
13
|
1
|
|
|
|
|
4
|
return $rule->selectors." {\n".$rule->properties."}\n\n" ; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub output_properties { |
17
|
1
|
|
|
1
|
1
|
2
|
my ($self, $properties) = @_; |
18
|
1
|
|
|
|
|
2
|
my $longest_prop = 0; |
19
|
1
|
|
|
|
|
1
|
for(@{$properties}){ |
|
1
|
|
|
|
|
4
|
|
20
|
1
|
50
|
|
|
|
4
|
if (length($_->{property}) > $longest_prop){ |
21
|
1
|
|
|
|
|
3
|
$longest_prop = length($_->{property}); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
1
|
|
|
|
|
4
|
my $tabs = int (($longest_prop + 1)/8); |
25
|
1
|
|
|
|
|
2
|
return join("", map { |
26
|
1
|
|
|
|
|
2
|
my $sp = "\t"; |
27
|
1
|
|
|
|
|
3
|
my $this = int ((length($_->{property}) + 1)/8); |
28
|
1
|
|
|
|
|
3
|
$sp .= "\t" x ($tabs - $this); |
29
|
1
|
|
|
|
|
8
|
"\t".$_->{property}.":".$sp.$_->values.";\n"; |
30
|
1
|
|
|
|
|
2
|
} @{$properties}); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
CSS::Adaptor::Pretty - An example adaptor for pretty-printing CSS. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 SYNOPSIS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
use CSS; |
44
|
|
|
|
|
|
|
... |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 DESCRIPTION |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
This class implements a CSS::Adaptor object to display a |
49
|
|
|
|
|
|
|
stylesheet in a 'pretty' style. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 AUTHORS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Copyright (C) 2003-2004, Cal Henderson <cal@iamcal.com> |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 SEE ALSO |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
L<CSS>, L<CSS::Adaptor> |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |