Skip to content

Commit 3b9e958

Browse files
committed
feat: 内置mathjax可以被关闭
Relate to mirai-mamori/Sakurairo#1328 Relate to mirai-mamori/Sakurairo#1333
1 parent f70507b commit 3b9e958

2 files changed

Lines changed: 21 additions & 14 deletions

File tree

src/global.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ declare namespace _iro {
8080
const skin_bg4: string
8181
const meting_api_url: string | undefined
8282
const code_highlight: "prism" | "hljs" | "custom"
83+
const theme_mathjax: boolean
8384
const code_highlight_prism: {
8485
line_number_all: boolean
8586
autoload_path: string,

src/page/artile_attachment/math.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
import { resolvePath } from '../../common/npmLib'
22

33
export default async function math() {
4-
if (document.getElementsByTagName('math').length > 0 || document.querySelector('article > div.entry-content')?.textContent.match(/(?:\$|\\\(|\\\[|\\begin\{.*?})/)) {
5-
const mathjaxConfig = {
6-
tex: {
7-
inlineMath: [['$', '$'], ['\\(', '\\)']]
8-
},
9-
startup: {
10-
typeset: false, // Perform initial typeset?
11-
},
12-
chtml: {
13-
fontURL: resolvePath('es5/output/chtml/fonts/woff-v2', 'mathjax'),
14-
mathmlSpacing: true// true for MathML spacing rules, false for TeX rules
15-
}
16-
}
4+
if (_iro.theme_mathjax &&
5+
(
6+
document.getElementsByTagName('math').length > 0 ||
7+
document.querySelector('article > div.entry-content')?.textContent.match(/(?:\$|\\\(|\\\[|\\begin\{.*?})/)
8+
)
9+
) {
1710
if (!('MathJax' in window)) {
11+
const mathjaxConfig = {
12+
tex: {
13+
inlineMath: [['$', '$'], ['\\(', '\\)']]
14+
},
15+
startup: {
16+
typeset: false, // Perform initial typeset?
17+
},
18+
chtml: {
19+
fontURL: resolvePath('es5/output/chtml/fonts/woff-v2', 'mathjax'),
20+
mathmlSpacing: true// true for MathML spacing rules, false for TeX rules
21+
}
22+
}
1823
//@ts-ignore
1924
window.MathJax = mathjaxConfig
2025
}
2126
//@ts-ignore
22-
await import('mathjax/es5/tex-mml-chtml') //@ts-ignore
27+
await import('mathjax/es5/tex-mml-chtml')
28+
//@ts-ignore
2329
window.MathJax.typesetPromise()
2430
}
2531
}

0 commit comments

Comments
 (0)