cssparser.js
cssparser.js copied to clipboard
Option to include comments in json output
One use case is for documentation. For example, at the top of each CSS file I might include a title and a description. The JSON could then be used to output that meta information along with the actual CSS.
Thanks for the request! I agree to your opinion.
I also wanted supporting comments
, however, I was troubled because there is something difficult to solve. As we know, comments blocks can be located at anywhere in CSS. So, sometimes it's difficult to put comments informations into JSON:
/* field decorator */
.my-field {
padding-left: 1em; /* left padding */
/* background color */
background-color: /* don't fix this */ #fff /* white */
}
I know this is ugly example. but, it's possible. :/ If you have any idea to handle these cases, please let me know. :) Thanks! :)
Do you you mean it would be difficult to construct JSON from the example above or that its difficult to parse?
In any case what I wanted to do was use the comments for documentation, where the source would look like:
/*
# My Thing
This component does x, y, and z.
*/
.my-thing {
padding-left: 1em;
}
Here only the comments at the root level would be captured, though I could see that may be too specific a use case for this script.
Okay. I'll include this feature in the next release. :)