Cerdic/CSSTidy

Add a script to run it from command line as C++ csstidy drop in replacement

etienned opened this issue · 5 comments

I was using the CSSTidy C++ version to compress my CSS but this version had problem with format in @font-face. After taking a quick look to your up to date PHP version, I was thinking that this problem was fix in it (actually it's not fix, check my next issue).

So, I decided to use it instead of the C++ one. But I needed to call from the command line (like the C++ version) because I'm using it through django_compressor. The solution was to write a script to run it from the command line. I tried to do it in way that it will be mostly a drop in replacement of the C++ version.

You can found my script here: https://gist.github.com/2789689

It's NOT well tested and I don't think I will put more work on it because I can't use your CSSTidy PHP version for the moment. But feel free to do whatever you want with it, just keep my name in the credits please.

N.B.: I should add that the PHP and C++ versions are not totally equivalent. If I'm not wrong, the C++ version remove duplicate properties like this:

.duplicate{
    display: none;
    display: none;
}

The PHP version don't do that. I saw other differences like quotation around @font-face font-family name, etc.

I'm also interested in this for vim equalprg and will be taking a closer look.

Any progress on this? It would be very useful and the css_parser.php as mentioned in the README doesn't exist ;)

I confirm, C++ and PHP are not exactly the same software. Original team work on both but not as the same time. PHP version always be released a little earlier than the C++ version. C++ is at least as important as PHP since an executable file is more versatile than a PHP script. A CLI version may be an interesting way.

Also would like to request this. For the tool to gain greater acceptance, it seems to me that a CLI script or program would be a very welcomed and useful addition.

A brand new command line script is now available in the bin/ directory
https://github.com/Cerdic/CSSTidy/blob/master/bin/pcsstidy

Took some inspiration in the proposal from @etienned but decided to not try to mimic the (super) old C++ script and go for something clean and with default values sticked to the csstidy class default values.