FEAT: enable persistent macros in Katex, update Katex to 0.15.6 (#51)

This commit is contained in:
qnxor 2022-06-07 16:19:59 +01:00 committed by GitHub
parent 836d084818
commit 4b4ad9d532
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 6 deletions

View File

@ -11,7 +11,7 @@ function ensureKaTeX() {
}); });
} }
function decorate(elem) { function decorate(elem, macros) {
const $elem = $(elem); const $elem = $(elem);
const displayMode = elem.tagName === "DIV"; const displayMode = elem.tagName === "DIV";
@ -25,7 +25,7 @@ function decorate(elem) {
const displayClass = tag === "div" ? "block-math" : "inline-math"; const displayClass = tag === "div" ? "block-math" : "inline-math";
const text = $elem.text(); const text = $elem.text();
$elem.addClass(`math-container ${displayClass} katex-math`).text(""); $elem.addClass(`math-container ${displayClass} katex-math`).text("");
window.katex.render(text, elem, { displayMode }); window.katex.render(text, elem, { displayMode, macros });
} }
} }
@ -38,7 +38,9 @@ function katex($elem) {
if (mathElems.length > 0) { if (mathElems.length > 0) {
ensureKaTeX().then(() => { ensureKaTeX().then(() => {
mathElems.each((idx, elem) => decorate(elem)); // enable persistent macros: https://katex.org/docs/api.html#persistent-macros
const macros = {};
mathElems.each((idx, elem) => decorate(elem, macros));
}); });
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long