mylloon.fr/static/js/libs/katex.js
Mylloon 9dfcc1101d
All checks were successful
ci/woodpecker/push/publish Pipeline was successful
Basic cours support (#44)
feat: Basic support for new `/cours` endpoint (not ready for release yet), see commit description for more

- Basic /cours support
- Fix LaTeX support (see #47 / cours+blog)
  - Better detection of when there is LaTeX in document
  - Don't shuffle markdown and LaTeX processing (thanks to comrak)
  - Macros on release
- Local image support (cours+blog)
- PDF support
- Support of markdown files integration in other markdown files
- Very basic exclusion support in toc (need a lot of improvement!!)
- Update multiple dependencies (actix-web, ramhorns, comrak, reqwest, hljs)
- Reformat some code
- ToC in /cours support (very basic, works via building it in rust and processing it in js)
- Remove very old assets (font + jspdf)
- Hide navbar when printing the website
- New tag in index page
- Fix OCaml support for HLJS + add "pseudocode" derived from Julia

Reviewed-on: #44
Co-authored-by: Mylloon <kennel.anri@tutanota.com>
Co-committed-by: Mylloon <kennel.anri@tutanota.com>
2024-04-01 18:11:46 +02:00

29 lines
733 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]()) {
const bs = "\\";
macros[`${bs}${item[0]}`] = `${bs}${item[1]}`;
}
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,
output: "mathml",
});
}
});