From 85a710d6c261326b0da2d90a781a3c0529402499 Mon Sep 17 00:00:00 2001 From: Dillon Date: Fri, 6 May 2022 23:54:15 +0800 Subject: [PATCH] feat: raw shortcode --- .../index.en.md | 34 +++++++++++++++++++ .../index.zh-cn.md | 33 ++++++++++++++++++ layouts/shortcodes/raw.html | 1 + 3 files changed, 68 insertions(+) create mode 100644 layouts/shortcodes/raw.html diff --git a/exampleSite/content/posts/theme-documentation-extended-shortcodes/index.en.md b/exampleSite/content/posts/theme-documentation-extended-shortcodes/index.en.md index cfb2220b..5c44c81a 100644 --- a/exampleSite/content/posts/theme-documentation-extended-shortcodes/index.en.md +++ b/exampleSite/content/posts/theme-documentation-extended-shortcodes/index.en.md @@ -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: {{}}\(\mathbf{E}=\sum_{i} \mathbf{E}_{i}=\mathbf{E}_{1}+\mathbf{E}_{2}+\mathbf{E}_{3}+\cdots\){{}} + +Block Formula: + +{{}} +\[ a=b+c \\ d+e=f \] +{{}} + +Raw content using Markdown syntax: {{}}**Hello**{{}} +``` + +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 >}} diff --git a/exampleSite/content/posts/theme-documentation-extended-shortcodes/index.zh-cn.md b/exampleSite/content/posts/theme-documentation-extended-shortcodes/index.zh-cn.md index d2845f55..fba5d2ff 100644 --- a/exampleSite/content/posts/theme-documentation-extended-shortcodes/index.zh-cn.md +++ b/exampleSite/content/posts/theme-documentation-extended-shortcodes/index.zh-cn.md @@ -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 +行内公式: {{}}\(\mathbf{E}=\sum_{i} \mathbf{E}_{i}=\mathbf{E}_{1}+\mathbf{E}_{2}+\mathbf{E}_{3}+\cdots\){{}} + +公式块: + +{{}} +\[ a=b+c \\ d+e=f \] +{{}} + +原始的带有 Markdown 语法的内容: {{}}**Hello**{{}} +``` + +呈现的输出效果如下: + +行内公式: {{< 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 >}} diff --git a/layouts/shortcodes/raw.html b/layouts/shortcodes/raw.html new file mode 100644 index 00000000..4e81aced --- /dev/null +++ b/layouts/shortcodes/raw.html @@ -0,0 +1 @@ +{{- .Inner | safeHTML -}}