尽管有 `strict: false` 和 `trust: true` 选项,KaTeX 不会呈现 HTML 扩展命令

KaTeX does not render HTML extension commands despite `strict: false` and `trust: true` options

我正在尝试将 LaTeX 表达式嵌入到我的库的 Web 文档中。

那是 HTML 代码,cargo,Rust 的构建系统,将其放入 HTML 文档的头部,其中包含文档:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.css" integrity="sha384-R4558gYOUz8mP9YWpZJjofhk+zx0AS11p36HnD2ZKj/6JR5z27gSSULCNHIRReVs" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.js" integrity="sha384-z1fJDqw8ZApjGO3/unPWUPsIymfsJmyrDVWC8Tv/a1HeOtGmkwNd/7xUS0Xcnvsx" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/contrib/auto-render.min.js" integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
<script>
    document.addEventListener("DOMContentLoaded", function() {
        renderMathInElement(document.body, {
            strict: false,
            trust: true,
            delimiters: [
                {left: "$$", right: "$$", display: true},
                {left: "\(", right: "\)", display: false},
                {left: "$", right: "$", display: false},
                {left: "\[", right: "\]", display: true}
            ]
        });
    });
</script>

正在嵌入的.tex

\begin{cases}
    \operatorname{try\_get\_len\_of\_closed\_int\_intvl\_from\_0}: \href{Self}{google.com} \rightharpoonup usize \
    \operatorname{try\_get\_len\_of\_closed\_int\_intvl\_from\_0} = i \mapsto \lvert [0..i] \rvert
\end{cases}

输出:

如何让KaTeX正确显示文本?

问题是 onload 属性悄悄进入 HTML 文档头部的第 3 行:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.css" integrity="sha384-R4558gYOUz8mP9YWpZJjofhk+zx0AS11p36HnD2ZKj/6JR5z27gSSULCNHIRReVs" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.js" integrity="sha384-z1fJDqw8ZApjGO3/unPWUPsIymfsJmyrDVWC8Tv/a1HeOtGmkwNd/7xUS0Xcnvsx" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/contrib/auto-render.min.js" integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
<script>
    document.addEventListener("DOMContentLoaded", function() {
        renderMathInElement(document.body, {
            strict: false,
            trust: true,
            delimiters: [
                {left: "$$", right: "$$", display: true},
                {left: "\(", right: "\)", display: false},
                {left: "$", right: "$", display: false},
                {left: "\[", right: "\]", display: true}
            ]
        });
    });
</script>

即这条线

<script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/contrib/auto-render.min.js" integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>

导致渲染器被调用两次。第一次调用是使用默认设置进行的。