Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Incorrect usage of lang tag on pre #30

Closed
5 tasks done
aschultz opened this issue Nov 12, 2023 · 1 comment
Closed
5 tasks done

Incorrect usage of lang tag on pre #30

aschultz opened this issue Nov 12, 2023 · 1 comment

Comments

@aschultz
Copy link

Describe the bug

Change #26 added the lang tag to pre nodes to indicate the programming language in use. However, the HTML spec says the lang tag should only be used for natural languages and not computer languages. Chrome's Lighthouse tool also flags the elements as having invalid (i.e. not BCP 47) tags.

There's additional discussion here about what the right approach is to include this data, which generally boil down to using class or data tags.

You may want to favor matching the CommonMark and Prism pattern of adding class="language-foo" to the code tag as a starting point.

Reproduction

System Info

-

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@tobias-edwards
Copy link

tobias-edwards commented Nov 13, 2023

Indeed, Lighthouse flags this up during it's accessibility checks:

[lang] attributes do not have a valid value

See https://dequeuniversity.com/rules/axe/4.7/valid-lang

@antfu antfu closed this as completed in 6f02959 Nov 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants