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
@ -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:
miseram excita suadent es pecudes iam. Concilio _quam_ velatus posset ait quod
nunc! Fragosis suae dextra geruntur functus vulgata.
{{< /columns >}}
{{% /columns %}}
## টেম্পোরার নিশি

View File

@ -5,7 +5,7 @@ type: docs
# Acerbo datus maxime
{{< columns >}}
{{% columns %}}
## Astris ipse furtiva
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:
miseram excita suadent es pecudes iam. Concilio _quam_ velatus posset ait quod
nunc! Fragosis suae dextra geruntur functus vulgata.
{{< /columns >}}
{{% /columns %}}
## 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 relref="/" >}}Get Home{{< /button >}}
{{< button href="https://github.com/alex-shpak/hugo-book" >}}Contribute{{< /button >}}
{{<button relref="/">}}Get Home{{</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
{{</* columns */>}} <!-- begin columns block -->
{{%/* columns */%}} <!-- begin columns block -->
# Left Content
Lorem markdownum insigne...
@ -17,12 +17,12 @@ Lorem markdownum insigne...
# Right Content
Lorem markdownum insigne...
{{</* /columns */>}}
{{%/* /columns */%}}
```
## Example
{{< columns >}}
{{% columns %}}
## Left Content
Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat
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
protulit, sed sed aere valvis inhaesuro Pallas animam: qui _quid_, ignes.
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
```tpl
{{</* details "Title" [open] */>}}
{{%/* details "Title" [open] */%}}
## Markdown content
Lorem markdownum insigne...
{{</* /details */>}}
{{%/* /details */%}}
```
```tpl
{{</* details title="Title" open=true */>}}
{{%/* details title="Title" open=true */%}}
## Markdown content
Lorem markdownum insigne...
{{</* /details */>}}
{{%/* /details */%}}
```
{{< details "Title" open >}}
{{% details "Title" open %}}
## Markdown content
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`.
```tpl
{{</* hint [info|warning|danger] */>}}
{{%/* hint [info|warning|danger] */%}}
**Markdown content**
Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat
stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa
{{</* /hint */>}}
{{%/* /hint */%}}
```
## Example
{{< hint info >}}
{{% hint info %}}
**Markdown content**
Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat
stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa
{{< /hint >}}
{{% /hint %}}
{{< hint warning >}}
{{% hint warning %}}
**Markdown content**
Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat
stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa
{{< /hint >}}
{{% /hint %}}
{{< hint danger >}}
{{% hint danger %}}
**Markdown content**
Lorem markdownum insigne. Olympo signis Delphis! Retexi Nereius nova develat
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/)
## Example
<div class="book-columns flex flex-wrap">
<div class="flex-even markdown-inner">
{{% columns %}}
```latex
{{</* 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 */>}}
```
</div>
<div class="flex-even markdown-inner">
<--->
{{< katex display=true class="optional" >}}
f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi
{{< /katex >}}
</div>
</div>
{{% /columns %}}
## 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.
{{< hint info >}}
**Override Mermaid Initialization Config**
{{% hint info %}}
**Override Mermaid initialization config**
To override the [initialization config](https://mermaid-js.github.io/mermaid/#/Setup) for Mermaid,
create a `mermaid.json` file in your `assets` folder!
{{< /hint >}}
{{% /hint %}}
## Example
<div class="book-columns flex flex-wrap">
<div class="flex-even markdown-inner">
{{% columns %}}
```tpl
{{</* mermaid class="optional" >}}
@ -28,8 +26,7 @@ stateDiagram-v2
{{< /mermaid */>}}
```
</div>
<div class="flex-even markdown-inner">
<--->
{{< mermaid class="optional" >}}
stateDiagram-v2
@ -42,5 +39,4 @@ stateDiagram-v2
note left of State2 : This is the note to the left.
{{< /mermaid >}}
</div>
</div>
{{% /columns %}}

View File

@ -12,4 +12,4 @@ Section renders pages in section as definition list, using title and description
{{</* 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.
```tpl
{{</* tabs */>}}
{{</* tab "MacOS" */>}} # MacOS Content {{</* /tab */>}}
{{</* tab "Linux" */>}} # Linux Content {{</* /tab */>}}
{{</* tab "Windows" */>}} # Windows Content {{</* /tab */>}}
{{</* /tabs */>}}
{{%/* tabs */%}}
{{%/* tab "MacOS" */%}} # MacOS Content {{%/* /tab */%}}
{{%/* tab "Linux" */%}} # Linux Content {{%/* /tab */%}}
{{%/* tab "Windows" */%}} # Windows Content {{%/* /tab */%}}
{{%/* /tabs */%}}
```
## Example
{{< tabs >}}
{{< tab "MacOS" >}}
{{% tabs %}}
{{% tab "MacOS" %}}
# MacOS
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
protulit, sed sed aere valvis inhaesuro Pallas animam: qui _quid_, ignes.
Miseratus fonte Ditis conubia.
{{< /tab >}}
{{% /tab %}}
{{< tab "Linux" >}}
{{% tab "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
protulit, sed sed aere valvis inhaesuro Pallas animam: qui _quid_, ignes.
Miseratus fonte Ditis conubia.
{{< /tab >}}
{{% /tab %}}
{{< tab "Windows" >}}
{{% tab "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
protulit, sed sed aere valvis inhaesuro Pallas animam: qui _quid_, ignes.
Miseratus fonte Ditis conubia.
{{< /tab >}}
{{< /tabs >}}
{{% /tab %}}
{{% /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
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:
miseram excita suadent es pecudes iam. Concilio _quam_ velatus posset ait quod
nunc! Fragosis suae dextra geruntur functus vulgata.
{{< /columns >}}
{{% /columns %}}
## Tempora nisi nunc

View File

@ -5,7 +5,7 @@ type: docs
# 中文索引页
{{< columns >}}
{{% columns %}}
## Astris ipse furtiva
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:
miseram excita suadent es pecudes iam. Concilio _quam_ velatus posset ait quod
nunc! Fragosis suae dextra geruntur functus vulgata.
{{< /columns >}}
{{% /columns %}}
## Tempora nisi nunc

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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