ABOUT
^^^^^
XcsParser is a XCS/CSS parsing and compression class for PHP5.
XCS stands for "eXtended Cascading Stylesheet".
"Extended", because XCS introduces several new concepts
and shorthands to CSS standard:
1) Global variables (e.g. '!foregroundColor = #333;');
2) Simple arythmetic operations on variables, and/or
integer constants ("simple" means only 2 operands allowed).
(e.g. '!width = !columnWidth * !numberOfColumns;')
(e.g. '!width = !columnWidth * 4;')
3) Complex expression handling, if allowed
(e.g. '!date = expr(date("Y:m:d"));')
4) Inline file inclusion, if allowed. This is different
from normal CSS file inclusion, as it is performed
in place (i.e. server-side), instead of client-side.
(e.g. '@require(variable_defines.css);')
5) Creating new CSS definitions by extending the
existing rules
(e.g. '.smalltext{font-size:0.8em} .smallredtext extends(.smalltext){color:red}')
6) Line comments syntax with '// ... '
(e.g. 'width: 120px; // this is a comment')
Of course, XCS syntax is optional, and the class can be used
for basic CSS prettyfying/compression alone. Depending on
compression flag set, the class will eiher:
1) Leave your CSS as-is.
2) Remove duplicated properties, alphabetize them
and, optionally, alphabetize rules as well.
3) Like 2), but will also strip any duplicated
newlines.
4) Like 3), but will also strip any CSS comments and
zap all whitespaces to a single ' '.
The class requires PHP5, and will not work with PHP4.
All overridable `private` members are declared `protected`, so
one could easily extend the class to meet her particular needs
(e.g. to pre-populate options and flags in order to avoid
in-script option setting). By changing internal regexen, one
could also tweak XCS syntax to her liking. For more on this,
see included examples.
Included example scripts:
../examples/basic.php - Basic usage example.
../examples/static.php - Static loader usage example.
../examples/inherit.php - Class inheritance usage example.
../examples/noexpr.php - Forbidden `expr()` syntax example.
../examples/norequire.php - Forbidden `@require()` syntax example.
../examples/compression.php - Various compression/prettyfying examples.
../examples/syntax.php - XCS syntax changing advanced examples.
AUTHOR AND LICENSE IFORMATION
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
My name is Ve Bailovity, and you can reach me at
malatestapunk@gmail.com. If you find a bug or need help
of any kind, please don't hesitate to do so.
I don't really know much about legal stuff. Use this as
you see fit. For more info and an exception to this,
see 'LICENSE.txt' file included with the release. |