tinycss
tinycss copied to clipboard
A way of getting a ruleset by element/class
Hi there, just wondering if you ever considered something that could help one get the styles for a certain element and/or class from the list of rules.. say if I have a parsed stylesheet, and want to know what styles would apply to ".foo" or "p#bar" - even at a very crude level of exact matching, without any inheritance, overwriting etc..
Cheers
No. This is out of scope for a parser. But you might want to have a look at cssselect as well as how to use it with tinycss.
See also how WeasyPrint implements the full CSS cascade based on cssselect and tinycss, or how CairoSVG does it somewhat simplified.