Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  CSS::INLINER::PARSER (3)

.ds Aq ’


CSS::Inliner::Parser - Interface through which to read/write CSS files while respecting the cascade order

NOTE: This sub-module very seriously focuses on respecting cascade order. As such this module is not for you
if you want to modified a stylesheet once it’s read. If you are looking for that functionality you may
want to look at the sister module, CSS::Simple



 use CSS::Inliner::Parser;

 my $css = new CSS::Inliner::Parser();

 $css->read({ filename => input.css });

 #perform manipulations...

 $css->write({ filename => output.css });


Class for reading and writing CSS. Unlike other CSS classes on CPAN this particular module focuses on respecting the order of selectors. This is very useful for things like... inlining CSS, or for similar strict CSS work.


new ([ OPTIONS ]) Instantiates the CSS::Inliner::Parser object. Sets up class variables that are used during file parsing/processing.

<B>warns_as_errorsB> (optional). Boolean value to indicate whether fatal errors should occur during parse failures.


read_file( params ) Opens and reads a CSS file, then subsequently performs the parsing of the CSS file necessary for later manipulation.

This method requires you to pass in a params hash that contains a filename argument. For example:

$self->read_file({ filename => ’myfile.css’ });

read( params ) Reads css data and parses it. The intermediate data is stored in class variables.

Compound selectors (i.e. a, span) are split apart during parsing and stored separately, so the output of any given stylesheet may not match the output 100%, but the rules themselves should apply as expected.

This method requires you to pass in a params hash that contains scalar css data. For example:

$self->read({ css => $css });

write_file() Write the parsed and manipulated CSS out to a file parameter

This method requires you to pass in a params hash that contains a filename argument. For example:

$self->write_file({ filename => ’myfile.css’ });

write() Write the parsed and manipulated CSS out to a scalar and return it

This code makes some assumptions about the nature of the prelude and data portions of the stored css rules and possibly is insufficient.

content_warnings() Return back any warnings thrown while parsing a given block of css

Note: content warnings are initialized at read time. In order to receive back content feedback you must perform read() first.

get_rules( params ) Get an array of rules representing the composition of the stylesheet. These rules are returned in the exact order that they were discovered. Both qualified and at rules are returned by this method. It is left to the caller to pull out the kinds of rules your application needs to accomplish your goals.

The structures returned match up with the fields set while adding the rules via the add_x_rule collection methods.

Specifically at-rules will contain a type, prelude and block while qualified rules will contain a selector and declarations.

add_qualified_rule( params ) Add a qualified CSS rule to the ruleset store.

The most common type of CSS rule is a qualified rule. This term became more prominent with the rise of CSS3, but is still relevant when handling earlier versions of the standard. These rules have a prelude consisting of a CSS selector, along with a data block consisting of various rule declarations.

Adding a qualified rule is trivial, for example: $self->add_qualified_rule({ selector => ’p > a’, block => ’color: blue;’ });

add_at_rule( params ) Add an at-rule to the ruleset store.

The less common variants of CSS rules are know as at-rules. These rules implement various behaviours through various expressions containing a rule type, prelude and associated data block. The standard is evolving here, so it is not easy to enumerate such examples, but these rules always start with @.

At rules are a little more complex, an example: $self->add_at_rule({ type => ’@media’, prelude => ’print’, block => ’body { font-size: 10pt; }’ });


This code has been developed under sponsorship of MailerMailer LLC,


Kevin Kamel <>


This module is directly based off of Adam Kennedy’s <> CSS::Tiny module.

This particular version differs in terms of interface and the ultimate ordering of the CSS.


This module is a derived version of Adam Kennedy’s CSS::Tiny Module.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 CSS::INLINER::PARSER (3) 2015-05-16

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.