Kronuz / pyScss

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

CSS selector with ':' #273

Closed ninfaj closed 10 years ago

ninfaj commented 10 years ago

Hi there! It's not possible (or I didn't find out how) to define a CSS selector for elements with a ':' or '\3A' (CSS) in the class (for example <div class="width1:4">test</div>).

python
from scss import Scss
compiler = Scss()
compiler.compile('div.width1\3A 4 {width: 25%;}')

This will return

div\x03A.width1 4 {
  width: 25%;
}

But imho it should return

div.width1\3A 4 {
  width: 25%;
}

Is there a possibility to escape the \?

eevee commented 10 years ago

Well, your example doesn't escape the \, so you're putting a literal 0x03 byte in that string, which is doing funny things.

But I'm not sure how this could possibly work anyway; : marks the beginning of a pseudo-selector. Even as plain CSS, does any browser interpret this as you expect?

You might be able to get away with div[class~="width1:4"], but you'll have a much easier time if you just use a hyphen.

ninfaj commented 10 years ago

Thanks for your answer. The styling works if I insert div.width1\3A 4 as CSS. Well the problem is, it's not me defining css classes like that, there are other packages, such as plone.app.theming for example (https://github.com/plone/plone.app.theming/blob/master/src/plone/app/theming/browser/mapper.pt#L874) I've just "solved" the problem by other selectors to get these elements. Btw. this package is awesome! :smiley: