hugo-tufte/layouts/partials/math.html

29 lines
1.4 KiB
HTML
Raw Permalink Normal View History

<!-- <script src="{{ "/js/math-code.js" | relURL }}"></script> -->
{{ $script := resources.Get "latex-fix.js" | resources.Minify }}
{{ with $script.Content }}
<script>{{ . | safeJS }}</script>
{{ end }}
<link rel="stylesheet" href="{{ .Site.Params.KaTeXCDN }}/katex@{{ .Site.Params.KaTeXVersion }}/dist/katex.min.css" crossorigin="anonymous">
<script defer src="{{ .Site.Params.KaTeXCDN }}/katex@{{ .Site.Params.KaTeXVersion }}/dist/katex.min.js" crossorigin="anonymous"></script>
<script defer src="{{ .Site.Params.KaTeXCDN }}/katex@{{ .Site.Params.KaTeXVersion }}/dist/contrib/auto-render.min.js" crossorigin="anonymous"></script>
<!-- do not add onload attributes, breaks settings below -->
<script>
document.addEventListener("DOMContentLoaded", function() {
renderMathInElement(document.body, {
// delimiters: [
// {left: "$$\n", right: "\n$$", display: true},
// {left: "$$", right: "$$", display: false},
// {left: "\\[", right: "\\]", display: true},
// {left: "\\(", right: "\\)", display: false}
// ],
trust: (context) => ['\\htmlId', '\\href'].includes(context.command),
macros: {
"\\eqref": "\\href{###1}{(\\text{#1})}",
"\\ref": "\\href{###1}{\\text{#1}}",
"\\label": "\\htmlId{#1}{}"
}
});
});
</script>