mylloon.fr/static/js/libs/katex.js

33 lines
801 B
JavaScript
Raw Permalink Normal View History

2023-04-24 16:18:54 +02:00
window.addEventListener("load", () => {
const macros = {};
for (const item of new Map(
Object.entries({
2024-11-06 15:02:07 +01:00
B: "mathbb{B}",
2023-04-24 16:18:54 +02:00
N: "mathbb{N}",
R: "mathbb{R}",
Z: "mathbb{Z}",
O: "Theta",
2024-11-06 15:02:07 +01:00
Tau: "mathrm{T}",
u: "mu",
2023-04-24 16:18:54 +02:00
ra: "rightarrow",
la: "leftarrow",
RA: "Rightarrow",
LA: "Leftarrow",
2024-11-06 14:57:25 +01:00
lb: "llbracket",
rb: "rrbracket",
2023-04-24 16:18:54 +02:00
})
)[Symbol.iterator]()) {
const bs = "\\";
macros[`${bs}${item[0]}`] = `${bs}${item[1]}`;
2023-04-24 16:18:54 +02:00
}
const attribute = "data-math-style";
for (const element of document.querySelectorAll(`span[${attribute}]`)) {
katex.render(element.textContent, element, {
throwOnError: false,
displayMode: element.getAttribute(attribute) === "display",
macros: macros,
});
}
2023-04-24 16:18:54 +02:00
});