Skip to content

Commit

Permalink
feat(docs): update outdates maths formula settings docs
Browse files Browse the repository at this point in the history
  • Loading branch information
HEIGE-PCloud authored and Jatin794 committed Dec 19, 2024
1 parent e9ae0fd commit 23bb365
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 96 deletions.
58 changes: 35 additions & 23 deletions content/posts/theme-documentation-content/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,48 +302,60 @@ This part is shown in the [emoji support page](../emoji-support/).

**DoIt** theme supports mathematical formulas based on [$ \KaTeX $](https://katex.org/).

Set the property `enable = true` under `[params.math]` in your [site configuration](../theme-documentation-basics#site-configuration)
and the property `math: true` of the article front matter to enable the automatic rendering of mathematical formulas.
Set the followings in your [site configuration](../theme-documentation-basics#site-configuration) to enable mathematical formulas.

```toml {title="hugo.toml"}
[markup]
[markup.goldmark]
[markup.goldmark.extensions]
[markup.goldmark.extensions.passthrough]
enable = true
[markup.goldmark.extensions.passthrough.delimiters]
block = [['\[', '\]']]
inline = [['\(', '\)']]
[params]
[page]
[page.math]
enable = true
blockLeftDelimiter = '\['
blockRightDelimiter = '\]'
inlineLeftDelimiter = '\('
inlineRightDelimiter = '\)'
copyTex = true
mhchem = true
```

{{< admonition tip >}}
Here is a list of [$ \TeX $ functions supported by $ \KaTeX $](https://katex.org/docs/supported.html).
{{< /admonition >}}

#### Block Formula

The default block delimiters are `$$`/`$$` and `\\[`/`\\]`:
The default block delimiters is `\[ \]`:

```markdown
$$ c = \pm\sqrt{a^2 + b^2} $$
```markdown {linenos=false}
\[ c = \pm\sqrt{a^2 + b^2} \]
\\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\]
\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \]
```

The rendered output looks like this:

$$ c = \pm\sqrt{a^2 + b^2} $$
\[ c = \pm\sqrt{a^2 + b^2} \]

\\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\]
\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \]

#### Inline Formula

The default inline delimiters are `$`/`$` and `\\(`/`\\)`:
The default inline delimiters is `\( \)`:

```markdown
$ c = \pm\sqrt{a^2 + b^2} $ and \\( f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\)
\( c = \pm\sqrt{a^2 + b^2} \) and \( f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \)
```

The rendered output looks like this:

$ c = \pm\sqrt{a^2 + b^2} $ and \\( f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\)

{{< admonition tip >}}
You can add more block and inline delimiters in your [site configuration](../theme-documentation-basics#site-configuration).
{{< /admonition >}}

{{< admonition info >}}
You can use the [`math` shortcode](../theme-documentation-extended-shortcodes/#14-math) to avoid [issues](https://github.com/HEIGE-PCloud/DoIt/issues/126) causing by special characters.
{{< /admonition >}}
\( c = \pm\sqrt{a^2 + b^2} \) and \( f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \)

#### Copy-tex

Expand All @@ -364,16 +376,16 @@ By the extension, you can write beautiful chemical equations easily in the artic
Set the property `mhchem = true` under `[params.math]` in your [site configuration](../theme-documentation-basics#site-configuration) to enable mhchem.

```markdown
$$ \ce{CO2 + C -> 2 CO} $$
\[ \ce{CO2 + C -> 2 CO} \]
$$ \ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-} $$
\[ \ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-} \]
```

The rendered output looks like this:

$$ \ce{CO2 + C -> 2 CO} $$
\[ \ce{CO2 + C -> 2 CO} \]

$$ \ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-} $$
\[ \ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-} \]

### Ruby Annotation {#ruby}

Expand Down
62 changes: 37 additions & 25 deletions content/posts/theme-documentation-content/index.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,48 +301,60 @@ resources:

**DoIt** 基于 [$ \KaTeX $](https://katex.org/) 提供数学公式的支持.

在你的 [网站配置](../theme-documentation-basics#site-configuration) 中的 `[params.math]` 下面设置属性 `enable = true`,
并在文章的前置参数中设置属性 `math: true`来启用数学公式的自动渲染.
在你的 [网站配置](../theme-documentation-basics#site-configuration) 中添加如下设置来启用数学公式支持:

```toml {title="hugo.toml"}
[markup]
[markup.goldmark]
[markup.goldmark.extensions]
[markup.goldmark.extensions.passthrough]
enable = true
[markup.goldmark.extensions.passthrough.delimiters]
block = [['\[', '\]']]
inline = [['\(', '\)']]
[params]
[page]
[page.math]
enable = true
blockLeftDelimiter = '\['
blockRightDelimiter = '\]'
inlineLeftDelimiter = '\('
inlineRightDelimiter = '\)'
copyTex = true
mhchem = true
```

{{< admonition tip >}}
有一份 [$ \KaTeX $ 中支持的 $ \TeX $ 函数](https://katex.org/docs/supported.html) 清单.
这是一份 [$ \KaTeX $ 中支持的 $ \TeX $ 函数](https://katex.org/docs/supported.html) 列表。
{{< /admonition >}}

#### 公式块

默认的公式块分割符是 `$$`/`$$` 和 `\\[`/`\\]`:
默认的公式块分割符是 `\[ \]`:

```markdown
$$ c = \pm\sqrt{a^2 + b^2} $$
```markdown {linenos=false}
\[ c = \pm\sqrt{a^2 + b^2} \]
\\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\]
\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \]
```

