WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 5304bc4

Browse files
committed
fix: 修复数学公式支持
1 parent 0f4d228 commit 5304bc4

File tree

2 files changed

+13
-39
lines changed

2 files changed

+13
-39
lines changed

docs/js/katex.js

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,10 @@
1-
(function () {
2-
'use strict';
3-
4-
var katexMath = (function () {
5-
var maths = document.querySelectorAll('.arithmatex'),
6-
tex;
7-
8-
for (var i = 0; i < maths.length; i++) {
9-
tex = maths[i].textContent || maths[i].innerText;
10-
if (tex.startsWith('\\(') && tex.endsWith('\\)')) {
11-
katex.render(tex.slice(2, -2), maths[i], {'displayMode': false});
12-
} else if (tex.startsWith('\\[') && tex.endsWith('\\]')) {
13-
katex.render(tex.slice(2, -2), maths[i], {'displayMode': true});
14-
}
15-
}
16-
});
17-
18-
(function () {
19-
var onReady = function onReady(fn) {
20-
if (document.addEventListener) {
21-
document.addEventListener("DOMContentLoaded", fn);
22-
} else {
23-
document.attachEvent("onreadystatechange", function () {
24-
if (document.readyState === "interactive") {
25-
fn();
26-
}
27-
});
28-
}
29-
};
30-
31-
onReady(function () {
32-
if (typeof katex !== "undefined") {
33-
katexMath();
34-
}
35-
});
36-
})();
37-
38-
}());
39-
1+
document$.subscribe(({ body }) => {
2+
renderMathInElement(body, {
3+
delimiters: [
4+
{ left: "$$", right: "$$", display: true },
5+
{ left: "$", right: "$", display: false },
6+
{ left: "\\(", right: "\\)", display: false },
7+
{ left: "\\[", right: "\\]", display: true }
8+
],
9+
})
10+
})

mkdocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,15 @@ hooks:
146146

147147
extra_css:
148148
- https://fonts.googleapis.com/css?family=Noto+Serif+SC:300,300i,400,400i,700,700i&display=fallback
149+
- https://unpkg.com/katex@0/dist/katex.min.css
149150
- css/tasklist.css
150151
- css/card.css
151152
- css/custom.css
152153

153154
extra_javascript:
154155
- js/katex.js
156+
- https://unpkg.com/katex@0/dist/katex.min.js
157+
- https://unpkg.com/katex@0/dist/contrib/auto-render.min.js
155158

156159
markdown_extensions:
157160
- toc:

0 commit comments

Comments
 (0)