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

Set a proper "lang" attribute on <html> #1481

Merged
merged 3 commits into from Jul 9, 2021
Merged

Set a proper "lang" attribute on <html> #1481

merged 3 commits into from Jul 9, 2021

Conversation

ghost
Copy link

@ghost ghost commented Apr 10, 2020

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 is en. Since we now override the lang attribute on <html>. I changed it to always set lang to en when there is no lang 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:https:/// 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.

@ghost ghost changed the title Set proper "lang" attribute on <html> and #doc Set proper "lang" attribute on <html> Apr 10, 2020
@ghost ghost marked this pull request as ready for review April 10, 2020 11:31
@ghost ghost changed the title Set proper "lang" attribute on <html> Set a proper "lang" attribute on <html> Apr 10, 2020
@Yukaii Yukaii added this to the Next milestone Apr 11, 2020
@Yukaii Yukaii requested a review from jackycute April 25, 2020 07:18
@Yukaii
Copy link
Member

Yukaii commented Apr 25, 2020

getLocale() would fail for simplified and traditional Chinese now, since their proper language code should be zh-Hans and zh-Hant but file names are zh-CN.json and zh-TW.json respectively. Or we can just rename these two files. What do you think? @jackycute

ref: https://www.w3schools.com/tags/ref_language_codes.asp

@ghost
Copy link
Author

ghost commented Apr 26, 2020

@jackycute
Copy link
Member

Thanks!

@jackycute jackycute merged commit 6b8950d into hackmdio:develop Jul 9, 2021
edgarogh pushed a commit to WartaPoirier-corp/codimd that referenced this pull request Sep 21, 2021
@a60814billy a60814billy mentioned this pull request Jan 18, 2022
@Yukaii Yukaii modified the milestones: Next, 2.5.0 Dec 26, 2023
@stanley2058 stanley2058 mentioned this pull request Dec 26, 2023
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

Successfully merging this pull request may close these issues.

None yet

3 participants