Skip to content

Numerical font-weight not parsed correctly in font shorthand #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mganss opened this issue May 22, 2020 · 2 comments
Closed

Numerical font-weight not parsed correctly in font shorthand #56

mganss opened this issue May 22, 2020 · 2 comments

Comments

@mganss
Copy link
Contributor

mganss commented May 22, 2020

Description

A font shorthand declaration is not parsed correctly if it contains a numerical font-weight.

Steps to Reproduce

var p = new HtmlParser(new HtmlParserOptions(), BrowsingContext.New(new Configuration().WithCss(new CssParserOptions())));
var dom = p.ParseDocument(@"<html><body><div style=""font: 400 12px serif"">Test</div></body></html>");
var div = dom.QuerySelector("div");
var style = div.GetStyle(); // -> style.Length == 0
var css = style.CssText; // -> ""

It works if font-weight is specified using a constant, e.g. font: bold 12px serif.

Possible Solution

It seems the numerical case is not considered here:

if (weight == null)
{
weight = source.ParseConstant(Map.FontWeights);
source.SkipSpacesAndComments();
}

@FlorianRappl
Copy link
Contributor

Yes I guess that's right. Can you supply a PR?

Thanks - much appreciated! 🍻

mganss added a commit to mganss/AngleSharp.Css that referenced this issue May 22, 2020
@FlorianRappl
Copy link
Contributor

Available in 0.14.2!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants