{{- partial "helper/external" (dict "Context" . "Namespace" "KaTeX") -}}
<script>
    window.addEventListener("DOMContentLoaded", () => {
        const elementsToRender = [".main-article", ".widget--toc"];

        elementsToRender.forEach(selector => {
            const element = document.querySelector(selector);
            if (element) {
                renderMathInElement(element, {
                    delimiters: [
                        { left: "$$", right: "$$", display: true },
                        { left: "$", right: "$", display: false },
                        { left: "\\(", right: "\\)", display: false },
                        { left: "\\[", right: "\\]", display: true }
                    ],
                    ignoredClasses: ["gist"]
                });
            }
        });
    });
</script>