-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
40 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,10 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
var katexMath = (function () { | ||
var maths = document.querySelectorAll('.arithmatex'), | ||
tex; | ||
|
||
for (var i = 0; i < maths.length; i++) { | ||
tex = maths[i].textContent || maths[i].innerText; | ||
if (tex.startsWith('\\(') && tex.endsWith('\\)')) { | ||
katex.render(tex.slice(2, -2), maths[i], {'displayMode': false}); | ||
} else if (tex.startsWith('\\[') && tex.endsWith('\\]')) { | ||
katex.render(tex.slice(2, -2), maths[i], {'displayMode': true}); | ||
} | ||
} | ||
}); | ||
|
||
(function () { | ||
var onReady = function onReady(fn) { | ||
if (document.addEventListener) { | ||
document.addEventListener("DOMContentLoaded", fn); | ||
} else { | ||
document.attachEvent("onreadystatechange", function () { | ||
if (document.readyState === "interactive") { | ||
fn(); | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
onReady(function () { | ||
if (typeof katex !== "undefined") { | ||
katexMath(); | ||
} | ||
}); | ||
})(); | ||
|
||
}()); | ||
|
||
document$.subscribe(({ body }) => { | ||
renderMathInElement(body, { | ||
delimiters: [ | ||
{ left: "$$", right: "$$", display: true }, // Display mode equations | ||
{ left: "$", right: "$", display: false }, // Inline equations | ||
{ left: "\\(", right: "\\)", display: false }, // Alternative inline | ||
{ left: "\\[", right: "\\]", display: true } // Alternative display | ||
], | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
window.MathJax = { | ||
tex: { | ||
inlineMath: [["\\(", "\\)"]], // Inline math delimiters | ||
displayMath: [["\\[", "\\]"]], // Display math delimiters | ||
processEscapes: true, // Handle escaped characters | ||
processEnvironments: true // Process LaTeX environments | ||
}, | ||
options: { | ||
ignoreHtmlClass: ".*|", // Ignore all classes by default | ||
processHtmlClass: "arithmatex" // Only process elements with this class | ||
} | ||
}; | ||
|
||
document$.subscribe(() => { | ||
MathJax.typesetPromise() // Render math when document loads | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,8 @@ markdown_extensions: | |
custom_checkbox: true | ||
- pymdownx.arithmatex: | ||
generic: true | ||
|
||
|
||
# - markdown.extensions.toc: | ||
# slugify: | ||
# !!python/object/apply:pymdownx.slugs.slugify { kwds: { case: lower } } | ||
|
@@ -141,8 +143,8 @@ extra: | |
# property: YOUR-ANALYTICS-ID | ||
|
||
extra_css: | ||
# - https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.7/katex.min.css | ||
- https://cdn.tonycrane.cc/utils/katex.min.css | ||
- https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/katex.min.css | ||
# - https://cdn.tonycrane.cc/utils/katex.min.css | ||
- https://cdn.tonycrane.cc/jbmono/jetbrainsmono.css | ||
- https://cdn.tonycrane.cc/lxgw/lxgwscreen.css | ||
- css/custom.css | ||
|
@@ -153,17 +155,23 @@ extra_css: | |
# - css/changelog_extra.css | ||
# - css/flod_toc.css | ||
# - css/grid cards.css # 好用的但还没用 | ||
# - https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/katex.min.css | ||
# - css/extra.css | ||
# - https://cdn.jsdelivr.net/npm/[email protected]/style.css | ||
|
||
|
||
extra_javascript: | ||
- js/katex.js | ||
- https://cdn.tonycrane.cc/utils/katex.min.js | ||
- js/mathjax.js | ||
# - https://cdn.tonycrane.cc/utils/katex.min.js | ||
- https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js | ||
# - https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.7/katex.min.js | ||
# - https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.7/contrib/auto-render.min.js | ||
# katex | ||
- https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/katex.min.js | ||
- https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/contrib/auto-render.min.js | ||
# mathjax | ||
- https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.0/es5/tex-mml-chtml.js | ||
- https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.0/es5/tex-chtml.js | ||
- https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.0/es5/tex-chtml-full.js | ||
- https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.0/es5/tex-svg-full.js | ||
# - js/custom.js | ||
# - js/heti.js | ||
# - js/toc.js | ||
|