Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google fonts @import url() raises SelectorSyntaxError in parse_simple_selector #25

Closed
mxdubois opened this issue May 2, 2013 · 4 comments

Comments

@mxdubois
Copy link

mxdubois commented May 2, 2013

Got this error: Expected selector, got <NUMBER '700' at 0>

I think it was caused by this line in my css:
@import url('https://fonts.googleapis.com/css?family=Lato:400,700,400italic|Signika:400,700');

I'm using premailer which uses your library.

@SimonSapin
Copy link
Contributor

Hi. @import rules have nothing to do with selectors. Are you sure this is about cssselect rather than tinycss?

Anyway, could you provide sample code to reproduce the issue, and a full traceback?

@SimonSapin
Copy link
Contributor

Ok, it appears that you’re asking cssselect to parse something that is not a Selector at all, which as expected gives a syntax error. I think the bug is in your code, which should do a better job at recognizing what is a style rule or not. This might be related to the fact that you’re parsing CSS with regexps. This is about parsing HTML, but I think it applies equally well here.

Consider using an actual CSS parser like tinycss. With tinycss you can test if some_rule.at_keyword is None: … to only pick style rules (as opposed to at-rules such as @import.)

@SimonSapin
Copy link
Contributor

Sorry for the mix up. By "you" in the previous message I mean premailer.

@mxdubois
Copy link
Author

mxdubois commented May 2, 2013

Haha. Np. So it's an issue with premailer's parsing. Your library's not supposed to handle @import. I'll file an issue over there then and link them here for reference to your comments.

Thanks for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants