CSSTree - An ultra-simple CSS parser
I needed something to parse a bunch of CSS and gave me a manipulatable object. I tried a couple parsers and none of them worked. It wasn’t that they didn’t do everything I needed, they just flat out didn’t work at all.
So then I made CSSTree. It’s dead-simple and does next to nothing. Other than parsing CSS that is.
tree = CSSTree.parse("body { color: #000000; }") # => #<CSSTree:0x000000> tree.find("body").color # => "#000000" tree.find("body").margin = "10px" # => "10px" tree.render # => "body { color: #000000; margin: 10px; }
And that’s pretty much it. Go team!