1CSS(3)                User Contributed Perl Documentation               CSS(3)
2
3
4

NAME

6       CSS - Object oriented access to Cascading Style Sheets (CSS)
7

SYNOPSIS

9         use CSS;
10
11         # create a CSS object with the default options
12         my $css = CSS->new();
13
14         # create a CSS object with a specific parser
15         my $css = CSS->new( { 'parser' => 'CSS::Parse::Lite' } );
16         my $css = CSS->new( { 'parser' => 'CSS::Parse::Heavy' } );
17         my $css = CSS->new( { 'parser' => 'CSS::Parse::Compiled' } );
18
19         # create a CSS object with a specific adaptor
20         my $css = CSS->new( { 'adaptor' => 'CSS::Adaptor' } );
21         my $css = CSS->new( { 'adaptor' => 'CSS::Adaptor::Pretty' } );
22         my $css = CSS->new( { 'adaptor' => 'CSS::Adaptor::Debug' } );
23
24         # parse some CSS from a string
25         $css->read_string( $css_data );
26         $css->read_string( ( $css_data, $more_css_data ) );
27
28         # parse some CSS from a file
29         $css->read_file( 'my_file.css' );
30         $css->read_file( ( 'my_file.css', 'my_other_file.css' ) );
31
32         # output the CSS using the current adaptor
33         print $css->output();
34
35         # set a new adaptor and then output the CSS
36         $css->set_adaptor( 'CSS::Adaptor::Foo' );
37         print $css->output();
38
39         # output the CSS using a tempory adaptor
40         print $css->output( 'CSS::Adaptor::Bar' );
41
42         # forget about the CSS we've already parsed
43         $css->purge();
44

DESCRIPTION

46       This module can be used, along with a CSS::Parse::* module, to parse
47       CSS data and represent it as a tree of objects. Using a CSS::Adaptor::*
48       module, the CSS data tree can then be transformed into other formats.
49

NOTICE

51       From version 1.00 of this module onwards, backwards compatibility is
52       broken. This is due to large changes in the way data is parsed and then
53       represented internally. Version 0.08 is still available on CPAN:
54       <http://search.cpan.org/author/IAMCAL/CSS-0.08/>
55

TREE STRUCTURE

57       The CSS object is the head of the tree. It contains a list of
58       CSS::Style objects which each represent a CSS ruleset. Each of these
59       objects contains a list of selectors and properties. Each selector is
60       stored as a CSS::Selector object. Each property object is stored as a
61       CSS::Property object and contains a list of values. These values are
62       stored as CSS::Value objects.
63
64         foo, bar {
65             baz: fop;
66             woo: yay houpla;
67         }
68
69       The above example would be represented as a single CSS::Style object.
70       That object would then have two CSS::Selector objects representing
71       'foo' and 'bar'. It would also have two CSS::Property objects repre‐
72       senting 'baz' and 'woo'. The 'baz' object then has a single child
73       CSS::Value object for 'fop', whilst the 'woo' object has two child
74       objects for 'yay' and 'houpla'.
75

METHODS

77       CONSTRUCTOR
78
79       "new()" or "new( { ..options.. } )"
80           An optional hash can contain arguments:
81
82             parser        module to use as the CSS parser
83             adaptor       adaptor to use for output
84
85       ACCESSORS
86
87       "read_file( $filename )" or "read_file( @filenames )"
88           Read one or mores files and parse the CSS within them.
89
90       "read_string( $scalar )" or "read_string( @strings )"
91           Read one or more strings and parse the CSS within them.
92
93       "output()" or "output( 'CSS::Adaptor::Foo' )"
94           Return a string representation of the CSS tree, using either the
95           current adaptor or the specified one.
96
97       "set_adaptor( 'CSS::Adaptor::Bar' )"
98           Set the current adaptor for the CSS tree.
99
100       "purge()"
101           Forget all the objects in the CSS tree;
102
103       "get_style_by_selector( 'selector_name' )"
104           Returns the first CSS::Style object with the specified selector
105           name attached. Returns zero on failure.
106

AUTHORS

108       Copyright (C) 2001-2002, Allen Day <allenday@ucla.edu>
109
110       Copyright (C) 2003-2004, Cal Henderson <cal@iamcal.com>
111

SEE ALSO

113       CSS::Style, CSS::Selector, CSS::Property, CSS::Value, CSS::Parse,
114       CSS::Parse::Lite, CSS::Parse::Heavy, CSS::Parse::Compiled,
115       CSS::Parse::PRDGrammar, CSS::Adaptor, CSS::Adaptor::Pretty, CSS::Adap‐
116       tor::Debug, perl(1)
117
118
119
120perl v5.8.8                       2008-04-22                            CSS(3)
Impressum