feat: raw shortcode

This commit is contained in:
Dillon 2022-05-06 23:54:15 +08:00
parent 73a705a629
commit 85a710d6c2
No known key found for this signature in database
GPG key ID: 0EF4AE57FB98F108
3 changed files with 68 additions and 0 deletions

View file

@ -17,6 +17,9 @@ tags: ["shortcodes"]
categories: ["documentation"]
lightgallery: true
math:
enable: true
---
**LoveIt** theme provides multiple shortcodes on top of built-in ones in Hugo.
@ -1293,3 +1296,34 @@ You can see the output in the console of the developer tool.
{{< script >}}
console.log('Hello LoveIt!');
{{< /script >}}
## 12 raw
`raw` is a shortcode to insert raw **:(fab fa-html5 fa-fw): HTML** content in your post.
This is useful when you want to include some Markdown content to **avoid being rendered or escaped** by Hugo.
Example `raw` input:
```markdown
Inline Formula: {{</* raw */>}}\(\mathbf{E}=\sum_{i} \mathbf{E}_{i}=\mathbf{E}_{1}+\mathbf{E}_{2}+\mathbf{E}_{3}+\cdots\){{</* /raw */>}}
Block Formula:
{{</* raw */>}}
\[ a=b+c \\ d+e=f \]
{{</* /raw */>}}
Raw content using Markdown syntax: {{</* raw */>}}**Hello**{{</* /raw */>}}
```
The rendered output looks like this:
Inline Formula: {{< raw >}}\(\mathbf{E}=\sum_{i} \mathbf{E}_{i}=\mathbf{E}_{1}+\mathbf{E}_{2}+\mathbf{E}_{3}+\cdots\){{< /raw >}}
Block Formula:
{{< raw>}}
\[ a=b+c \\ d+e=f \]
{{< /raw >}}
Raw content using Markdown syntax: {{< raw >}}**Hello**{{< /raw >}}

View file

@ -17,6 +17,9 @@ tags: ["shortcodes"]
categories: ["documentation"]
lightgallery: true
math:
enable: true
mapbox:
lightStyle: mapbox://styles/mapbox/light-zh-v1?optimize=true
darkStyle: mapbox://styles/mapbox/dark-zh-v1?optimize=true
@ -1295,3 +1298,33 @@ console.log('Hello LoveIt!');
{{< script >}}
console.log('Hello LoveIt!');
{{< /script >}}
## 12 raw
`raw` shortcode 用来在你的文章中插入原始 **:(fab fa-html5 fa-fw): HTML** 内容.
一个 `raw` 示例:
```markdown
行内公式: {{</* raw */>}}\(\mathbf{E}=\sum_{i} \mathbf{E}_{i}=\mathbf{E}_{1}+\mathbf{E}_{2}+\mathbf{E}_{3}+\cdots\){{</* /raw */>}}
公式块:
{{</* raw */>}}
\[ a=b+c \\ d+e=f \]
{{</* /raw */>}}
原始的带有 Markdown 语法的内容: {{</* raw */>}}**Hello**{{</* /raw */>}}
```
呈现的输出效果如下:
行内公式: {{< raw >}}\(\mathbf{E}=\sum_{i} \mathbf{E}_{i}=\mathbf{E}_{1}+\mathbf{E}_{2}+\mathbf{E}_{3}+\cdots\){{< /raw >}}
公式块:
{{< raw>}}
\[ a=b+c \\ d+e=f \]
{{< /raw >}}
原始的带有 Markdown 语法的内容: {{< raw >}}**Hello**{{< /raw >}}

View file

@ -0,0 +1 @@
{{- .Inner | safeHTML -}}