-
Notifications
You must be signed in to change notification settings - Fork 188
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
add trusted pseudo-classes argument #39
base: master
Are you sure you want to change the base?
Conversation
@@ -96,11 +104,13 @@ def __init__(self, html, base_url=None, | |||
include_star_selectors=False, | |||
remove_classes=True, | |||
strip_important=True, | |||
external_styles=None): | |||
external_styles=None, | |||
trusted_pseudoclasses=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the word "trusted". If that's the parameter name I'd expect the value to be a list of pseudo classes. Like:
trusted_pseudoclasses=[':foo', ':bar']
...or something.
Perhaps you mean to call it trust_pseudoclasses=False
which would make it a verb.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note how the parameter in that same signature is exclude_pseudoclasses
. "verb_noun"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would it be False
by default?
Looking at your added unit test, it looks like a really useful feature that isn't controversial.
The reason exclude_pseudoclasses
is True
by default is because you can't keep pseudo classes in style attributes so keeping them is kinda silly.
Your code has diverged from master. Can you rebase up your code and push back into the pull request? |
I rebase code, fix
|
Great work! I'm currently a bit swamped as tomorrow is the start of the new quarter but I've starred this on my todo list and I'll try to see what I can do to make it work again. |
@@ -8,7 +8,7 @@ | |||
|
|||
import cssutils | |||
from lxml import etree | |||
from lxml.cssselect import CSSSelector | |||
from lxml.cssselect import CSSSelector, SelectorError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What version of lxml added SelectorError
?
Once we know that setup.py needs to be modified and look something like lxml>=x.y.z
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SelectorError
available in lxml=>3.0
version.
Test fail quite hard. Would you mind looking at that first? |
It useful to wide cssselect pseudo-classes support like `:not()`, `:nth-child()`, `:nth-last-child`, `:nth-of-type()`, `:nth-last-of-type()` and etc. For this case pseudo-classes as `:hover`, `:active` and etc. will processed but not left in style attribute, so you must use for this `keep_style_tags` argument.
As I said before issue in code I created issue for PS. I fixed |
Any chance we can revive this? |
It useful to wide cssselect pseudo-classes support like
:not()
,:nth-child()
,:nth-last-child
,:nth-of-type()
,:nth-last-of-type()
and etc. For this case pseudo-classes as:hover
,:active
and etc. will processed but not left in style attribute, so you must use for thiskeep_style_tags
argument.