Skip to content

Commit 8e59770

Browse files
committed
Update KaTeX SSR
1 parent 5e79845 commit 8e59770

File tree

3 files changed

+73
-4
lines changed

3 files changed

+73
-4
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ RUN apk add --no-cache \
3131
font-noto-cjk-extra \
3232
&& fc-cache -fv
3333

34-
RUN npm install -g markdownlint-cli2 && \
34+
RUN npm install -g markdownlint-cli2 katex && \
3535
npm cache clean --force
3636

3737
WORKDIR /app

bin/mkdocs-build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ python /app/scripts/generate.py "$@"
1212
echo ">>> Generation script finished."
1313
echo "========================================"
1414
echo ">>> [3/4] Running MkDocs build..."
15+
npm install katex
1516
mkdocs build --clean
1617
echo ">>> MkDocs build finished."
1718
echo "========================================"

scripts/template.yml

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,76 @@ plugins:
6060
- table-reader
6161
# https://github.com/timvink/mkdocs-table-reader-plugin
6262
# 在 Markdown 里面用这个引入 csv(是否是一个好习惯?
63+
- katex-ssr: # 自己做的插件
64+
katex_dist: "https://cdn.jsdelivr.net/npm/katex@0.16.27/dist/"
65+
add_katex_css: true
66+
katex_css_filename: "katex-swap.min.css"
67+
ssr_contribs:
68+
- mhchem
69+
macros:
70+
"\\RR": "\\mathbb{R}"
71+
"\\i": "\\mathrm{i}"
72+
"\\d": "\\mathrm{d}"
73+
"\\C": "\\mathbb{C}"
74+
"\\R": "\\mathbb{R}"
75+
"\\Q": "\\mathbb{Q}"
76+
"\\Z": "\\mathbb{Z}"
77+
"\\N": "\\mathbb{N}"
78+
"\\P": "\\mathbb{P}"
79+
"\\degree": "^\\circ"
80+
"\\op": "\\operatorname"
81+
"\\la": "\\left\\langle"
82+
"\\ra": "\\right\\rangle"
83+
"\\lc": "\\left\\lceil"
84+
"\\rc": "\\right\\rceil"
85+
"\\lf": "\\left\\lfloor"
86+
"\\rf": "\\right\\rfloor"
87+
"\\lv": "\\left\\lvert"
88+
"\\rv": "\\right\\rvert"
89+
"\\paren": "\\left({#1}\\right)"
90+
"\\bracket": "\\left[{#1}\\right]"
91+
"\\brace": "\\left\\{{#1}\\right\\}"
92+
"\\ceil": "\\left\\lceil{#1}\\right\\rceil"
93+
"\\floor": "\\left\\lfloor{#1}\\right\\rfloor"
94+
"\\vert": "\\left\\lvert{#1}\\right\\rvert"
95+
"\\vec": "\\bm"
96+
"\\vecc": "\\overrightarrow"
97+
"\\mol": "\\operatorname{mol}"
98+
"\\thermo": "\\ce{#1};\\quad\\Delta H=\\pu{#2}"
99+
"\\cat": "\\ce{催化剂}"
100+
"\\heat": "\\triangle"
101+
"\\poly": "\\ce{-\\!\\!\\![ #1 ]_n\\!\\!\\!\\!\\!-}"
102+
"\\el": "#1\\mathrm{#2}^{#3}"
103+
"": "'"
104+
"": ","
105+
"": "."
106+
"": ";"
107+
"": ":"
108+
"": "!"
109+
"": "?"
110+
"": "["
111+
"": "]"
112+
"": "("
113+
"": ")"
114+
"": ","
115+
"": "-"
116+
"": "\\dots"
117+
"·": "\\cdot"
118+
"->": "\\to"
119+
"<-": "\\gets"
120+
"\\pH": "p\\ce{H}"
121+
"\\pOH": "p\\ce{OH}"
122+
"\\con": "\\left[\\ce{#1}\\right]"
123+
"\\rank": "\\operatorname{rank}"
124+
"\\trans": "^{\\mathrm{T}}"
125+
"\\sgn": "\\operatorname{sgn}"
126+
"\\environment": "\\begin{#1} #2 \\end{#1}"
127+
"\\matrix": "\\begin{matrix} #1 \\end{matrix}"
128+
"\\pmatrix": "\\begin{pmatrix} #1 \\end{pmatrix}"
129+
"\\bmatrix": "\\begin{bmatrix} #1 \\end{bmatrix}"
130+
"\\Bmatrix": "\\begin{Bmatrix} #1 \\end{Bmatrix}"
131+
"\\vmatrix": "\\begin{vmatrix} #1 \\end{vmatrix}"
132+
"\\Vmatrix": "\\begin{Vmatrix} #1 \\end{Vmatrix}"
63133
- document-dates:
64134
# https://jaywhj.netlify.app/document-dates-zh
65135
position: bottom
@@ -124,7 +194,7 @@ plugins:
124194
remove_processing_instructions: false
125195
- optimize:
126196
optimize_png_speed: 1
127-
optimize_jpg_quality: 60
197+
optimize_jpg_quality: 75
128198
- blog:
129199
blog_toc: true
130200
post_date_format: long
@@ -175,5 +245,3 @@ exclude_docs: |
175245
/test/
176246
/cultural/
177247
/includes/
178-
extra_javascript:
179-
- assets/katex.render.js # 准备写 katex ssr?!

0 commit comments

Comments
 (0)