Kozea/tinycss2

parse css to ast tree

Closed this issue · 2 comments

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))
liZe commented

@djn3m0 Feel free to reopen if you need anything.