Skip to content
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

Parse document language from <html lang=""> attribute #72

Open
barnabywalters opened this issue Oct 29, 2023 · 1 comment
Open

Parse document language from <html lang=""> attribute #72

barnabywalters opened this issue Oct 29, 2023 · 1 comment

Comments

@barnabywalters
Copy link

The mf2 parsing spec should consider looking for a lang attribute on the <html> element, and making its value available in the "lang" key on the parsed results, e.g.

<html lang="en-us">
</html>

would result in

{
  "items": [],
  "lang": "en-us"
}

This change would make the page-wide language easily available to the consumer without them having to do additional parsing of their own, and would reduce the need to implement language inheritance mentioned in #3

Parsing should be restricted to the <html> element rather than also looking on <body> or taking the first lang attribute found, as <html> is the preferred location for specifying the page-wide language.

@barnabywalters
Copy link
Author

Via jkingweb: we could consider implementing the language algorithm in the HTML spec, which would involve additionally looking for a <meta> element with a language value, if none is found in <html> https://html.spec.whatwg.org/multipage/dom.html#the-lang-and-xml:lang-attributes

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

No branches or pull requests

1 participant