Breaking change: switch to '{{%' decorators in shortcodes to better support shortcode-in-shortcode

This commit is contained in:
Alex Shpak 2024-10-04 11:29:44 +02:00
parent 69886cc74b
commit 925dbd3b9f
21 changed files with 61 additions and 91 deletions

View File

@ -5,7 +5,7 @@ type: docs
# বাংলা ভাষায় শুরু করুন # বাংলা ভাষায় শুরু করুন
{{< columns >}} {{% columns %}}
## অস্ট্রিস চিপসে ফুর্তিভা ## অস্ট্রিস চিপসে ফুর্তিভা
Est in vagis et Pittheus tu arge accipiter regia iram vocatur nurus. Omnes ut Est in vagis et Pittheus tu arge accipiter regia iram vocatur nurus. Omnes ut
@ -19,7 +19,7 @@ modo arsit? Utinam rapta fiducia valuere litora _adicit cursu_, ad facies
Ea _furtique_ risere fratres edidit terrae magis. Colla tam mihi tenebat: Ea _furtique_ risere fratres edidit terrae magis. Colla tam mihi tenebat:
miseram excita suadent es pecudes iam. Concilio _quam_ velatus posset ait quod miseram excita suadent es pecudes iam. Concilio _quam_ velatus posset ait quod
nunc! Fragosis suae dextra geruntur functus vulgata. nunc! Fragosis suae dextra geruntur functus vulgata.
{{< /columns >}} {{% /columns %}}
## টেম্পোরার নিশি ## টেম্পোরার নিশি

View File

@ -5,7 +5,7 @@ type: docs
# Acerbo datus maxime # Acerbo datus maxime
{{< columns >}} {{% columns %}}
## Astris ipse furtiva ## Astris ipse furtiva
Est in vagis et Pittheus tu arge accipiter regia iram vocatur nurus. Omnes ut Est in vagis et Pittheus tu arge accipiter regia iram vocatur nurus. Omnes ut
@ -19,7 +19,7 @@ modo arsit? Utinam rapta fiducia valuere litora _adicit cursu_, ad facies
Ea _furtique_ risere fratres edidit terrae magis. Colla tam mihi tenebat: Ea _furtique_ risere fratres edidit terrae magis. Colla tam mihi tenebat:
miseram excita suadent es pecudes iam. Concilio _quam_ velatus posset ait quod miseram excita suadent es pecudes iam. Concilio _quam_ velatus posset ait quod
nunc! Fragosis suae dextra geruntur functus vulgata. nunc! Fragosis suae dextra geruntur functus vulgata.
{{< /columns >}} {{% /columns %}}
## Tempora nisi nunc ## Tempora nisi nunc

View File

@ -9,5 +9,5 @@ Buttons are styled links that can lead to local page or external link.
{{</* button href="https://github.com/alex-shpak/hugo-book" */>}}Contribute{{</* /button */>}} {{</* button href="https://github.com/alex-shpak/hugo-book" */>}}Contribute{{</* /button */>}}
``` ```
{{< button relref="/" >}}Get Home{{< /button >}} {{<button relref="/">}}Get Home{{</button>}}
{{< button href="https://github.com/alex-shpak/hugo-book" >}}Contribute{{< /button >}} {{<button href="https://github.com/alex-shpak/hugo-book">}}Contribute{{</button>}}

View File

@ -4,7 +4,7 @@ Columns help organize shorter pieces of content horizontally for readability.
```html ```html
{{</* columns */>}} <!-- begin columns block --> {{%/* columns */%}} <!-- begin columns block -->
# Left Content # Left Content
Lorem markdownum insigne... Lorem markdownum insigne...
@ -17,12 +17,12 @@ Lorem markdownum insigne...
# Right Content # Right Content
Lorem markdownum insigne... Lorem markdownum insigne...
{{</* /columns */>}} {{%/* /columns */%}}
``` ```
## Example ## Example
{{< columns >}} {{% columns %}}
## Left Content ## Left Content
Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat
stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa
@ -42,4 +42,4 @@ Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat
stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa
protulit, sed sed aere valvis inhaesuro Pallas animam: qui _quid_, ignes. protulit, sed sed aere valvis inhaesuro Pallas animam: qui _quid_, ignes.
Miseratus fonte Ditis conubia. Miseratus fonte Ditis conubia.
{{< /columns >}} {{% /columns %}}

View File

@ -4,19 +4,19 @@ Details shortcode is a helper for `details` html5 element. It is going to replac
## Example ## Example
```tpl ```tpl
{{</* details "Title" [open] */>}} {{%/* details "Title" [open] */%}}
## Markdown content ## Markdown content
Lorem markdownum insigne... Lorem markdownum insigne...
{{</* /details */>}} {{%/* /details */%}}
``` ```
```tpl ```tpl
{{</* details title="Title" open=true */>}} {{%/* details title="Title" open=true */%}}
## Markdown content ## Markdown content
Lorem markdownum insigne... Lorem markdownum insigne...
{{</* /details */>}} {{%/* /details */%}}
``` ```
{{< details "Title" open >}} {{% details "Title" open %}}
## Markdown content ## Markdown content
Lorem markdownum insigne... Lorem markdownum insigne...
{{< /details >}} {{% /details %}}

View File

@ -4,29 +4,29 @@ Hint shortcode can be used as hint/alerts/notification block.
There are 3 colors to choose: `info`, `warning` and `danger`. There are 3 colors to choose: `info`, `warning` and `danger`.
```tpl ```tpl
{{</* hint [info|warning|danger] */>}} {{%/* hint [info|warning|danger] */%}}
**Markdown content** **Markdown content**
Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat
stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa
{{</* /hint */>}} {{%/* /hint */%}}
``` ```
## Example ## Example
{{< hint info >}} {{% hint info %}}
**Markdown content** **Markdown content**
Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat
stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa
{{< /hint >}} {{% /hint %}}
{{< hint warning >}} {{% hint warning %}}
**Markdown content** **Markdown content**
Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat
stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa
{{< /hint >}} {{% /hint %}}
{{< hint danger >}} {{% hint danger %}}
**Markdown content** **Markdown content**
Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat
stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa
{{< /hint >}} {{% /hint %}}

View File

@ -6,9 +6,7 @@ title: KaTeX
KaTeX shortcode let you render math typesetting in markdown document. See [KaTeX](https://katex.org/) KaTeX shortcode let you render math typesetting in markdown document. See [KaTeX](https://katex.org/)
## Example ## Example
{{% columns %}}
<div class="book-columns flex flex-wrap">
<div class="flex-even markdown-inner">
```latex ```latex
{{</* katex display=true class="optional" >}} {{</* katex display=true class="optional" >}}
@ -16,15 +14,13 @@ f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi
{{< /katex */>}} {{< /katex */>}}
``` ```
</div> <--->
<div class="flex-even markdown-inner">
{{< katex display=true class="optional" >}} {{< katex display=true class="optional" >}}
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
{{< /katex >}} {{< /katex >}}
</div> {{% /columns %}}
</div>
## Display Mode Example ## Display Mode Example

View File

@ -2,18 +2,16 @@
[MermaidJS](https://mermaid-js.github.io/) is library for generating svg charts and diagrams from text. [MermaidJS](https://mermaid-js.github.io/) is library for generating svg charts and diagrams from text.
{{< hint info >}} {{% hint info %}}
**Override Mermaid Initialization Config** **Override Mermaid initialization config**
To override the [initialization config](https://mermaid-js.github.io/mermaid/#/Setup) for Mermaid, To override the [initialization config](https://mermaid-js.github.io/mermaid/#/Setup) for Mermaid,
create a `mermaid.json` file in your `assets` folder! create a `mermaid.json` file in your `assets` folder!
{{< /hint >}} {{% /hint %}}
## Example ## Example
<div class="book-columns flex flex-wrap"> {{% columns %}}
<div class="flex-even markdown-inner">
```tpl ```tpl
{{</* mermaid class="optional" >}} {{</* mermaid class="optional" >}}
@ -28,8 +26,7 @@ stateDiagram-v2
{{< /mermaid */>}} {{< /mermaid */>}}
``` ```
</div> <--->
<div class="flex-even markdown-inner">
{{< mermaid class="optional" >}} {{< mermaid class="optional" >}}
stateDiagram-v2 stateDiagram-v2
@ -42,5 +39,4 @@ stateDiagram-v2
note left of State2 : This is the note to the left. note left of State2 : This is the note to the left.
{{< /mermaid >}} {{< /mermaid >}}
</div> {{% /columns %}}
</div>

View File

@ -12,4 +12,4 @@ Section renders pages in section as definition list, using title and description
{{</* section [summary] */>}} {{</* section [summary] */>}}
``` ```
{{<section summary >}} {{<section summary>}}

View File

@ -3,17 +3,17 @@
Tabs let you organize content by context, for example installation instructions for each supported platform. Tabs let you organize content by context, for example installation instructions for each supported platform.
```tpl ```tpl
{{</* tabs */>}} {{%/* tabs */%}}
{{</* tab "MacOS" */>}} # MacOS Content {{</* /tab */>}} {{%/* tab "MacOS" */%}} # MacOS Content {{%/* /tab */%}}
{{</* tab "Linux" */>}} # Linux Content {{</* /tab */>}} {{%/* tab "Linux" */%}} # Linux Content {{%/* /tab */%}}
{{</* tab "Windows" */>}} # Windows Content {{</* /tab */>}} {{%/* tab "Windows" */%}} # Windows Content {{%/* /tab */%}}
{{</* /tabs */>}} {{%/* /tabs */%}}
``` ```
## Example ## Example
{{< tabs >}} {{% tabs %}}
{{< tab "MacOS" >}} {{% tab "MacOS" %}}
# MacOS # MacOS
This is tab **MacOS** content. This is tab **MacOS** content.
@ -22,9 +22,9 @@ Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat
stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa
protulit, sed sed aere valvis inhaesuro Pallas animam: qui _quid_, ignes. protulit, sed sed aere valvis inhaesuro Pallas animam: qui _quid_, ignes.
Miseratus fonte Ditis conubia. Miseratus fonte Ditis conubia.
{{< /tab >}} {{% /tab %}}
{{< tab "Linux" >}} {{% tab "Linux" %}}
# Linux # Linux
@ -34,9 +34,9 @@ Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat
stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa
protulit, sed sed aere valvis inhaesuro Pallas animam: qui _quid_, ignes. protulit, sed sed aere valvis inhaesuro Pallas animam: qui _quid_, ignes.
Miseratus fonte Ditis conubia. Miseratus fonte Ditis conubia.
{{< /tab >}} {{% /tab %}}
{{< tab "Windows" >}} {{% tab "Windows" %}}
# Windows # Windows
@ -46,5 +46,5 @@ Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat
stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa
protulit, sed sed aere valvis inhaesuro Pallas animam: qui _quid_, ignes. protulit, sed sed aere valvis inhaesuro Pallas animam: qui _quid_, ignes.
Miseratus fonte Ditis conubia. Miseratus fonte Ditis conubia.
{{< /tab >}} {{% /tab %}}
{{< /tabs >}} {{% /tabs %}}

View File

@ -1,22 +0,0 @@
---
headless: true
---
- [**Example Site**]({{< relref "/docs/example" >}})
- [Table of Contents]({{< relref "/docs/example/table-of-contents" >}})
- [With ToC]({{< relref "/docs/example/table-of-contents/with-toc" >}})
- [Without ToC]({{< relref "/docs/example/table-of-contents/without-toc" >}})
- [Collapsed]({{< relref "/docs/example/collapsed" >}})
- [3rd]({{< relref "/docs/example/collapsed/3rd-level" >}})
- [4th]({{< relref "/docs/example/collapsed/3rd-level/4th-level" >}})
<br />
- **Shortcodes**
- [Buttons]({{< relref "/docs/shortcodes/buttons" >}})
- [Columns]({{< relref "/docs/shortcodes/columns" >}})
- [Expand]({{< relref "/docs/shortcodes/expand" >}})
- [Hints]({{< relref "/docs/shortcodes/hints" >}})
- [KaTeX]({{< relref "/docs/shortcodes/katex" >}})
- [Mermaid]({{< relref "/docs/shortcodes/mermaid" >}})
- [Tabs]({{< relref "/docs/shortcodes/tabs" >}})
<br />

View File

@ -5,7 +5,7 @@ type: docs
# Стартовая страница на русском языке # Стартовая страница на русском языке
{{< columns >}} {{% columns %}}
## Astris ipse furtiva ## Astris ipse furtiva
Est in vagis et Pittheus tu arge accipiter regia iram vocatur nurus. Omnes ut Est in vagis et Pittheus tu arge accipiter regia iram vocatur nurus. Omnes ut
@ -19,7 +19,7 @@ modo arsit? Utinam rapta fiducia valuere litora _adicit cursu_, ad facies
Ea _furtique_ risere fratres edidit terrae magis. Colla tam mihi tenebat: Ea _furtique_ risere fratres edidit terrae magis. Colla tam mihi tenebat:
miseram excita suadent es pecudes iam. Concilio _quam_ velatus posset ait quod miseram excita suadent es pecudes iam. Concilio _quam_ velatus posset ait quod
nunc! Fragosis suae dextra geruntur functus vulgata. nunc! Fragosis suae dextra geruntur functus vulgata.
{{< /columns >}} {{% /columns %}}
## Tempora nisi nunc ## Tempora nisi nunc

View File

@ -5,7 +5,7 @@ type: docs
# 中文索引页 # 中文索引页
{{< columns >}} {{% columns %}}
## Astris ipse furtiva ## Astris ipse furtiva
Est in vagis et Pittheus tu arge accipiter regia iram vocatur nurus. Omnes ut Est in vagis et Pittheus tu arge accipiter regia iram vocatur nurus. Omnes ut
@ -19,7 +19,7 @@ modo arsit? Utinam rapta fiducia valuere litora _adicit cursu_, ad facies
Ea _furtique_ risere fratres edidit terrae magis. Colla tam mihi tenebat: Ea _furtique_ risere fratres edidit terrae magis. Colla tam mihi tenebat:
miseram excita suadent es pecudes iam. Concilio _quam_ velatus posset ait quod miseram excita suadent es pecudes iam. Concilio _quam_ velatus posset ait quod
nunc! Fragosis suae dextra geruntur functus vulgata. nunc! Fragosis suae dextra geruntur functus vulgata.
{{< /columns >}} {{% /columns %}}
## Tempora nisi nunc ## Tempora nisi nunc

View File

@ -8,5 +8,5 @@
{{- $ref = relref $ . -}} {{- $ref = relref $ . -}}
{{- end -}} {{- end -}}
<a {{ with $ref }} href="{{.}}" {{ end }} {{ with $target }} target="{{.}}" rel="noopener" {{ end }} class="book-btn{{ with .Get "class" }} {{ . }}{{ end }}"> <a {{ with $ref }} href="{{.}}" {{ end }} {{ with $target }} target="{{.}}" rel="noopener" {{ end }} class="book-btn{{ with .Get "class" }} {{ . }}{{ end }}">
{{ .InnerDeindent | .Page.RenderString }} {{ .InnerDeindent }}
</a> </a>

View File

@ -1,7 +1,7 @@
<div class="book-columns flex flex-wrap"> <div class="book-columns flex flex-wrap">
{{ range split .Inner "<--->" }} {{ range split .InnerDeindent "<--->" }}
<div class="flex-even markdown-inner"> <div class="flex-even markdown-inner">
{{ . | $.Page.RenderString }} {{ . | safeHTML }}
</div> </div>
{{ end }} {{ end }}
</div> </div>

View File

@ -1,7 +1,7 @@
<details {{ if or (.Get "open") (in .Params "open") }}open{{ end }}> <details {{ if or (.Get "open") (in .Params "open") }}open{{ end }}>
{{- $summary := cond .IsNamedParams (.Get "title") (.Get 0) -}} {{- $summary := cond .IsNamedParams (.Get "title") (.Get 0) -}}
<summary>{{ $summary | .Page.RenderString }}</summary> <summary>{{ $summary }}</summary>
<div class="markdown-inner"> <div class="markdown-inner">
{{ .InnerDeindent | .Page.RenderString }} {{ .InnerDeindent | safeHTML }}
</div> </div>
</details> </details>

View File

@ -1,3 +1,3 @@
<blockquote class="book-hint {{ .Get 0 }}"> <blockquote class="book-hint {{ .Get 0 }}">
{{ .InnerDeindent | .Page.RenderString }} {{ .InnerDeindent | safeHTML }}
</blockquote> </blockquote>

View File

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

View File

@ -8,6 +8,6 @@
<span {{- with .Get "class" }} class="{{ . }}"{{ end }}> <span {{- with .Get "class" }} class="{{ . }}"{{ end }}>
{{ with .Get "display" }}\[{{else}}\({{end}} {{ with .Get "display" }}\[{{else}}\({{end}}
{{- trim .Inner "\n" -}} {{- .InnerDeindent -}}
{{ with .Get "display" }}\]{{else}}\){{end}} {{ with .Get "display" }}\]{{else}}\){{end}}
</span> </span>

View File

@ -8,5 +8,5 @@
{{ end }} {{ end }}
<pre class="mermaid{{ with .Get "class" }} {{ . }}{{ end }}"> <pre class="mermaid{{ with .Get "class" }} {{ . }}{{ end }}">
{{- .Inner | safeHTML -}} {{- .Inner -}}
</pre> </pre>

View File

@ -8,7 +8,7 @@
{{- $tab.Name -}} {{- $tab.Name -}}
</label> </label>
<div class="book-tabs-content markdown-inner"> <div class="book-tabs-content markdown-inner">
{{- .Content | $.Page.RenderString -}} {{- .Content | safeHTML -}}
</div> </div>
{{- end -}} {{- end -}}
</div> </div>