Merge pull request #1481 from ghost/lang-attr

This commit is contained in:
Max Wu 2021-07-09 14:59:49 +08:00 committed by GitHub
commit 6b8950d235
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 18 deletions

View File

@ -27,6 +27,8 @@ import { renderFretBoard } from './lib/renderer/fretboard/fretboard'
import './lib/renderer/lightbox'
import { renderCSVPreview } from './lib/renderer/csvpreview'
import { escapeAttrValue } from './render'
import markdownit from 'markdown-it'
import markdownitContainer from 'markdown-it-container'
@ -202,18 +204,15 @@ export function parseMeta (md, edit, view, toc, tocAffix) {
dir = meta.dir
breaks = meta.breaks
}
// text language
if (lang && typeof lang === 'string') {
view.attr('lang', lang)
toc.attr('lang', lang)
tocAffix.attr('lang', lang)
if (edit) { edit.attr('lang', lang) }
} else {
view.removeAttr('lang')
toc.removeAttr('lang')
tocAffix.removeAttr('lang')
if (edit) { edit.removeAttr('lang', lang) }
if (!lang || typeof lang !== 'string') {
lang = 'en'
}
// text language
view.attr('lang', lang)
toc.attr('lang', lang)
tocAffix.attr('lang', lang)
if (edit) { edit.attr('lang', lang) }
// text direction
if (dir && typeof dir === 'string') {
view.attr('dir', dir)
@ -817,8 +816,8 @@ export function exportToHTML (view) {
html: src[0].outerHTML,
'ui-toc': toc.html(),
'ui-toc-affix': tocAffix.html(),
lang: (md && md.meta && md.meta.lang) ? `lang="${md.meta.lang}"` : null,
dir: (md && md.meta && md.meta.dir) ? `dir="${md.meta.dir}"` : null
lang: (md && md.meta && md.meta.lang) ? `lang="${escapeAttrValue(md.meta.lang)}"` : null,
dir: (md && md.meta && md.meta.dir) ? `dir="${escapeAttrValue(md.meta.dir)}"` : null
}
const html = template(context)
// console.log(html);

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="<%= getLocale() %>">
<head>
<%- include codimd/head %>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="<%= getLocale() %>">
<head>
<%- include codimd/head %>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="<%= getLocale() %>">
<head>
<%- include index/head %>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="<%= getLocale() %>">
<head>
<meta charset="utf-8">

View File

@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html lang="<%= getLocale() %>">
<head>
<meta charset="utf-8">
<meta name="apple-mobile-web-app-capable" content="yes">