Kronuz / pyScss

pyScss, a Scss compiler for Python
MIT License
582 stars 141 forks source link

Empty list syntax not supported #166

Closed eevee closed 10 years ago

eevee commented 11 years ago

From ye Ruby reference:

Lists can also have no items in them at all. These lists are represented as (). They can’t be output directly to CSS; if you try to do e.g. font-family: (), Sass will raise an error. If a list contains empty lists or null values, as in 1px 2px () 3px or 1px 2px null 3px, the empty lists and null values will be removed before the containing list is turned into CSS.

That last part isn't handled correctly, either.

rsternagel commented 11 years ago

Is it sufficient to change these lines within scss.types.List.render:

return delim.join(
    item.render(compress=compress)
    for item in self.value
)

into:

return delim.join(
    item.render(compress=compress)
    for item in self.value
    if not isinstance(item, Null) and len(item)
)
eevee commented 11 years ago

No, the parser needs to be made aware of this too.

clarabstract commented 11 years ago

So out of "I just really need this to work now"-desperation, I ended up adding a (terrible, inexcusable) monkey-patch for the above code (except using if item.value != "()" as the guard). I also set a __version__ check to remind me to get rid of it in 1.3+. It does seem to fix my immediate problem (linear-gradient not working in bourbon).

I understand this is not a complete solution... but is it just a matter of it missing certain instances (I'm still seeing ()s, but nothing that affects me so far) or am I likely to have broken something more subtle?

eevee commented 11 years ago

Any code that tries to treat () as a list (e.g. append((), $value) to get a one-element list) will be a little confused, because the parser still thinks () is a string. But that's uncommon in my experience, so if it fixes the problem for you, it's probably fine :)

eevee commented 10 years ago

I accidentally fixed this! Neat.