Prerequisites
Description
I want to extract text and style from an html document, but when I try to use element.ComputeCurrentStyle().GetColor(), it throws an exception.
Steps to Reproduce
using var angle = AngleSharp.BrowsingContext.New();
var parser = angle.GetService<IHtmlParser>()!;
using var doc = await parser.ParseDocumentAsync("<div>hi</div>");
Console.WriteLine(doc.QuerySelector("div").ComputeCurrentStyle().GetColor());
Expected Behavior
Outputs null or a default color.
Actual Behavior
AngleSharp.Css.Dom.CssStyleDeclaration
System.InvalidOperationException: Sequence contains no elements
at System.Linq.ThrowHelper.ThrowNoElementsException()
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
at AngleSharp.BrowsingContextExtensions.GetFactory[TFactory](IBrowsingContext context)
at AngleSharp.Css.Dom.CssStyleDeclaration.TryCreateShorthand(String shorthandName, IEnumerable`1 serialized, List`1 usedProperties, Boolean force)
at AngleSharp.Css.Dom.CssStyleDeclaration.GetPropertyShorthand(String name)
at AngleSharp.Css.Dom.CssStyleDeclaration.GetProperty(String name)
at AngleSharp.Css.Dom.CssStyleDeclaration.GetPropertyValue(String propertyName)
at AngleSharp.Css.Dom.StyleDeclarationExtensions.GetColor(ICssStyleDeclaration style)
Possible Solution / Known Workarounds
Is there a way to assign a default color to the document so it can fall back to it when no color is assigned to the elements?
Is there a way to have some browser default styles be loaded? Even manually?
Prerequisites
AngleSharp.Xmlfor Xml support)Description
I want to extract text and style from an html document, but when I try to use
element.ComputeCurrentStyle().GetColor(), it throws an exception.Steps to Reproduce
Expected Behavior
Outputs
nullor a default color.Actual Behavior
Possible Solution / Known Workarounds
Is there a way to assign a default color to the document so it can fall back to it when no color is assigned to the elements?
Is there a way to have some browser default styles be loaded? Even manually?