tinycss icon indicating copy to clipboard operation
tinycss copied to clipboard

Modify parsed CSS?

Open stodge opened this issue 9 years ago • 1 comments

While parsing a CSS file I'd like to convert any colours from "white" or "#FFF" to "#FFFFFF". I tried modifying the token's value accordingly but calling as_css() doesn't appear to show the change. Is it possible at all to modify the parsed CSS?

Thanks

stodge avatar Jul 15 '16 14:07 stodge

tinycss doesn’t actually have a serializer. Its as_css method only returns a slice of the original CSS input, which is stored in Token._as_css.

I suggest trying https://github.com/SimonSapin/tinycss2 which does have a proper serializer.

SimonSapin avatar Jul 15 '16 14:07 SimonSapin