-
Notifications
You must be signed in to change notification settings - Fork 128
Description
Hello, great project you all have worked on here.
I'm parsing scss files which works wonderfully for the css portions but drops out any properties/values that cannot be perfectly parsed, and I'd like to disable this strictness. I understand that this won't provide full support for less/scss syntax, but it would help drastically even with a few updates.
Update: There is a tolerateInvalidValues parameter in the StylesheetParser constructor method. Setting this to true handles the scss-variables issue (which is now in strikethrough markup).
For example, consider these properties and values:
.classname {
background: $bgColor;
font-size: $mediumFont;
}
Currently, the parsed .classname ruleblock will parse in ExCSS as if it's empty, simply because the values are preprocessor variables. For our purposes, it would be much better to store the invalid vanilla css value of $bgColor or $mediumFont in the parsed object instead of acting like the property doesn't even exist.
Remaining Issue
@include mixin-name-here; and @include mixin-with-params(12px, #000); statements are likewise completely dropped. I understand that importing mixin definition property values is outside the scope of this project, but again, I'd like the parse output to at least acknowledge that the @include statement is present. Can an .InvalidProperties or similar collection be added to each IStyleRule object, where @include or other preprocessor-specific statements can at least be recallable?
Lastly, there should be some way (even if using a custom CssStyleFormatter definition) to print out these invalid statements using this library's native .ToCss() method.
For invalid vanilla property values (like the variables in the first example), if the raw value is set inside the parsed property (eg. See font-size or background), then .ToCss() would function as expected without further modification. This functionality could of course be walled behind a boolean toggle, such as parser.HonorInvalidValues = true;.tolerateInvalidValues parameter info above
Thanks!