Skip to content

Commit

Permalink
update katex
Browse files Browse the repository at this point in the history
  • Loading branch information
forFudan committed May 30, 2023
1 parent 4c577c0 commit 71a1c1b
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 39 deletions.
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ nav_external_links:
# hide_icon: false # set to true to hide the external link icon - defaults to false

markdown: kramdown
math: katex
layout: katex

# kramdown:
# syntax_highlighter_opts:
Expand Down
6 changes: 6 additions & 0 deletions _includes/head_custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% assign math = page.math | default: layout.math | default: site.math %}

{% case math %}
{% when "katex" %}
{% include katex.html %}
{% endcase %}
27 changes: 27 additions & 0 deletions _includes/katex.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- Copied from https://katex.org/docs/browser.html#starter-template -->

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-Juol1FqnotbkyZUT5Z7gUPjQ9gzlwCENvUZTpQBAPxtusdwFLRy382PSDx5UUJ4/" crossorigin="anonymous">

<!-- The loading of KaTeX is deferred to speed up page rendering -->
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-97gW6UIJxnlKemYavrqDHSX3SiygeOwIZhwyOKRfSaf0JWKRVj9hLASHgFTzT+0O" crossorigin="anonymous">
</script>

<!-- Automatically display code inside script tags with type=math/tex using KaTeX -->
<script defer src="/just-the-docs-tests/assets/js/mathtex-script-type.js">
</script>

<!-- To automatically render math in text elements, include the auto-render extension: -->
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05" crossorigin="anonymous"
onload="renderMathInElement(document.body, {
globalGroup: true,
trust: true,
strict: false,
throwOnError: false,
});"></script>

<!-- The KaTeX default is 1.21em, see https://katex.org/docs/font.html#font-size-and-lengths -->
<style>
.katex {
font-size: 1em;
}
</style>
12 changes: 12 additions & 0 deletions _layouts/katex.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
layout: default
math: katex
---
<div style="display: none">
\(
<!-- optional definitions using \newcommand, etc. (assuming globalGroup: true)
see https://katex.org/docs/supported.html#macros -->
\)
</div>

{{ content }}
34 changes: 34 additions & 0 deletions assets/js/mathtex-script-type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Mostly copied from https://github.com/KaTeX/KaTeX/tree/main/contrib/mathtex-script-type
// Options for global command definitions added by @pdmosses

// import katex from "katex";

const macros = {};

