oliverbooth.dev/src/ts/app.ts

26 lines
848 B
TypeScript
Raw Normal View History

2023-08-08 01:08:18 +00:00
declare const bootstrap: any;
2023-08-08 01:08:50 +00:00
declare const katex: any;
2023-08-04 11:55:16 +00:00
(() => {
2023-08-08 01:10:17 +00:00
document.querySelectorAll("pre code").forEach((block) => {
const content = block.textContent;
if (content.split("\n").length > 1) {
block.parentElement.classList.add("line-numbers");
}
});
2023-08-08 01:08:18 +00:00
const list = document.querySelectorAll('[data-bs-toggle="tooltip"]');
list.forEach((el: Element) => new bootstrap.Tooltip(el));
2023-08-08 01:08:50 +00:00
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);
});
};
2023-08-04 11:55:16 +00:00
})();