digitalsparky / jekyll-minifier

Jekyll HTML/XML/CSS/JS Minifier utilising yui-compressor, and htmlcompressor
GNU General Public License v3.0
244 stars 25 forks source link

Problem with calc() minify (bis) #54

Open pfdt opened 3 years ago

pfdt commented 3 years ago

CSS minifying is breaking calc() function removing the needed spaces. It the same problem explained here : https://github.com/digitalsparky/jekyll-minifier/issues/5

And still a problem in last version (0.1.10)

thetwopct commented 3 years ago

Also suffering same issue where spaces from the CSS calc() function are being removed making the style fail.

Example:

max-width: calc(100% + 40px);

is output as

max-width: calc(100%+40px);

which doesn't work. I have tried a "workaround"

max-width: calc(100% - - 40px);

which also doesn't work.

I've had to remove jekyll-minifier from my build.

wneessen commented 3 years ago

Ran into the same issue. Fixed it with this little patch:

--- vendor/bundle/ruby/2.6.0/gems/cssminify2-2.0.1/lib/cssminify2/cssmin-orig.rb    2021-02-20 22:16:46.000000000 +0100
+++ vendor/bundle/ruby/2.6.0/gems/cssminify2-2.0.1/lib/cssminify2/cssmin.rb 2021-02-20 22:16:41.000000000 +0100
@@ -212,2 +212,6 @@
     css = css.gsub(/(:|\s)0+\.(\d+)/) { "#{$1.to_s}.#{$2.to_s}" }
+
+    #
+    # Put space back between ' + ' i. e. in calc() operations
+    css = css.gsub(/\+/i, ' + ')
jordikitto commented 2 years ago

Any update on this? Still a big issue

tallcoleman commented 1 year ago

I also ran into this recently. Didn't appear to be an issue on Firefox, but broke on Edge and Safari because there wasn't space on both sides of a - operator. Was only able to fix it by turning CSS minification completely off in _config.yml.

TheEvilSkeleton commented 1 month ago

which doesn't work. I have tried a "workaround"

max-width: calc(100% - - 40px);

which also doesn't work.

I've had to remove jekyll-minifier from my build.

@thetwopct have you tried max-width: calc(100% - -40px); (remove the space after the second -)? This worked for me

For example: https://gitlab.com/TheEvilSkeleton/theevilskeleton.gitlab.io/-/commit/be3571f703dc70cbd792b6aece89791c3eff42cf#e5af3623409c270e77be92ef76ad4c5fda7764a7_24_28

Update: Apparently it doesn't work everywhere...