let scripts = document.body.getElementsByTagName("script");
scripts = Array.prototype.slice.call(scripts);
scripts.forEach(function(script) {
if (!script.type || !script.type.match(/math\/tex/i)) {
return -1;
}
const display =
(script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null);

const katexElement = document.createElement(display ? "div" : "span");
katexElement.setAttribute("class",
display ? "equation" : "inline-equation");
try {
katex.render(script.text, katexElement, {
displayMode: display,
globalGroup: true,
trust: true,
strict: false,
throwOnError: false,
macros
});
} catch (err) {
//console.error(err); linter doesn't like this
katexElement.textContent = script.text;
}
script.parentNode.replaceChild(katexElement, script);
});
1 change: 1 addition & 0 deletions beta/chaifen/宇浩字根码位映射表.csv
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ repr,font,zhu_code
亦,亦,Pi
宀,宀,Oo
亠,亠,Oo
{齊頭},亠,Oo
广,广,Uu
户,户,Ie
戸,戸,Ie
Expand Down
14 changes: 7 additions & 7 deletions beta/mabiao/baidu/yuhao_tradition.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33419,7 +33419,7 @@ dkrh 南街
dkrj 不由得
dkrj 不见得
dkrn 走向
dkrn 雲開衡嶽積陰止
dkrn 雲開衡岳積陰止
dkro 電稿
dkrq 成败得失
dkrq 馬里奧
Expand Down Expand Up @@ -44361,6 +44361,7 @@ efib 后汉
efib 后梁
efib 𬐃
efic 便池
efic 岳池
efie 𫢅
efih 兵法
efij 丘
Expand Down Expand Up @@ -55430,6 +55431,7 @@ ffee 本質
ffee 楊柳依依
ffef 本体
ffef 本条
ffef 林岳
ffeg 枯木逢春
ffeh 无功受禄
ffeh 𢽳
Expand Down Expand Up @@ -55688,7 +55690,6 @@ ffjm 檢校山園書所見
ffjm 更想幽期處
ffjr 棟
ffjr 本日
ffjr 林嶽
ffjr 𣈅
ffjs 𡹚
ffjt 榃
Expand Down Expand Up @@ -66366,7 +66367,7 @@ fwdv 构成
fwdy 攀索
fwdy 五月不可觸
fwec 攀爬
fwef 五千仞嶽上摩天
fwef 五千仞岳上摩天
fweg 万代
fweh 𭫺
fwem 𣟡
Expand Down Expand Up @@ -90527,6 +90528,7 @@ ienc 𭯺
ienc 𭲣
iend 激鬥
iene 浟
iene 海岳尚可傾
iene 𭲦
ienf 滌
ienf 所困
Expand Down Expand Up @@ -93972,7 +93974,6 @@ ijmx 𧡱
ijnd 𣴪
ijnd 𥪎
ijne 意图
ijne 海嶽尚可傾
ijnf 沉思默想
ijnf 𣷐
ijnl 意圖
Expand Down Expand Up @@ -106775,7 +106776,6 @@ jrhw 日均
jrhw 男兒到死心如鐵
jrhw 嶶
jrhy 日志
jric 嶽池
jrif 日新
jrig 日漸
jrig 曉行湘水春
Expand Down Expand Up @@ -141628,6 +141628,7 @@ ocec 安妥
oced 案例
oced 案值
ocef 安丘
ocef 安岳
oceg 𪧮
oceh 𫴧
ocel 安保
Expand Down Expand Up @@ -141679,7 +141680,6 @@ ocis 安源
ociv 安慶
ocjf 安凱
ocjm 安曼
ocjr 安嶽
ocjw 安歇
ocjw 𡪙
ock 谲
Expand Down Expand Up @@ -219274,6 +219274,7 @@ vddt 孤零零
vddy 红艳艳
vdeb 续假
vdec 及其使人也
vdef 張震岳
vdeh 頗佳
vdel 续保
vdeo 绑住
Expand Down Expand Up @@ -219321,7 +219322,6 @@ vdjf 𰘱
vdjj 𢐤
vdjk 𰌪
vdjq 司馬昭之心路人皆知
vdjr 張震嶽
vdjr 㢶
vdjr 𬁣
vdjs 终南山
Expand Down
14 changes: 7 additions & 7 deletions beta/mabiao/dada/yuhao_tradition.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33419,7 +33419,7 @@
不由得 dkrj
不见得 dkrj
走向 dkrn
雲開衡嶽積陰止 dkrn
雲開衡岳積陰止 dkrn
電稿 dkro
成败得失 dkrq
馬里奧 dkrq
Expand Down Expand Up @@ -44361,6 +44361,7 @@
后梁 efib
𬐃 efib
便池 efic
岳池 efic
𫢅 efie
兵法 efih
丘 efij
Expand Down Expand Up @@ -55430,6 +55431,7 @@
楊柳依依 ffee
本体 ffef
本条 ffef
林岳 ffef
枯木逢春 ffeg
无功受禄 ffeh
𢽳 ffeh
Expand Down Expand Up @@ -55688,7 +55690,6 @@
更想幽期處 ffjm
棟 ffjr
本日 ffjr
林嶽 ffjr
𣈅 ffjr
𡹚 ffjs
榃 ffjt
Expand Down Expand Up @@ -66366,7 +66367,7 @@
攀索 fwdy
五月不可觸 fwdy
攀爬 fwec
五千仞嶽上摩天 fwef
五千仞岳上摩天 fwef
万代 fweg
𭫺 fweh
𣟡 fwem
Expand Down Expand Up @@ -90527,6 +90528,7 @@
𭲣 ienc
激鬥 iend
浟 iene
海岳尚可傾 iene
𭲦 iene
滌 ienf
所困 ienf
Expand Down Expand Up @@ -93972,7 +93974,6 @@
𣴪 ijnd
𥪎 ijnd
意图 ijne
海嶽尚可傾 ijne
沉思默想 ijnf
𣷐 ijnf
意圖 ijnl
Expand Down Expand Up @@ -106775,7 +106776,6 @@
男兒到死心如鐵 jrhw
嶶 jrhw
日志 jrhy
嶽池 jric
日新 jrif
日漸 jrig
曉行湘水春 jrig
Expand Down Expand Up @@ -141628,6 +141628,7 @@ $ kkmy
案例 oced
案值 oced
安丘 ocef
安岳 ocef
𪧮 oceg
𫴧 oceh
安保 ocel
Expand Down Expand Up @@ -141679,7 +141680,6 @@ $ kkmy
安慶 ociv
安凱 ocjf
安曼 ocjm
安嶽 ocjr
安歇 ocjw
𡪙 ocjw
谲 ock
Expand Down Expand Up @@ -219274,6 +219274,7 @@ $ kkmy
红艳艳 vddy
续假 vdeb
及其使人也 vdec
張震岳 vdef
頗佳 vdeh
续保 vdel
绑住 vdeo
Expand Down Expand Up @@ -219321,7 +219322,6 @@ $ kkmy
𢐤 vdjj
𰌪 vdjk
司馬昭之心路人皆知 vdjq
張震嶽 vdjr
㢶 vdjr
𬁣 vdjr
终南山 vdjs
Expand Down
14 changes: 7 additions & 7 deletions beta/mabiao/dazhu/yuhao_tradition.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33471,7 +33471,7 @@ dkrh 南街
dkrj 不由得
dkrj 不见得
dkrn 走向
dkrn 雲開衡嶽積陰止
dkrn 雲開衡岳積陰止
dkro 電稿
dkrq 成败得失
dkrq 馬里奧
Expand Down Expand Up @@ -44426,6 +44426,7 @@ efib 后汉
efib 后梁
efib 𬐃
efic 便池
efic 岳池
efie 𫢅
efih 兵法
efij 丘
Expand Down Expand Up @@ -55519,6 +55520,7 @@ ffee 本質
ffee 楊柳依依
ffef 本体
ffef 本条
ffef 林岳
ffeg 枯木逢春
ffeh 无功受禄
ffeh 𢽳
Expand Down Expand Up @@ -55777,7 +55779,6 @@ ffjm 檢校山園書所見
ffjm 更想幽期處
ffjr 棟
ffjr 本日
ffjr 林嶽
ffjr 𣈅
ffjs 𡹚
ffjt 榃
Expand Down Expand Up @@ -66430,7 +66431,7 @@ fwdv 构成
fwdy 攀索
fwdy 五月不可觸
fwec 攀爬
fwef 五千仞嶽上摩天
fwef 五千仞岳上摩天
fweg 万代
fweh 𭫺
fwem 𣟡
Expand Down Expand Up @@ -90649,6 +90650,7 @@ ienc 𭯺
ienc 𭲣
iend 激鬥
iene 浟
iene 海岳尚可傾
iene 𭲦
ienf 滌
ienf 所困
Expand Down Expand Up @@ -94099,7 +94101,6 @@ ijmx 𧡱
ijnd 𣴪
ijnd 𥪎
ijne 意图
ijne 海嶽尚可傾
ijnf 沉思默想
ijnf 𣷐
ijnl 意圖
Expand Down Expand Up @@ -106743,7 +106744,6 @@ jrhw 日均
jrhw 男兒到死心如鐵
jrhw 嶶
jrhy 日志
jric 嶽池
jrif 日新
jrig 日漸
jrig 曉行湘水春
Expand Down Expand Up @@ -141071,6 +141071,7 @@ ocec 安妥
oced 案例
oced 案值
ocef 安丘
ocef 安岳
oceg 𪧮
oceh 𫴧
ocel 安保
Expand Down Expand Up @@ -141122,7 +141123,6 @@ ocis 安源
ociv 安慶
ocjf 安凱
ocjm 安曼
ocjr 安嶽
ocjw 安歇
ocjw 𡪙
ock 谲
Expand Down Expand Up @@ -218858,6 +218858,7 @@ vddt 孤零零
vddy 红艳艳
vdeb 续假
vdec 及其使人也
vdef 張震岳
vdeh 頗佳
vdel 续保
vdeo 绑住
Expand Down Expand Up @@ -218905,7 +218906,6 @@ vdjf 𰘱
vdjj 𢐤
vdjk 𰌪
vdjq 司馬昭之心路人皆知
vdjr 張震嶽
vdjr 㢶
vdjr 𬁣
vdjs 终南山
Expand Down
Loading

0 comments on commit 71a1c1b

Please sign in to comment.