PHP-CSS-Parser icon indicating copy to clipboard operation
PHP-CSS-Parser copied to clipboard

Add option to keep comments in output

Open eternoendless opened this issue 7 years ago • 1 comments

At @PrestaShop we want to use this library to help us programmatically transform a bunch of CSS files into right-to-left. Our problem is, the license block included in our CSS files was being lost after the process.

Unless I'm mistaken, the Parser is able to read comments into the syntax tree, but they are always ignored when rendering the output CSS.

The main goal of this change is to make it possible to keep comments in the output CSS, at least the ones located at root level of the original CSS.

With that in mind, this PR adds an option setKeepComments in OutputFormat which allows toggling this feature on and off (off by default)/

Code is mostly whitespace and comments. I followed PSR-2 on some classes, sorry. Feel free to change it back to your standards if you decide to merge it.

For a clutter-free review I suggest looking at https://github.com/sabberworm/PHP-CSS-Parser/commit/9e23f77d2131fd2f11897ca10c806cf6287eb121, which contains the main change.

eternoendless avatar Dec 28 '17 13:12 eternoendless