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
25
26         # parse some CSS from a string
27         $css->read_string( $css_data );
28         $css->read_string( ( $css_data, $more_css_data ) );
29
30         # parse some CSS from a file
31         $css->read_file( 'my_file.css' );
32         $css->read_file( ( 'my_file.css', 'my_other_file.css' ) );
33
34
35
36         # output the CSS using the current adaptor
37         print $css->output();
38
39         # set a new adaptor and then output the CSS
40         $css->set_adaptor( 'CSS::Adaptor::Foo' );
41         print $css->output();
42
43         # output the CSS using a tempory adaptor
44         print $css->output( 'CSS::Adaptor::Bar' );
45
46
47
48         # forget about the CSS we've already parsed
49         $css->purge();
50

DESCRIPTION

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

NOTICE

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

TREE STRUCTURE

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

METHODS

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

AUTHORS

112       Copyright (C) 2001-2002, Allen Day <allenday@ucla.edu>
113
114       Copyright (C) 2003-2004, Cal Henderson <cal@iamcal.com>
115

SEE ALSO

117       CSS::Style, CSS::Selector, CSS::Property, CSS::Value, CSS::Parse,
118       CSS::Parse::Lite, CSS::Parse::Heavy, CSS::Parse::Compiled,
119       CSS::Parse::PRDGrammar, CSS::Adaptor, CSS::Adaptor::Pretty,
120       CSS::Adaptor::Debug, perl(1)
121
122
123
124perl v5.36.0                      2022-07-22                            CSS(3)
Impressum