noprompt / garden

Generate CSS with Clojure
1.35k stars 90 forks source link

Complex media queries and pretty-print? false #168

Closed roosta closed 5 years ago

roosta commented 5 years ago

First of thanks for making Garden, its been my goto CSS library for a long time . That said I think I located a bug with pretty print and media queries. A query like this for example:

(css {:pretty-print? false} (at-media {:screen :only :min-width "32em"} [:.some-class {:width "33rem"}]))

produces this CSS:

@media only screen and(min-width:32em){.some-class{width:33rem}}

The media query is not applied due to missing whitespace after and.

roosta commented 5 years ago

Forgot to mention my env is cljs. Found this regexp in compression.cljc :r-paren #"^\s*\(\s*", seems it gobbles up whitespace before a literal paren match. I also see that there is a :space+ regexp that seems to match literal space? Maybe there's a way to have the space after and detected as :space+?

noprompt commented 5 years ago

Thanks for the bug report and having a look into possible solutions. It’s been a while since I’ve worked with that code and I’ll take a look into the issue. You’re proposed solution seems like it’s on the right track though.