Is there a library out there that will allow me to write the following kind of code, which parses CSS and returns a queryable object model
string input = "p, span { font-family: arial; }";
var cssRules = new Parser().Parse(input);
var rule = cssRules.Find(new Selector("p")).First();
Assert.That(rule.Attribute("font-family").Value, Is.Equal.To("arial"));
I've taken a look at dotless, downloaded their code and examined some of the relevant unit tests and fixtures. It looks promising but I can't quite work out how to use it to parse and query plain CSS.
The closest I know is CssParser from jsonfx.net:
http://css-parser.googlecode.com/svn/trunk/CssParser/
You can parse any css and browse through selectors afterwards using StyleSheet property of CssParser
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With