/
index.md
399 lines (278 loc) Β· 9.89 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
---
title: Extended Markdown Syntax
date: 2023-02-24T21:42:22+08:00
type: posts
author:
name: Lruihao
link: https://lruihao.cn
description: This article shows the extended Markdown syntax and format in FixIt theme.
resources:
- name: featured-image
src: featured-image.webp
tags:
- Markdown
- Content
- HTML
- Advanced
categories:
- Documentation
reward: true
math: true
---
**FixIt** theme has some extended syntax elements for you to write articles.
<!--more-->
## Emoji Support
This part is shown in the [emoji support page][emoji-support].
## Mathematical Formula
{{< version 0.2.16 changed >}}
**FixIt** theme supports mathematical formulas based on [$\KaTeX$][katex].
Set the property `enable = true` under `[params.math]` in your [theme configuration][theme-config]
and the property `math: true` of the article front matter to enable the automatic rendering of mathematical formulas.
{{< admonition tip >}}
Here is a list of [$\TeX$ functions supported by $\KaTeX$](https://katex.org/docs/supported.html).
{{< /admonition >}}
{{< admonition >}}
Since Hugo generates HTML documents according to the syntax such as `_`/`*`/`>>` when rendering Markdown documents,
and some text content in the form of escape characters
(such as `\(`/`\)`/`\[`/`\]`/`\\`) escape processing will be performed automatically,
therefore, additional escape character expressions are required for these places to achieve automatic rendering:
- `_` -> `\_`
- `*` -> `\*`
- `>>` -> `\>>`
- `\(` -> `\\(`
- `\)` -> `\\)`
- `\[` -> `\\[`
- `\]` -> `\\]`
- `\\` -> `\\\\`
**FixIt** theme supports [`raw` shortcode][raw-shortcode] to avoid these escape characters,
which helps you write raw mathematical formula content.
Example `raw` input:
```markdown
{?{}{?{}< raw >}}Inline Formula: \(\mathbf{E}=\sum_{i} \mathbf{E}_{i}=\mathbf{E}_{1}+\mathbf{E}_{2}+\mathbf{E}_{3}+\cdots\){?{}{?{}< /raw >}}
{?{}{?{}< raw >}}
Block Formula:
\[ a=b+c \\ d+e=f \]
{?{}{?{}< /raw >}}
```
The rendered output looks like this:
{{< raw >}}Inline Formula: \(\mathbf{E}=\sum_{i} \mathbf{E}_{i}=\mathbf{E}_{1}+\mathbf{E}_{2}+\mathbf{E}_{3}+\cdots\){{< /raw >}}
{{< raw>}}
Block Formula:
\[ a=b+c \\ d+e=f \]
{{< /raw >}}
{{< /admonition >}}
### Inline Formula
The default inline delimiters are:
- `$ ... $`
- `\( ... \)` (escaped: `\\( ... \\)`)
For example:
```tex
$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\\)
### Block Formula
The default block delimiters are:
- `$$ ... $$`
- `\[ ... \]` (escaped: `\\[ ... \\]`)
- `\begin{equation} ... \end{equation}` (unnumbered: `\begin{equation*} ... \end{equation*}`)
- `\begin{align} ... \end{align}` (unnumbered: `\begin{align*} ... \end{align*}`)
- `\begin{alignat} ... \end{alignat}` (unnumbered: `\begin{alignat*} ... \end{alignat*}`)
- `\begin{gather} ... \end{gather}` (unnumbered: `\begin{gather*} ... \end{gather*}`)
- `\begin{CD} ... \end{CD}`
{{< admonition warning >}}
When there are newlines in the block formula, please turn on `goldmark.renderer.hardWraps` carefully, set it to true, Goldmark will render the newlines as `<br>` elements.
{{< /admonition >}}
For example:
```tex
$$ c = \pm\sqrt{a^2 + b^2} $$
\\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\]
\begin{equation*}
\rho \frac{\mathrm{D} \mathbf{v}}{\mathrm{D} t}=\nabla \cdot \mathbb{P}+\rho \mathbf{f}
\end{equation*}
\begin{equation}
\mathbf{E}=\sum_{i} \mathbf{E}\_{i}=\mathbf{E}\_{1}+\mathbf{E}\_{2}+\mathbf{E}_{3}+\cdots
\end{equation}
\begin{align}
a&=b+c \\\\
d+e&=f
\end{align}
\begin{alignat}{2}
10&x+&3&y = 2 \\\\
3&x+&13&y = 4
\end{alignat}
\begin{gather}
a=b \\\\
e=b+c
\end{gather}
\begin{CD}
A @>a\>> B \\\\
@VbVV @AAcA \\\\
C @= D
\end{CD}
```
The rendered output looks like this:
$$ c = \pm\sqrt{a^2 + b^2} $$
\\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\]
\begin{equation*}
\rho \frac{\mathrm{D} \mathbf{v}}{\mathrm{D} t}=\nabla \cdot \mathbb{P}+\rho \mathbf{f}
\end{equation*}
\begin{equation}
\mathbf{E}=\sum_{i} \mathbf{E}\_{i}=\mathbf{E}\_{1}+\mathbf{E}\_{2}+\mathbf{E}_{3}+\cdots
\end{equation}
\begin{align}
a&=b+c \\\\
d+e&=f
\end{align}
\begin{alignat}{2}
10&x+&3&y = 2 \\\\
3&x+&13&y = 4
\end{alignat}
\begin{gather}
a=b \\\\
e=b+c
\end{gather}
\begin{CD}
A @>a\>> B \\\\
@VbVV @AAcA \\\\
C @= D
\end{CD}
{{< admonition tip >}}
You can add more inline and block delimiters in your [theme configuration]({{< relref path="/documentation/getting-started/configuration#theme-configuration" >}}).
{{< /admonition >}}
### Copy-tex
**[Copy-tex][copy-tex]** is an extension for **$\KaTeX$**.
By the extension, when selecting and copying $\KaTeX$ rendered elements, copies their $\LaTeX$ source to the clipboard.
Set the property `copyTex = true` under `[params.math]` in your [theme configuration][theme-config] to enable Copy-tex.
Select and copy the formula rendered in the previous section, and you can find that the copied content is the LaTeX source code.
### mhchem
**[mhchem][mhchem]** is an extension for **$\KaTeX$**.
By the extension, you can write beautiful chemical equations easily in the article.
Set the property `mhchem = true` under `[params.math]` in your [theme configuration][theme-config] to enable mhchem.
```markdown
$$ \ce{CO2 + C -> 2 CO} $$
$$ \ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-} $$
```
The rendered output looks like this:
$$ \ce{CO2 + C -> 2 CO} $$
$$ \ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-} $$
## Ruby Annotation {#ruby}
An extended Markdown syntax for **ruby annotation** is supported in **FixIt** theme:
```markdown
[Hugo]{?^}(An open-source static site generator)
```
The rendered output looks like this:
[Hugo]^(An open-source static site generator)
## Fraction {#fraction}
{{< version 0.2.0 >}}
An extended Markdown syntax for **fraction** is supported in **FixIt** theme:
```markdown
[Light]{?/}[Dark]
[99]{?/}[100]
```
The rendered output looks like this:
[Light]/[Dark]
[90]/[100]
## Font Awesome {#fontawesome}
**FixIt** theme uses [Font Awesome][fontawesome] as the icon library.
You can easily use these icons in your articles.
Get the `class` of icons you wanted from the [Font Awesome website][fontawesome-icons].
```markdown
Gone camping! {?:}(fa-solid fa-campground fa-fw): Be back soon.
That is so funny! {?:}(fa-regular fa-grin-tears):
```
The rendered output looks like this:
Gone camping! :(fa-solid fa-campground fa-fw): Be back soon.
That is so funny! :(fa-regular fa-grin-tears):
## Escape character {#escape-character}
In some special cases (when writing this theme documentation :(fa-regular fa-grin-squint-tears):),
your content will conflict with basic or extended Markdown syntax, and it is inevitable.
The escape character syntax can help you build the content you wanted:
```markdown
{{??}X} -> X
```
For example, two `:` will enable emoji syntax, which is not the behavior you want. The escape character syntax is like this:
```markdown
{{??}:}joy:
```
The rendered output looks like this:
**{?:}joy{?:}** instead of **:joy:**
{{< admonition tip >}}
This is related to **[an issue for Hugo](https://github.com/gohugoio/hugo/issues/4978)**, which has not been resolved.
{{< /admonition >}}
Another example is:
```markdown
[link{{??}]}(#escape-character)
```
The rendered output looks like this:
**[link{?]}(#escape-character)** instead of **[link](#escape-character)**.
## Custom attribute
> The premise is that you set `goldmark.parser.attribute.block` to `true`.
Enable custom attribute support for titles and blocks by adding attribute lists inside single curly brackets (`{.myclass class="class1 class2"}`) and placing it after the Markdown element it decorates, on the same line for titles and on a new line directly below for blocks.
Hugo supports adding attributes (e.g. CSS classes) to Markdown blocks, e.g. tables, lists, paragraphs etc.
A blockquote with a CSS class:
```md
> foo\
> bar
{.text-danger}
```
The rendered output looks like this:
> foo\
> bar
{.text-danger}
There are some current limitations: For tables you can currently only apply it to the full table, and for lists the `ul`/`ol`-nodes only, e.g.:
```md
* Fruit
* Apple
* Orange
* Banana
{.text-success}
* Dairy
* Milk
* Cheese
{.text-warning}
{.text-primary}
```
The rendered output looks like this:
- Fruit
- Apple
- Orange
- Banana
{.text-success}
- Dairy
- Milk
- Cheese
{.text-warning}
{.text-primary}
Note that attributes in [code fences][code-fences] must come after the opening tag, with any other highlighting processing instruction, e.g.:
```md
{?`}{?`}{?`}go {.myclass linenos=table,hl_lines=[8,"15-17"],linenostart=199}
// ... code
{?`}{?`}{?`}
```
## Code Fences Extended
### Code Block Attributes
You can add attributes to a code block, for example:
````markdown
```js {title="test.js"}
console.log('hello FixIt!');
```
````
The rendered output looks like this:
```js {title="test.js"}
console.log('hello FixIt!');
```
Currently supported attributes include:
- `title`: The title of the code block.
### Diagrams Support
This part is shown in the [diagrams support page][diagrams-support].
[emoji-support]: {{< relref path="/guides/emoji-support" >}}
[katex]: https://katex.org/
[theme-config]: {{< relref path="/documentation/getting-started/configuration#theme-configuration" >}}
[raw-shortcode]: {{< relref path="/documentation/content-management/shortcodes/extended#raw" >}}
[copy-tex]: https://github.com/Khan/KaTeX/tree/master/contrib/copy-tex
[mhchem]: https://github.com/Khan/KaTeX/tree/master/contrib/mhchem
[fontawesome]: https://fontawesome.com/
[fontawesome-icons]: https://fontawesome.com/icons?d=gallery
[code-fences]: https://gohugo.io/content-management/syntax-highlighting/#highlighting-in-code-fences
[diagrams-support]: {{< relref path="/documentation/content-management/diagrams" >}}