1CSS(3) User Contributed Perl Documentation CSS(3)
2
3
4
6 CSS - Object oriented access to Cascading Style Sheets (CSS)
7
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
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
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 <http://search.cpan.org/author/IAMCAL/CSS-0.08/>
62
64 The CSS object is the head of the tree. It contains a list of
65 CSS::Style objects which each represent a CSS ruleset. Each of these
66 objects contains a list of selectors and properties. Each selector is
67 stored as a CSS::Selector object. Each property object is stored as a
68 CSS::Property object and contains a list of values. These values are
69 stored as CSS::Value objects.
70
71 foo, bar {
72 baz: fop;
73 woo: yay houpla;
74 }
75
76 The above example would be represented as a single CSS::Style object.
77 That object would then have two CSS::Selector objects representing
78 'foo' and 'bar'. It would also have two CSS::Property objects
79 representing 'baz' and 'woo'. The 'baz' object then has a single child
80 CSS::Value object for 'fop', whilst the 'woo' object has two child
81 objects for 'yay' and 'houpla'.
82
84 CONSTRUCTOR
85 "new()" or "new( { ..options.. } )"
86 An optional hash can contain arguments:
87
88 parser module to use as the CSS parser
89 adaptor adaptor to use for output
90
91 ACCESSORS
92 "read_file( $filename )" or "read_file( @filenames )"
93 Read one or mores files and parse the CSS within them.
94
95 "read_string( $scalar )" or "read_string( @strings )"
96 Read one or more strings and parse the CSS within them.
97
98 "output()" or "output( 'CSS::Adaptor::Foo' )"
99 Return a string representation of the CSS tree, using either the
100 current adaptor or the specified one.
101
102 "set_adaptor( 'CSS::Adaptor::Bar' )"
103 Set the current adaptor for the CSS tree.
104
105 "purge()"
106 Forget all the objects in the CSS tree;
107
108 "get_style_by_selector( 'selector_name' )"
109 Returns the first CSS::Style object with the specified selector
110 name attached. Returns zero on failure.
111
113 Copyright (C) 2001-2002, Allen Day <allenday@ucla.edu>
114
115 Copyright (C) 2003-2004, Cal Henderson <cal@iamcal.com>
116
118 CSS::Style, CSS::Selector, CSS::Property, CSS::Value, CSS::Parse,
119 CSS::Parse::Lite, CSS::Parse::Heavy, CSS::Parse::Compiled,
120 CSS::Parse::PRDGrammar, CSS::Adaptor, CSS::Adaptor::Pretty,
121 CSS::Adaptor::Debug, perl(1)
122
123
124
125perl v5.12.0 2008-04-23 CSS(3)