ndparker / rcssmin

Fast CSS minifier for Python
http://opensource.perlig.de/rcssmin/
Apache License 2.0
50 stars 11 forks source link

Issues with nested CSS #17

Open geoffrey-eisenbarth opened 2 weeks ago

geoffrey-eisenbarth commented 2 weeks ago

Given the css

css = """
  .box {
    & :is(ol) {
      margin: 0;
    }
  }
"""

then rendercss(css) outputs .box{&:is(ol){margin:0}} which is not the correct selector: there needs to be a space between the ampersand and the colon.

I'm not sure if this style of css is incorrect, so I'm all ears if I need to be doing something else. Thank you for the great package!

ndparker commented 1 week ago

Hi,

thanks for the report. I don't follow the CSS specs, really, but it seems that's a new feature I need to look at.

geoffrey-eisenbarth commented 1 week ago

I haven't looked into the specifics of how this library works yet, but it's likely that & is being recognized as a binary operator and not a selector.

Thanks! If there's anything I can do to help move this along, please let me know. I'd love to help out however I can.

ndparker commented 1 week ago

Hi,

it's basically a huge regex with benefits :-). The & wasn't recognized at all. It wasn't special. I've started working on it in this branch: https://github.com/ndparker/rcssmin/tree/issue-17 . The python/regex version seems to be fixed (I've added a test case, but maybe try it out), the C version still needs to follow.

Cheers,

ndparker commented 5 days ago

The C version also seems to work. If you have the chance please check it out.