tubalmartin / YUI-CSS-compressor-PHP-port

A PHP port of the YUI CSS compressor.
230 stars 34 forks source link

calc whitespace not always preserved #22

Closed futtta closed 7 years ago

futtta commented 9 years ago

An Autoptimize-user has CSS with a calc in it which gets broken. Whereas YUI-CSS-compressor-PHP-port normally preserves spaces, it does not in this case (confirmed using GUI)

Test input; input { width: calc(100% - (1em*1.5)); }

Expected output: input{width:calc(100% - (1em*1.5))}

Actual Output: input{width:calc(100% -(1em*1.5))}

Frank

futtta commented 9 years ago

improved fix; https://github.com/futtta/YUI-CSS-compressor-PHP-port/commit/5cadbf1dcced636c87a44cb519c398f50a0bc71a

rostik commented 8 years ago

seems like it fixes "- (" but not ") -"

futtta commented 8 years ago

can you try with this commit @rostik ?

rostik commented 8 years ago

@futtta that didnt work, but i did this, not sure if its correct, but it worked

$this->preserved_tokens[] = preg_replace('/([+-]{1})(/','/$1 (/',trim(pregreplace('/\s([_\/(),])/', '$1', $matches[2])));

futtta commented 8 years ago

yeah, had a stupid mistake in my code (forgot re-replacing $calc by $matches[2]) cfr. this commit.

can you try again?

rostik commented 8 years ago

this works. thanks! @futtta

futtta commented 8 years ago

great, thanks for testing & confirming! :-)

sambolek commented 7 years ago

Can this fix be implemented into the mainline please?

tubalmartin commented 7 years ago

Thank you for the fix. I'll release it this week ;)

futtta commented 7 years ago

great to see you're back @tubalmartin :-)

tubalmartin commented 7 years ago

Fixed in v2.4.8-p7 release. Thank you guys!