From 2062f15bee2dbbb0b7ee0cf67bce9790d0c1b988 Mon Sep 17 00:00:00 2001 From: zzossig Date: Thu, 30 Jan 2020 18:39:25 +0900 Subject: [PATCH] katex config bug fix --- exampleSite/content/posts/test-katex.md | 22 +++++----------------- layouts/partials/script/single-script.html | 13 ++++++++----- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/exampleSite/content/posts/test-katex.md b/exampleSite/content/posts/test-katex.md index 6101673..992fb3a 100644 --- a/exampleSite/content/posts/test-katex.md +++ b/exampleSite/content/posts/test-katex.md @@ -16,21 +16,13 @@ libraries: featured_image: "feature2/mathbook.png" --- -{{< box >}} -We need goldmark katex entension which is not yet we have: -[https://github.com/gohugoio/hugo/issues/6544](https://github.com/gohugoio/hugo/issues/6544) -{{< /box >}} - - The following $$ \int_{a}^{b} x^2 dx $$ Is an integral -$$ - \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } -$$ +$$ \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } $$ Enable Katex in the config file by setting the `katex` param to `true`. This will import the necessary Katex CSS/JS. @@ -39,21 +31,17 @@ See the online reference of [supported TeX functions](https://katex.org/docs/sup **Note:** For inline math to render correctly, your content file extension must be `.mmark`. See the [official mmark site](https://mmark.nl/). ``` -Inline math: $$ \varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887… $$ +Inline math: $ \varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887… $ ``` -Inline math: $$ \varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887… $$ +Inline math: $ \varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887… $ ``` Block math: -$$ -\varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } -$$ +$$ \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } $$ ``` Block math: -$$ -\varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } -$$ \ No newline at end of file +$$ \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } $$ \ No newline at end of file diff --git a/layouts/partials/script/single-script.html b/layouts/partials/script/single-script.html index 787e922..acefba9 100644 --- a/layouts/partials/script/single-script.html +++ b/layouts/partials/script/single-script.html @@ -436,11 +436,14 @@ // ============================= katex ============================= if (lib && lib.includes('katex')) { var mathElements = document.getElementsByClassName('math'); - var options = [ - { left: "$$", right: "$$", display: true }, - { left: "\\(", right: "\\)", display: false }, - { left: "\\[", right: "\\]", display: true } - ]; + var options = { + delimiters: [ + { left: "$$", right: "$$", display: true }, + { left: "\\[", right: "\\]", display: true }, + { left: "$", right: "$", display: false }, + { left: "\\(", right: "\\)", display: false } + ], + }; renderMathInElement(document.querySelector('.single__contents'), options); }