AngleSharp / AngleSharp.Css

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

Parsing CSS shorthand property containing variable as value #171

Open csiga00 opened 3 months ago

csiga00 commented 3 months ago

Prerequisites

Description

I'm using version 1.0.0-alpha-99.

I try to replace CSS variables with actual value in a html file (I have a pdf export tool that can't handle css variables in the pre-generated html). I'm playing with AngleSharp(.Css) to parse the html file and see what can I do with it. First of all, I parsed the html content and checked the parsed style objects. I noticed, that if a variable is used in a shorthand css property, Value is empty in all the longhand properties, even the simple ones (e.g 1px or solid, etc). If I parse a single css property (one of the longhand) with variable, Value is set correctly.

Sorry, if this is not a bug, but by design or if I'm using AngleSharp in the wrong way. I'm really new to it and I might have missed something.

Thanks for help!

Steps to Reproduce

new AngleSharp.Css.Parser.CssParser(new AngleSharp.Css.Parser.CssParserOptions() { IsIncludingUnknownDeclarations = true, IsIncludingUnknownRules = true, IsToleratingInvalidSelectors = true }).ParseDeclaration("border-bottom: 1px solid var(--pale-grey);")

new AngleSharp.Css.Parser.CssParser(new AngleSharp.Css.Parser.CssParserOptions() { IsIncludingUnknownDeclarations = true, IsIncludingUnknownRules = true, IsToleratingInvalidSelectors = true }).ParseDeclaration("border-bottom-color: var(--pale-grey);")

The same happens if I examine a document loaded with the following code, that contains a