呈现的输出效果如下:
呈现的输出效果如下

$$ c = \pm\sqrt{a^2 + b^2} $$
\[ c = \pm\sqrt{a^2 + b^2} \]

\\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\]
\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \]

#### 行内公式

默认的行内公式分割符是 `$`/`$` 和 `\\(`/`\\)`:
默认的行内公式分割符是 `\( \)`:

```markdown
$ c = \pm\sqrt{a^2 + b^2} $ 和 \\( f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\)
\( c = \pm\sqrt{a^2 + b^2} \) and \( f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \)
```

呈现的输出效果如下:

$ c = \pm\sqrt{a^2 + b^2} $ 和 \\( f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\)

{{< admonition tip >}}
你可以在 [网站配置](../theme-documentation-basics#site-configuration) 中自定义公式块和行内公式的分割符.
{{< /admonition >}}

{{< admonition info >}}
你可以使用 [`math` shortcode](../theme-documentation-extended-shortcodes/#14-math) 以避免特殊字符造成[问题](https://github.com/HEIGE-PCloud/DoIt/issues/126).
{{< /admonition >}}
\( c = \pm\sqrt{a^2 + b^2} \) and \( f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \)

#### Copy-tex

Expand All @@ -363,16 +375,16 @@ $ c = \pm\sqrt{a^2 + b^2} $ 和 \\( f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^
在你的 [网站配置](../theme-documentation-basics#site-configuration) 中的 `[params.math]` 下面设置属性 `mhchem = true` 来启用 mhchem.

```markdown
$$ \ce{CO2 + C -> 2 CO} $$
\[ \ce{CO2 + C -> 2 CO} \]
$$ \ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-} $$
\[ \ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-} \]
```

呈现的输出效果如下:

$$ \ce{CO2 + C -> 2 CO} $$
\[ \ce{CO2 + C -> 2 CO} \]

$$ \ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-} $$
\[ \ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-} \]

### 字符注音或者注释 {#ruby}

Expand Down
24 changes: 0 additions & 24 deletions content/posts/theme-documentation-extended-shortcodes/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -1483,30 +1483,6 @@ The rendered output looks like this:

{{< showcase title="Theme Documentation - Basics" summary="Discover what the Hugo - DoIt theme is all about and the core-concepts behind it." image="/theme-documentation-basics/featured-image.webp" link="/theme-documentation-basics" >}}

## math

{{< version 0.2.12 >}}

`math` is a shortcode to insert a math expression in your post. This can prevent [Goldmark](https://gohugo.io/getting-started/configuration-markup/#goldmark) from parsing math expressions into HTML. You no longer need to escape special characters inside this shortcode.

Example `math` input:

```markdown
{{</* math */>}}$\|\boldsymbol{x}\|_{0}=\sqrt[0]{\sum_{i} x_{i}^{0}}${{</* /math */>}}
Or
{{</* math */>}}
$$\|\boldsymbol{x}\|_{0}=\sqrt[0]{\sum_{i} x_{i}^{0}}$$
{{</* /math */>}}
```

The rendered output looks like this:

{{< math >}}$\|\boldsymbol{x}\|_{0}=\sqrt[0]{\sum_{i} x_{i}^{0}}${{< /math >}}

{{< math >}}
$$\|\boldsymbol{x}\|_{0}=\sqrt[0]{\sum_{i} x_{i}^{0}}$$
{{< /math >}}

## tabs and tab

`tabs` and `tab` are two shortcodes, when used together, can create a tab component for your content.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1487,30 +1487,6 @@ Or

{{< showcase title="主题文档 - 基本概念" summary="探索 Hugo - DoIt 主题的全部内容和背后的核心概念." image="/theme-documentation-basics/featured-image.webp" link="/theme-documentation-basics" >}}

## math

{{< version 0.2.12 >}}

`math` 用于插入数学公式. 它可以阻止 [Goldmark](https://gohugo.io/getting-started/configuration-markup/#goldmark) 将数学表达式中的特殊字符解析为 HTML 从而避免很多问题. 在 `math` 中, 你不再需要转义特殊字符.

一个 `math` 示例:

```markdown
{{</* math */>}}$\|\boldsymbol{x}\|_{0}=\sqrt[0]{\sum_{i} x_{i}^{0}}${{</* /math */>}}
Or
{{</* math */>}}
$$\|\boldsymbol{x}\|_{0}=\sqrt[0]{\sum_{i} x_{i}^{0}}$$
{{</* /math */>}}
```

呈现的输出效果如下:

{{< math >}}$\|\boldsymbol{x}\|_{0}=\sqrt[0]{\sum_{i} x_{i}^{0}}${{< /math >}}

{{< math >}}
$$\|\boldsymbol{x}\|_{0}=\sqrt[0]{\sum_{i} x_{i}^{0}}$$
{{< /math >}}

## tabs 和 tab

`tabs``tab` 是两个 shortcodes, 当一起使用时, 可以为你的内容创建一个选项卡组件。
Expand Down

0 comments on commit 23bb365

Please sign in to comment.