Closed jddantes closed 7 years ago
I managed to reproduce it with:
html = """
<html>
<style>
*,:after,:before{box-sizing:inherit}
h1{ border: 1px solid blue}
h1:hover {border: 1px solid green}
</style>
<h1>Hey</h1>
</html>
"""
What happens is that the selector
in the parsed rules becomes an empty string.
Running the same script above gives a similar error:
WARNING Property: Unknown Property name. [1:24: -ms-text-size-adjust]
WARNING Property: Unknown Property name. [1:50: -webkit-text-size-adjust]
WARNING Property: Unknown Property name. [1:197: font-smoothing]
ERROR Property: Invalid value for "CSS Level 2.1" property: calc(2rem - 0.142857em) 0 1rem [1:89: margin]
ERROR Property: Invalid value for "CSS Level 2.1" property: 1rem [1:1: min-height]
ERROR Property: Invalid value for "CSS Level 2.1" property: 2rem [1:17: font-size]
Traceback (most recent call last):
File "prem.py", line 18, in <module>
print(p.transform())
File "/home/jddantes/.conda/envs/pulse/lib/python3.6/site-packages/premailer/premailer.py", line 409, in transform
sel = CSSSelector(selector)
File "/home/jddantes/.conda/envs/pulse/lib/python3.6/site-packages/lxml/cssselect.py", line 94, in __init__
path = translator.css_to_xpath(css)
File "/home/jddantes/.conda/envs/pulse/lib/python3.6/site-packages/cssselect/xpath.py", line 192, in css_to_xpath
for selector in parse(css))
File "/home/jddantes/.conda/envs/pulse/lib/python3.6/site-packages/cssselect/parser.py", line 355, in parse
return list(parse_selector_group(stream))
File "/home/jddantes/.conda/envs/pulse/lib/python3.6/site-packages/cssselect/parser.py", line 370, in parse_selector_group
yield Selector(*parse_selector(stream))
File "/home/jddantes/.conda/envs/pulse/lib/python3.6/site-packages/cssselect/parser.py", line 378, in parse_selector
result, pseudo_element = parse_simple_selector(stream)
File "/home/jddantes/.conda/envs/pulse/lib/python3.6/site-packages/cssselect/parser.py", line 477, in parse_simple_selector
"Expected selector, got %s" % (peek,))
cssselect.parser.SelectorSyntaxError: Expected selector, got <NUMBER '.500' at 6>
Tried running this script:
but it crashes and returns:
premailer==3.0.0 lxml==3.8.0