Skip to content

Style empty if text-align is start #151

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 Nov 20, 2023 · 8 comments
Closed

Style empty if text-align is start #151

mganss opened this issue Nov 20, 2023 · 8 comments
Labels
Milestone

Comments

@mganss
Copy link
Contributor

mganss commented Nov 20, 2023

I have a feeling this is a configuration issue but I can't figure out what I'm missing here:

var html = @"<p style=""text-align: start;"">this is the content of the p tag</p>";
var parser = new HtmlParser(new HtmlParserOptions { IsScripting = false }, 
    BrowsingContext.New(Configuration.Default.WithCss(new CssParserOptions())));
var dom = parser.ParseDocument(html);
var style = dom.Body.FirstElementChild.GetStyle();
var decls = style.Count(); // -> 0
var css = style.ToCss(); // -> ""

This does not occur if the value of text-align is left for example.

@FlorianRappl
Copy link
Contributor

I think its rather that start is not a valid value for text-align. Remember that the spec is living, and especially CSS is moving rapidly.

Back then the text-align (not text-align-last) was equivalent to the horizontal alignment (https://github.com/AngleSharp/AngleSharp.Css/blob/devel/src/AngleSharp.Css/Declarations/TextAlignDeclaration.cs#L11C51-L11C79), i.e., https://github.com/AngleSharp/AngleSharp.Css/blob/devel/src/AngleSharp.Css/Constants/Map.cs#L96.

That being written, surely we can support the new values for text-align.

@FlorianRappl FlorianRappl added this to the v1.0 milestone Nov 20, 2023
@mganss
Copy link
Contributor Author

mganss commented Nov 22, 2023

FWIW this used to work before AngleSharp 0.10:

var html = @"<p style=""text-align: start;"">this is the content of the p tag</p>";
var parser = new HtmlParser(new HtmlParserOptions { IsScripting = false }, 
BrowsingContext.New(Configuration.Default.WithCss(e =>
{
    e.Options = new CssParserOptions
    {
        IsIncludingUnknownDeclarations = true,
        IsIncludingUnknownRules = true,
        IsToleratingInvalidSelectors = true,
    };
})));
var dom = parser.Parse(html);
var style = dom.Body.FirstElementChild.Style;
var decls = style.Count(); // -> 1
var css = style.ToCss(); // "text-align: start"

@FlorianRappl
Copy link
Contributor

Landed in devel.

@wghilliard
Copy link

Hey @FlorianRappl , thank you for all of the work to support this library! Would it be possible to back port this change to the 0.X line? I realize it's scheduled for 1.0 but the product I work on is not allowed to use alpha versions of dependencies for compliance reasons. I notice the 1.0 release is has seen a lot of activity lately, but it's not clear to me when it might be available.

@FlorianRappl
Copy link
Contributor

Unfortunately no - if that particular patch is relevant for your company then maybe sponsoring AngleSharp / other relevant libraries would be a great start to contributing back.

@wghilliard
Copy link

Do you have an ETA on when version 1.0 might be released?

@FlorianRappl
Copy link
Contributor

I wanted to close it out in February, but there are too many projects consuming my time. I'd say not before mid / end of March.

@wghilliard
Copy link

Okay I understand, thank you, I'll check back in then!

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

No branches or pull requests

3 participants