fix: make KaTeX render all math inside document.body (#994)

Since it only accepts one element, I cannot pass `.article-content` and `#TableOfContent` to it. The official documentation uses `document.body` directly, so I guess that's fine.

closes https://github.com/CaiJimmy/hugo-theme-stack/issues/882
This commit is contained in:
Jimmy Cai 2024-03-27 16:38:30 +01:00 committed by GitHub
parent 797949b37f
commit 609d43b088
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,7 +1,7 @@
{{- partial "helper/external" (dict "Context" . "Namespace" "KaTeX") -}} {{- partial "helper/external" (dict "Context" . "Namespace" "KaTeX") -}}
<script> <script>
window.addEventListener("DOMContentLoaded", () => { window.addEventListener("DOMContentLoaded", () => {
renderMathInElement(document.querySelector(`.article-content`), { renderMathInElement(document.body, {
delimiters: [ delimiters: [
{ left: "$$", right: "$$", display: true }, { left: "$$", right: "$$", display: true },
{ left: "$", right: "$", display: false }, { left: "$", right: "$", display: false },