parse css to ast tree
Closed this issue · 2 comments
djn3m0 commented
Hello,
I want to parse a given CSS code and get ast tree of that code and finally convert that ast tree back to code!
I found some AST related functionality but I cannot find any example code to use them. Can you please give me some example of the AST functionalities?
Thank you
liZe commented
I'm a bit late, but… Are you looking for serialize
?
import tinycss2
nodes = tinycss2.parse_stylesheet("div { background: red }")
print(tinycss2.serialize(nodes))