Last active
June 2, 2024 17:24
-
-
Save unennhexium/2b4a352d51b8423e30ef09263b0dc2f0 to your computer and use it in GitHub Desktop.
Hugo Blowfish theme: adding custom delimiters to render math inside
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[goldmark] | |
[goldmark.renderer] | |
unsafe = true | |
[goldmark.extensions.passthrough] | |
enable = true | |
delimiters.block = [["\\[", "\\]"], ["$$", "$$"]] | |
delimiters.inline = [["\\(", "\\)"], ["$", "$"]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: themes/blowfish/layouts/partials/vendor.html | |
<+>UTF-8 | |
=================================================================== | |
diff --git a/themes/blowfish/layouts/partials/vendor.html b/themes/blowfish/layouts/partials/vendor.html | |
--- a/themes/blowfish/layouts/partials/vendor.html | |
+++ b/themes/blowfish/layouts/partials/vendor.html (date 1717343639599) | |
@@ -36,8 +36,23 @@ | |
<script defer src="{{ $katexJS.RelPermalink }}" integrity="{{ $katexJS.Data.Integrity }}"></script> | |
{{ $katexRenderJS := resources.Get "lib/katex/auto-render.min.js" }} | |
{{ $katexRenderJS := $katexRenderJS | resources.Fingerprint "sha512" }} | |
-<script defer src="{{ $katexRenderJS.RelPermalink }}" integrity="{{ $katexRenderJS.Data.Integrity }}" | |
- onload="renderMathInElement(document.body);"></script> | |
+<script defer src="{{ $katexRenderJS.RelPermalink }}" integrity="{{ $katexRenderJS.Data.Integrity }}"></script> | |
+<script> | |
+ document.addEventListener("DOMContentLoaded", function() { | |
+ renderMathInElement(document.body, { | |
+ // customised options | |
+ // • auto-render specific keys, e.g.: | |
+ delimiters: [ | |
+ {left: '$$', right: '$$', display: true}, | |
+ {left: '$', right: '$', display: false}, | |
+ {left: '\\(', right: '\\)', display: false}, | |
+ {left: '\\[', right: '\\]', display: true} | |
+ ], | |
+ // • rendering keys, e.g.: | |
+ throwOnError : false | |
+ }); | |
+ }); | |
+</script> | |
{{ $katexFonts := resources.Match "lib/katex/fonts/*" }} | |
{{ range $katexFonts }} | |
<!-- {{ .RelPermalink }} --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment