AngleSharp / AngleSharp.Css

:angel: Library to enable support for cascading stylesheets in AngleSharp.
https://anglesharp.github.io
MIT License
72 stars 34 forks source link

Missing unit on 0 values #172

Open truthz03 opened 4 months ago

truthz03 commented 4 months ago

Prerequisites

Description

Hi, I'm currently using AngleSharp.Css 0.17.0 but I also tried it with 1.0.0-beta.139. My problem is that when I parse .fx-flex { flex: 1 1 0% !important } and write it back to a string the % sign is lost. But if the % sign is missing flex will do a completely different thing.

Is there anything to configure to get the needed behaviour?

Another strange behaviour is, that we use our software inside a Linux Docker container and as windows service, but the missing units will be only a problem on Windows.

Steps to Reproduce

var parser = new CssParser(new CssParserOptions()
{
    IsIncludingUnknownDeclarations = true,
    IsIncludingUnknownRules = true,
    IsToleratingInvalidSelectors = true
});
var css = parser.ParseStyleSheetAsync(".fx-flex{flex:1 1 0%!important}", CancellationToken.None).Result;
var sb = new StringBuilder();
using (var writer = new StringWriter(sb))
{
    css.ToCss(writer, AngleSharp.Css.CssStyleFormatter.Instance);
}
var newCssString = sb.ToString();

Expected Behavior

newCssString should be: .fx-flex { flex: 1 1 0% !important }

Actual Behavior

newCssString is: .fx-flex { flex: 1 1 0 !important }

Possible Solution / Known Workarounds

No response