1function _katexRender(rootElement) { 2 const eles = rootElement.querySelectorAll(".katex-eq:not(.katex-rendered)"); 3 for (let idx = 0; idx < eles.length; idx++) { 4 const ele = eles[idx]; 5 ele.classList.add("katex-rendered"); 6 try { 7 katex.render(ele.textContent, ele, { 8 displayMode: ele.getAttribute("data-katex-display") === "true", 9 throwOnError: false, 10 }); 11 } catch (n) { 12 ele.style.color = "red"; 13 ele.textContent = n.message; 14 } 15 } 16} 17 18function katexRender() { 19 _katexRender(document); 20} 21 22document.addEventListener("DOMContentLoaded", function () { 23 katexRender(); 24 25 // Perform a KaTeX rendering step when the DOM is mutated. 26 const katexObserver = new MutationObserver(function (mutations) { 27 [].forEach.call(mutations, function (mutation) { 28 if (mutation.target && mutation.target instanceof Element) { 29 _katexRender(mutation.target); 30 } 31 }); 32 }); 33 34 const katexObservationConfig = { 35 subtree: true, 36 childList: true, 37 attributes: true, 38 characterData: true, 39 }; 40 41 katexObserver.observe(document.body, katexObservationConfig); 42});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.