katex config bug fix

This commit is contained in:
zzossig 2020-01-30 18:39:25 +09:00
parent 4447dcc036
commit 2062f15bee
2 changed files with 13 additions and 22 deletions

View File

@ -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} } }
$$
$$ \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } $$

View File

@ -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);
}