rennat / pynliner

Python CSS-to-inline-styles conversion tool for HTML using BeautifulSoup and cssutils
http://pythonhosted.org/pynliner/
180 stars 93 forks source link

complex CSS selectors #8

Open rennat opened 13 years ago

rennat commented 13 years ago

Pynliner currently fails to apply the selector element#id.class.

Other selectors that fail include adjacent sibling (a + b) and child (a > b) selectors as well as pseudo selectors (not sure if pseudo selectors should be included... thoughts anyone?)

adam-p commented 11 years ago

+1 for pseudo selectors. I found out that they're not supported when I tried to zebra-stripe a table with :nth-child.

5p4k commented 10 years ago

Also :not( ) isn't supported. Pynliner fails raising an exception: https://github.com/rennat/pynliner/blob/master/pynliner/soupselect.py#L103. Until pseudo selectors get supported, I suggest Pynliner to ignore them instead of failing: a partial result is better than none. Besides, the selector could be included in a css file but not actually match any tag.

rennat commented 10 years ago

I think we should support pseudo selectors. Also any errors should log warning but continue rendering the remaining selectors. These are good improvements to make and I'm sure I'll get to them eventually but I'll also accept pull requests!

p-himik commented 8 years ago

Why is not a bug anymore? It fails to apply even a selector like .class1.class2. classes = re.findall('\.([a-zA-Z0-9_-]+)', token) in soupselect.py is definitely not a correct way to do it.

rennat commented 8 years ago

@p-himik , If you have some HTML and CSS that isn't being handled correctly, the most productive thing you can do here is to fork this repository and add a test showing the failure then open a pull request. I'll pull in failing tests if they highlight problems in pynliner so we can fix them.

p-himik commented 8 years ago

Created #46