Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/AmazingRise/hugo-theme-diary.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoramazingrise <8315221+AmazingRise@users.noreply.github.com>2021-08-14 08:47:41 +0300
committeramazingrise <8315221+AmazingRise@users.noreply.github.com>2021-08-14 08:47:41 +0300
commite8df5edc6e87132697e0b2b0c5c8abef9e41b7ce (patch)
tree78dec540ee1373cd39ca8bbf02be45ef93d273f7
parentfd04f1bdeace19dc58104d691774d57851e6eaef (diff)
Replace mathJax with KaTeX
-rw-r--r--layouts/partials/head.html22
-rw-r--r--layouts/partials/mathjax.html36
2 files changed, 20 insertions, 38 deletions
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 2851afb..b5825bb 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -61,8 +61,26 @@
-{{ if .Params.enableMathJax }}
- {{ partial "mathjax.html" . }}
+{{ if or (.Params.enableLaTeX) (.Site.Params.enableLaTeX) }}
+<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.13/dist/katex.min.css" integrity="sha384-RZU/ijkSsFbcmivfdRBQDtwuwVqK7GMOw6IMvKyeWL2K5UAlyp6WonmB8m7Jd0Hn" crossorigin="anonymous">
+<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.13/dist/katex.min.js" integrity="sha384-pK1WpvzWVBQiP0/GjnvRxV4mOb0oxFuyRxJlk6vVw146n3egcN5C925NCP7a7BY8" crossorigin="anonymous"></script>
+<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.13/dist/contrib/auto-render.min.js" integrity="sha384-vZTG03m+2yp6N6BNi5iM4rW4oIwk5DfcNdFfxkk9ZWpDriOkXX8voJBFrAO7MpVl" crossorigin="anonymous"></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>
{{ end }}
{{ if and (not (.Params.disableToC) ) (.IsPage) }}
diff --git a/layouts/partials/mathjax.html b/layouts/partials/mathjax.html
deleted file mode 100644
index 386b8d7..0000000
--- a/layouts/partials/mathjax.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<!-- From https://note.qidong.name/2018/03/hugo-mathjax/ -->
-<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
-<script>
-MathJax = {
- tex: {
- inlineMath: [['$', '$'], ['\\(', '\\)']]
- },
- svg: {
- fontCache: 'global'
- }
-};
-</script>
-<script type="text/javascript" id="MathJax-script"
-async
-src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">
-MathJax.Hub.Queue(function() {
-// Fix <code> tags after MathJax finishes running. This is a
-// hack to overcome a shortcoming of Markdown. Discussion at
-// https://github.com/mojombo/jekyll/issues/199
-var all = MathJax.Hub.getAllJax(), i;
-for(i = 0; i < all.length; i += 1) {
-all[i].SourceElement().parentNode.className += ' has-jax';
-}
-});
-</script>
-
-<style>
-code.has-jax {
-font: inherit;
-font-size: 100%;
-background: inherit;
-border: inherit;
-color: #515151;
-}
-</style>
-