Set a proper "lang" attribute on <html> #1481
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request fix the issue that
lang
attribute are always set to "en" no matter which language the user are using.For YAML metadata tag
lang
, according to the document, its default value isen
. Since we now override the lang attribute on<html>
. I changed it to always set lang toen
when there is nolang
in YAML metadata.Setting up a proper
lang
attribute is very necceserry for a11y. Since some screen reader like VoiceOver on iOS/macOS will relying on lang attribute to detect content language.Also I fixed a bug where the lang/dir attribute keeps unescaped in HTML exported page. This bug also exists in HackMD.io. Literally, this is a XSS bug but it only run on
file:///
so I don't think it's critical.Related to Issue: #87
P.S. I'm aware that default lang attribute for notes should be set in the server configuation. But I'd like to keep it in the future discuss now.