.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "CSS 3pm" .TH CSS 3pm "2020-12-29" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CSS \- Object oriented access to Cascading Style Sheets (CSS) .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use CSS; \& \& # create a CSS object with the default options \& my $css = CSS\->new(); \& \& # create a CSS object with a specific parser \& my $css = CSS\->new( { \*(Aqparser\*(Aq => \*(AqCSS::Parse::Lite\*(Aq } ); \& my $css = CSS\->new( { \*(Aqparser\*(Aq => \*(AqCSS::Parse::Heavy\*(Aq } ); \& my $css = CSS\->new( { \*(Aqparser\*(Aq => \*(AqCSS::Parse::Compiled\*(Aq } ); \& \& # create a CSS object with a specific adaptor \& my $css = CSS\->new( { \*(Aqadaptor\*(Aq => \*(AqCSS::Adaptor\*(Aq } ); \& my $css = CSS\->new( { \*(Aqadaptor\*(Aq => \*(AqCSS::Adaptor::Pretty\*(Aq } ); \& my $css = CSS\->new( { \*(Aqadaptor\*(Aq => \*(AqCSS::Adaptor::Debug\*(Aq } ); \& \& \& \& # parse some CSS from a string \& $css\->read_string( $css_data ); \& $css\->read_string( ( $css_data, $more_css_data ) ); \& \& # parse some CSS from a file \& $css\->read_file( \*(Aqmy_file.css\*(Aq ); \& $css\->read_file( ( \*(Aqmy_file.css\*(Aq, \*(Aqmy_other_file.css\*(Aq ) ); \& \& \& \& # output the CSS using the current adaptor \& print $css\->output(); \& \& # set a new adaptor and then output the CSS \& $css\->set_adaptor( \*(AqCSS::Adaptor::Foo\*(Aq ); \& print $css\->output(); \& \& # output the CSS using a tempory adaptor \& print $css\->output( \*(AqCSS::Adaptor::Bar\*(Aq ); \& \& \& \& # forget about the CSS we\*(Aqve already parsed \& $css\->purge(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module can be used, along with a CSS::Parse::* module, to parse \&\s-1CSS\s0 data and represent it as a tree of objects. Using a CSS::Adaptor::* module, the \s-1CSS\s0 data tree can then be transformed into other formats. .SH "NOTICE" .IX Header "NOTICE" From version 1.00 of this module onwards, backwards compatibility is broken. This is due to large changes in the way data is parsed and then represented internally. Version 0.08 is still available on \&\s-1CPAN:\s0 .SH "TREE STRUCTURE" .IX Header "TREE STRUCTURE" The \s-1CSS\s0 object is the head of the tree. It contains a list of CSS::Style objects which each represent a \s-1CSS\s0 ruleset. Each of these objects contains a list of selectors and properties. Each selector is stored as a CSS::Selector object. Each property object is stored as a CSS::Property object and contains a list of values. These values are stored as CSS::Value objects. .PP .Vb 4 \& foo, bar { \& baz: fop; \& woo: yay houpla; \& } .Ve .PP The above example would be represented as a single CSS::Style object. That object would then have two CSS::Selector objects representing \&'foo' and 'bar'. It would also have two CSS::Property objects representing 'baz' and 'woo'. The 'baz' object then has a single child CSS::Value object for 'fop', whilst the 'woo' object has two child objects for 'yay' and 'houpla'. .SH "METHODS" .IX Header "METHODS" .SS "\s-1CONSTRUCTOR\s0" .IX Subsection "CONSTRUCTOR" .ie n .IP """new()"" or ""new( { ..options.. } )""" 4 .el .IP "\f(CWnew()\fR or \f(CWnew( { ..options.. } )\fR" 4 .IX Item "new() or new( { ..options.. } )" An optional hash can contain arguments: .Sp .Vb 2 \& parser module to use as the CSS parser \& adaptor adaptor to use for output .Ve .SS "\s-1ACCESSORS\s0" .IX Subsection "ACCESSORS" .ie n .IP """read_file( $filename )"" or ""read_file( @filenames )""" 4 .el .IP "\f(CWread_file( $filename )\fR or \f(CWread_file( @filenames )\fR" 4 .IX Item "read_file( $filename ) or read_file( @filenames )" Read one or mores files and parse the \s-1CSS\s0 within them. .ie n .IP """read_string( $scalar )"" or ""read_string( @strings )""" 4 .el .IP "\f(CWread_string( $scalar )\fR or \f(CWread_string( @strings )\fR" 4 .IX Item "read_string( $scalar ) or read_string( @strings )" Read one or more strings and parse the \s-1CSS\s0 within them. .ie n .IP """output()"" or ""output( \*(AqCSS::Adaptor::Foo\*(Aq )""" 4 .el .IP "\f(CWoutput()\fR or \f(CWoutput( \*(AqCSS::Adaptor::Foo\*(Aq )\fR" 4 .IX Item "output() or output( CSS::Adaptor::Foo )" Return a string representation of the \s-1CSS\s0 tree, using either the current adaptor or the specified one. .ie n .IP """set_adaptor( \*(AqCSS::Adaptor::Bar\*(Aq )""" 4 .el .IP "\f(CWset_adaptor( \*(AqCSS::Adaptor::Bar\*(Aq )\fR" 4 .IX Item "set_adaptor( CSS::Adaptor::Bar )" Set the current adaptor for the \s-1CSS\s0 tree. .ie n .IP """purge()""" 4 .el .IP "\f(CWpurge()\fR" 4 .IX Item "purge()" Forget all the objects in the \s-1CSS\s0 tree; .ie n .IP """get_style_by_selector( \*(Aqselector_name\*(Aq )""" 4 .el .IP "\f(CWget_style_by_selector( \*(Aqselector_name\*(Aq )\fR" 4 .IX Item "get_style_by_selector( selector_name )" Returns the first CSS::Style object with the specified selector name attached. Returns zero on failure. .SH "AUTHORS" .IX Header "AUTHORS" Copyright (C) 2001\-2002, Allen Day .PP Copyright (C) 2003\-2004, Cal Henderson .SH "SEE ALSO" .IX Header "SEE ALSO" CSS::Style, CSS::Selector, CSS::Property, CSS::Value, CSS::Parse, CSS::Parse::Lite, CSS::Parse::Heavy, CSS::Parse::Compiled, CSS::Parse::PRDGrammar, CSS::Adaptor, CSS::Adaptor::Pretty, CSS::Adaptor::Debug, \fBperl\fR\|(1)