[dev] CSS Parsing class
Michael M Slusarz
slusarz at horde.org
Tue Mar 19 04:40:01 UTC 2013
There's been talk on the mailing lists recently about the limitations
of the current Horde_Text_Filter_Csstidy package (essentially a
wrapper around the unmaintained PHP csstidy code).
By fortuitous chance, the same issue came up with one of my clients.
Thus, plenty of impetus to look into replacing the library with a new
library.
Turns out there is a stable, CSS3 compliant, stateful, object oriented
PHP parser that exists and is favorably licensed (MIT/Expat license):
https://github.com/sabberworm/PHP-CSS-Parser
It turned out to be fairly easy to write a new Horde wrapper around
this class (Horde_Css_Parser;
https://github.com/horde/horde/commit/8fe7c6a52443ceab1a3c2a7e4b364f6ba005e059). And the results seem to work beautifully. Haven't played around much more than parsing the existing CSS code, but this code handles the issues requiring us to parse CSS in the first place: relative URL translation and @import
replacement.
As such, there is no reason to delay making the change, especially
considering the alternative (csstidy) is known to be broken in
multiple respects. This code has been around for several years and
stability looks good at a minimum, there are a good bit of
forks/stars of the code on github so it tells me this code is being
used on a daily basis by others.
michael
___________________________________
Michael Slusarz [slusarz at horde.org]
More information about the dev
mailing list