35 lines
847 B
JavaScript
35 lines
847 B
JavaScript
window.addEventListener("load", () => {
|
|
const macros = {};
|
|
for (const item of new Map(
|
|
Object.entries({
|
|
N: "mathbb{N}",
|
|
R: "mathbb{R}",
|
|
Z: "mathbb{Z}",
|
|
O: "Theta",
|
|
ra: "rightarrow",
|
|
la: "leftarrow",
|
|
RA: "Rightarrow",
|
|
LA: "Leftarrow",
|
|
u: "mu",
|
|
})
|
|
)[Symbol.iterator]()) {
|
|
macros[`\\${item[0]}`] = `\\${item[1]}`;
|
|
}
|
|
|
|
document.querySelectorAll("span[data-katex]").forEach((element) => {
|
|
const rawLaTeXFormula = element.getAttribute("data-katex");
|
|
const displayMode = rawLaTeXFormula.startsWith("$$");
|
|
const strip = displayMode ? 2 : 1;
|
|
|
|
katex.render(
|
|
rawLaTeXFormula.slice(strip, rawLaTeXFormula.length - strip),
|
|
element,
|
|
{
|
|
throwOnError: false,
|
|
macros,
|
|
displayMode,
|
|
output: "mathml",
|
|
}
|
|
);
|
|
});
|
|
});
|