2023-04-24 16:18:54 +02:00
|
|
|
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",
|
2023-12-10 19:26:20 +01:00
|
|
|
u: "mu",
|
2023-04-24 16:18:54 +02:00
|
|
|
})
|
|
|
|
)[Symbol.iterator]()) {
|
|
|
|
macros[`\\${item[0]}`] = `\\${item[1]}`;
|
|
|
|
}
|
|
|
|
|
2023-12-10 23:23:27 +01:00
|
|
|
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",
|
|
|
|
}
|
|
|
|
);
|
2023-04-24 16:18:54 +02:00
|
|
|
});
|
|
|
|
});
|