mirror of
https://github.com/loikein/hugo-tufte.git
synced 2025-08-14 22:32:44 +02:00
fix katex, 1 new shortcode, various fixes
This commit is contained in:
parent
e6c63a59cb
commit
e6d583a987
9 changed files with 90 additions and 46 deletions
layouts/partials
|
@ -1,29 +1,28 @@
|
|||
{{ if .Params.katex }}
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css">
|
||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js"></script>
|
||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js"></script>
|
||||
<script defer>
|
||||
renderMathInElement(
|
||||
document.body,
|
||||
{
|
||||
delimiters: [
|
||||
{ left: "$$", right: "$$", display: true },
|
||||
{ left: "\\[", right: "\\]", display: true },
|
||||
{ left: "$", right: "$", display: false },
|
||||
{ left: "\\(", right: "\\)", display: false }
|
||||
],
|
||||
displayMode: true
|
||||
<!-- <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>
|
||||
{{ else }}
|
||||
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
|
||||
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
||||
<script defer>
|
||||
window.MathJax = {
|
||||
tex: {
|
||||
inlineMath: [['$', '$'], ['\\(', '\\)']]
|
||||
}
|
||||
};
|
||||
</script>
|
||||
{{ end }}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue