refactor: render katex in delegate. window.onload is redundant
This commit is contained in:
parent
738bf1f3ba
commit
4e032c3aa5
|
@ -26,14 +26,12 @@ declare const katex: any;
|
||||||
const list = document.querySelectorAll('[data-bs-toggle="tooltip"]');
|
const list = document.querySelectorAll('[data-bs-toggle="tooltip"]');
|
||||||
list.forEach((el: Element) => new bootstrap.Tooltip(el));
|
list.forEach((el: Element) => new bootstrap.Tooltip(el));
|
||||||
|
|
||||||
window.onload = function () {
|
const tex = document.getElementsByClassName("math");
|
||||||
const tex = document.getElementsByClassName("math");
|
Array.prototype.forEach.call(tex, function (el) {
|
||||||
Array.prototype.forEach.call(tex, function (el) {
|
let content = el.textContent.trim();
|
||||||
let content = el.textContent.trim();
|
if (content.startsWith("\\[")) content = content.slice(2);
|
||||||
if (content.startsWith("\\[")) content = content.slice(2);
|
if (content.endsWith("\\]")) content = content.slice(0, -2);
|
||||||
if (content.endsWith("\\]")) content = content.slice(0, -2);
|
|
||||||
|
|
||||||
katex.render(content, el);
|
katex.render(content, el);
|
||||||
});
|
});
|
||||||
};
|
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in New Issue