feat: use KaTeX to render math exprs

This commit is contained in:
Oliver Booth 2023-08-08 02:08:50 +01:00
parent 2df24a99e7
commit 204269396e
Signed by: oliverbooth
GPG Key ID: 725DB725A0D9EE61
1 changed files with 12 additions and 0 deletions

View File

@ -1,6 +1,18 @@
declare const bootstrap: any;
declare const katex: any;
(() => {
const list = document.querySelectorAll('[data-bs-toggle="tooltip"]');
list.forEach((el: Element) => new bootstrap.Tooltip(el));
window.onload = function () {
const tex = document.getElementsByClassName("math");
Array.prototype.forEach.call(tex, function (el) {
let content = el.textContent.trim();
if (content.startsWith("\\[")) content = content.slice(2);
if (content.endsWith("\\]")) content = content.slice(0, -2);
katex.render(content, el);
});
};
})();