klen / python-scss

Python scss parser.

Home Page:http://packages.python.org/scss/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Immediate child selector (">") breaks parsing

opened this issue · comments

According to the docs, this should work:

.some-class {
  > div {
    color: white;
  }
}

However, the parser raises an error:

.some-class {
^
Expected end of text (at char 0), (line:1, col:1)

Simply removing the immediate child selector will make the parser not have any problems, however this then precludes the use of said selector.

This is python-scss version 0.8.71 on Fedora Core 13

TLDR; replace " > " with " >" (no space after greater than)

I tried to play with this a bit but I don't understand pyparsing enough to fix it. I tried a few test cases, and every time it would work if I was lazy, like "i>b{color: red}" and fail when I was not lazy, like "i > b { color: red }". After a bit of trial and error I found that the error is caused by "greater-than space". I then did a find and replace, removing every "> " with ">" and the problem went away. Note, the file I used contains 17 immediate child selectors, so it was tested with a variety of combinations. Hope that holds you over till they fix it.

I can reproduce that.

nav.top,
body > footer {
  color: #e7e7e7;
}

blows up complaining:

nav.top,
   ^
Expected end of text (at char 3), (line:1, col:4)

while this doesn't:

nav.top,
body >footer {
  color: #e7e7e7;
}

Another example:

body > footer {
  clear: both;
}

yields:

body > footer {
              ^
Expected end of text (at char 14), (line:1, col:15)

Even worse:

#foobar,
body > footer {
  clear: both;
}

This results in a misleading error message that doesn't even point to a certain line:

invalid literal for int() with base 16: 'fo'

This is quite annoying and hurts readability. Also, that's quite an adoption stopper (I encountered it before my stylesheet compiled even once; pyScss had no problem with this, BTW). Please fix this.

Sorry, I not supported python-scss anymore. Use https://github.com/Kronuz/pyScss