Review and update whitespaces in shortcodes to improve shortcode nesting

This commit is contained in:
Alex Shpak
2025-09-26 15:48:57 +02:00
parent 48157b18c7
commit 5ffdf5bfaf
18 changed files with 89 additions and 74 deletions
+1
View File
@@ -24,6 +24,7 @@
font-size: 0.75em; font-size: 0.75em;
vertical-align: middle; vertical-align: middle;
text-decoration: none; text-decoration: none;
margin-inline-start: .25em;
} }
&:hover a.anchor, &:hover a.anchor,
@@ -32,5 +32,4 @@ Steps shortcode styles numbered list as series of points for better content orga
4. ## Curabitur sed lacinia velit. 4. ## Curabitur sed lacinia velit.
Curabitur sed lacinia velit. Nullam sed ante non quam lobortis hendrerit. Phasellus elementum, erat sit amet imperdiet pulvinar, odio massa lobortis ipsum, in tincidunt metus dolor vel ligula. Curabitur sed lacinia velit. Nullam sed ante non quam lobortis hendrerit. Phasellus elementum, erat sit amet imperdiet pulvinar, odio massa lobortis ipsum, in tincidunt metus dolor vel ligula.
{{% /steps %}} {{% /steps %}}
+1 -1
View File
@@ -1,6 +1,6 @@
<h{{ .Level }} id="{{ .Anchor }}" {{- with .Attributes.class -}}class="{{ . }}"{{- end -}}> <h{{ .Level }} id="{{ .Anchor }}" {{- with .Attributes.class -}}class="{{ . }}"{{- end -}}>
{{- .Text -}} {{- .Text -}}
{{- if default true .Attributes.anchor }} {{- if default true .Attributes.anchor -}}
<a class="anchor" href="#{{ .Anchor }}">#</a> <a class="anchor" href="#{{ .Anchor }}">#</a>
{{- end -}} {{- end -}}
</h{{ .Level }}> </h{{ .Level }}>
@@ -16,7 +16,7 @@
{{- else with (resources.Get $path) -}} {{- else with (resources.Get $path) -}}
{{- $destination = .RelPermalink -}} {{- $destination = .RelPermalink -}}
{{- else -}} {{- else -}}
{{- warnf "Reference '%s' not found in '%s'" .Destination .Page.Permalink -}} {{- warnf "Reference '%s' not found in '%s'" .Destination .Page.RelPermalink -}}
{{- end -}} {{- end -}}
{{- with $url.RawQuery -}} {{- with $url.RawQuery -}}
+7 -7
View File
@@ -19,16 +19,16 @@
<li> <li>
{{- $isRemote := (urls.Parse .URL).IsAbs -}} {{- $isRemote := (urls.Parse .URL).IsAbs -}}
<a href="{{ .URL }}" <a href="{{ .URL }}"
{{- with $class }}class="{{ delimit . " " }}"{{ end -}} {{- with $class }} class="{{ delimit . " " }}"{{- end -}}
{{- with .Title }}title="{{ . }}"{{ end -}} {{- with .Title }} title="{{ . }}"{{- end -}}
{{- if $isRemote }}target="_blank" rel="noopener"{{ end -}}> {{- if $isRemote }} target="_blank" rel="noopener"{{- end -}}>
{{- .Pre -}} {{- .Pre -}}
{{ template "book-menu-title" . }} {{- template "book-menu-title" . -}}
{{- .Post -}} {{- .Post -}}
</a> </a>
{{- with .Children }} {{- with .Children -}}
{{ template "book-menu-hugo" (dict "Page" $.Page "Menu" .) }} {{- template "book-menu-hugo" (dict "Page" $.Page "Menu" .) -}}
{{- end }} {{- end -}}
</li> </li>
{{- end -}} {{- end -}}
</ul> </ul>
+12 -10
View File
@@ -1,15 +1,17 @@
{{- if not (.Page.Store.Get "asciinema") -}} {{- if not (.Page.Store.Get "asciinema") -}}
<!-- Include asciinema player only first time --> <!-- Include asciinema player only first time -->
<link rel="stylesheet" href="{{ "asciinema/asciinema-player.css" | relURL }}" /> {{- /* remove whitespaces */ -}}
<script defer src="{{ "asciinema/asciinema-player.min.js" | relURL }}"></script> <link rel="stylesheet" href="{{ "asciinema/asciinema-player.css" | relURL }}" />
<script defer src="{{ "asciinema/asciinema-auto.js" | relURL }}"></script> {{- /* remove whitespaces */ -}}
{{- .Page.Store.Set "asciinema" true -}} <script defer src="{{ "asciinema/asciinema-player.min.js" | relURL }}"></script>
{{- /* remove whitespaces */ -}}
<script defer src="{{ "asciinema/asciinema-auto.js" | relURL }}"></script>
{{- .Page.Store.Set "asciinema" true -}}
{{- end -}} {{- end -}}
{{- with (partial "docs/links/portable-image" (dict "Page" .Page "Destination" (index .Params "cast"))) -}} {{- with (partial "docs/links/portable-image" (dict "Page" .Page "Destination" (index .Params "cast"))) -}}
{{- $opts := newScratch -}}
{{- $opts := newScratch -}} {{- $opts.Set "asciinema" $.Params -}}
{{- $opts.Set "asciinema" $.Params -}} {{- $opts.DeleteInMap "asciinema" "cast" -}}
{{- $opts.DeleteInMap "asciinema" "cast" -}} <div class="asciinema" id="asciinema-{{ $.Ordinal }}" x-data-cast="{{ . | safeHTMLAttr }}" x-data-opts="{{ $opts.Get "asciinema" | jsonify | safeHTMLAttr }}"></div>
<div class="asciinema" id="asciinema-{{ $.Ordinal }}" x-data-cast="{{ . | safeHTMLAttr }}" x-data-opts="{{ $opts.Get "asciinema" | jsonify | safeHTMLAttr }}"></div>
{{- end -}} {{- end -}}
+4 -3
View File
@@ -1,5 +1,6 @@
{{- $style := default "default" (.Get "style") -}} {{- $style := default "default" (.Get "style") -}}
<span class="book-badge {{ $style }}"> <span class="book-badge {{ $style }}">
{{- with .Get "title" }}<span class="book-badge-title">{{ . | plainify }}</span>{{ end -}} {{- with .Get "title" -}}<span class="book-badge-title">{{ . | plainify }}</span>{{- end -}}
{{- with .Get "value" }}<span class="book-badge-value">{{ . | plainify }}</span>{{ end -}} {{- with .Get "value" -}}<span class="book-badge-value">{{ . | plainify }}</span>{{- end -}}
</span> </span>
{{- /* remove whitespaces */ -}}
+1
View File
@@ -3,3 +3,4 @@
<a {{ with $href }}href="{{ $href }}"{{ end }} {{ with $isRemote }}target="_blank" rel="noopener"{{ end }} class="book-btn{{ with .Get "class" }} {{ . }}{{ end }}"> <a {{ with $href }}href="{{ $href }}"{{ end }} {{ with $isRemote }}target="_blank" rel="noopener"{{ end }} class="book-btn{{ with .Get "class" }} {{ . }}{{ end }}">
{{- .InnerDeindent -}} {{- .InnerDeindent -}}
</a> </a>
{{- /* remove whitespaces */ -}}
+4 -7
View File
@@ -1,9 +1,7 @@
{{- /* remove whitespace */ -}}
{{- with .Get "href" -}} {{- with .Get "href" -}}
{{- $destination := partial "docs/links/portable-link" (dict "Page" $.Page "Destination" .) -}} <div><a class="book-card{{ with $.Get "class" }} {{ . }}{{ end }}" href="{{ . | safeURL }}">
<a class="book-card{{ with $.Get "class" }} {{ . }}{{ end }}" href="{{ $destination | safeURL }}">
{{- template "book-card-content" $ -}} {{- template "book-card-content" $ -}}
</a> </a></div>
{{- else -}} {{- else -}}
<div class="book-card{{ with .Get "class" }} {{ . }}{{ end }}"> <div class="book-card{{ with .Get "class" }} {{ . }}{{ end }}">
{{- template "book-card-content" $ -}} {{- template "book-card-content" $ -}}
@@ -14,9 +12,8 @@
{{- with .Get "image" -}} {{- with .Get "image" -}}
{{- $destination := partial "docs/links/portable-image" (dict "Page" $.Page "Destination" .) -}} {{- $destination := partial "docs/links/portable-image" (dict "Page" $.Page "Destination" .) -}}
<img src="{{ $destination | safeURL }}" /> <img src="{{ $destination | safeURL }}" />
{{- end }} {{- end -}}
<div class="markdown-inner"> <div class="markdown-inner">
{{ with .Inner }}{{ . }}{{ end }} {{ with .Inner }}{{ . }}{{ end -}}
</div> </div>
{{- end -}} {{- end -}}
{{- /* remove whitespace */ -}}
+10 -10
View File
@@ -1,21 +1,21 @@
{{- $ratio := (split (.Get "ratio") ":") -}} {{- $ratio := (split (.Get "ratio") ":") -}}
{{- if strings.Contains .InnerDeindent "<--->" -}} {{- if strings.Contains .InnerDeindent "<--->" -}}
{{ warnf "Columns shortcode seprator '<--->' is deprecated, use markdown list instead." -}} {{- warnf "Columns shortcode seprator '<--->' is deprecated, use markdown list instead." -}}
<div class="book-columns flex flex-wrap{{ with .Get "class" }} {{ . }}{{ end }}"> <div class="book-columns flex flex-wrap{{ with .Get "class" }} {{ . }}{{ end }}">
{{ range $index, $content := split .InnerDeindent "<--->" }} {{- range $index, $content := split .InnerDeindent "<--->" -}}
{{- $grow := default 1 (index $ratio $index) -}} {{- $grow := default 1 (index $ratio $index) -}}
<div class="flex-even markdown-inner" style="flex-grow: {{ $grow }};"> <div class="flex-even markdown-inner" style="flex-grow: {{ $grow }};">
{{ $content | safeHTML }} {{- $content | safeHTML -}}
</div> </div>
{{ end }} {{- end -}}
</div> </div>
{{ else }} {{- else -}}
{{- if .Get "ratio" }}<style>{{ range $index, $grow := $ratio }} {{- if .Get "ratio" -}}<style>{{- range $index, $grow := $ratio -}}
.book-columns-{{ $.Ordinal }}>ul>li:nth-child({{ $index | add 1 }}){ .book-columns-{{ $.Ordinal }}>ul>li:nth-child({{ $index | add 1 }}){
flex-grow: {{ default 1 $grow }}; flex-grow: {{ default 1 $grow }};
} }
{{ end }}</style>{{ end -}} {{- end -}}</style>{{- end -}}
<div class="book-columns book-columns-{{ .Ordinal }} {{ with .Get "class" }}{{ . }}{{ end }}"> <div class="book-columns book-columns-{{ .Ordinal }}{{ with .Get "class" }} {{ . }}{{ end }}">
{{ .InnerDeindent | safeHTML }} {{ .Inner | safeHTML -}}
</div> </div>
{{ end -}} {{- end -}}
+8 -6
View File
@@ -1,7 +1,9 @@
{{- /* remove whitespaces */ -}}
<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 | .Page.RenderString }}</summary>
<div class="markdown-inner"> {{- /* remove whitespaces */ -}}
{{ .InnerDeindent | safeHTML }} <div class="markdown-inner">
</div> {{ .Inner | safeHTML -}}
</details> </div></details>
{{- /* remove whitespaces */ -}}
+3 -1
View File
@@ -1,3 +1,5 @@
{{- /* remove whitespaces */ -}}
<blockquote class="book-hint {{ default "default" (.Get 0) }}"> <blockquote class="book-hint {{ default "default" (.Get 0) }}">
{{ .Inner | safeHTML }} {{ .Inner | safeHTML -}}
</blockquote> </blockquote>
{{- /* remove whitespaces */ -}}
-1
View File
@@ -1,4 +1,3 @@
{{- /* remove whitespaces */ -}}
{{- $destination := partial "docs/links/portable-image" (dict "Page" .Page "Destination" (.Get "src")) -}} {{- $destination := partial "docs/links/portable-image" (dict "Page" .Page "Destination" (.Get "src")) -}}
<label class="book-image" for="book-image-toggle-{{ .Ordinal }}"> <label class="book-image" for="book-image-toggle-{{ .Ordinal }}">
<input class="hidden toggle" type="checkbox" id="book-image-toggle-{{ .Ordinal }}" /> <input class="hidden toggle" type="checkbox" id="book-image-toggle-{{ .Ordinal }}" />
+14 -12
View File
@@ -1,19 +1,21 @@
{{- if not (.Page.Store.Get "katex") -}} {{- if not (.Page.Store.Get "katex") -}}
<!-- Include katex only first time --> <!-- Include katex only first time -->
<link rel="stylesheet" href="{{ "katex/katex.min.css" | relURL }}" /> {{- /* remove whitespaces */ -}}
<script defer src="{{ "katex/katex.min.js" | relURL }}"></script> <link rel="stylesheet" href="{{ "katex/katex.min.css" | relURL }}" />
{{ with resources.Get "katex.json" }} {{- /* remove whitespaces */ -}}
<script defer src="{{ "katex/auto-render.min.js" | relURL }}" onload="renderMathInElement(document.body, {{ .Content | safeJS }});"></script> <script defer src="{{ "katex/katex.min.js" | relURL }}"></script>
{{ end }} {{- with resources.Get "katex.json" -}}
{{- .Page.Store.Set "katex" true -}} <script defer src="{{ "katex/auto-render.min.js" | relURL }}" onload="renderMathInElement(document.body, {{ . | minify }});"></script>
{{- end -}}
{{- .Page.Store.Set "katex" true -}}
{{- end -}} {{- end -}}
{{ if .Inner }} {{- if .Inner -}}
<span> <span>
{{- if .Get "display" }} {{- if .Get "display" -}}
\[ {{ .Inner }} \] \[ {{ .Inner }} \]
{{ else }} {{- else -}}
\( {{ .Inner }} \) \( {{ .Inner }} \)
{{ end -}} {{- end -}}
</span> </span>
{{ end }} {{- end -}}
+11 -9
View File
@@ -1,12 +1,14 @@
{{ if not (.Page.Store.Get "mermaid") }} {{- if not (.Page.Store.Get "mermaid") -}}
<!-- Include mermaid only first time --> <!-- Include mermaid only first time -->
<script src="{{ "mermaid.min.js" | relURL }}"></script> {{- /* remove whitespaces */ -}}
{{ with resources.Get "mermaid.json" }} <script src="{{ "mermaid.min.js" | relURL }}"></script>
<script>mermaid.initialize({{ .Content | safeJS }})</script> {{- with resources.Get "mermaid.json" -}}
{{ end }} <script>mermaid.initialize({{ .Content | safeJS }})</script>
{{ .Page.Store.Set "mermaid" true }} {{- end -}}
{{ end }} {{- .Page.Store.Set "mermaid" true -}}
{{- end -}}
<pre class="mermaid{{ with .Get "class" }} {{ . }}{{ end }}"> <pre class="mermaid{{ with .Get "class" }} {{ . }}{{ end }}">
{{- .Inner | htmlEscape | safeHTML -}} {{- .Inner | htmlEscape | safeHTML -}}
</pre> </pre>
{{- /* remove whitespaces */ -}}
+4 -2
View File
@@ -1,3 +1,5 @@
{{- /* remove whitespaces */ -}}
<div class="book-steps {{ with .Get "class" }}{{ . }}{{ end }}"> <div class="book-steps {{ with .Get "class" }}{{ . }}{{ end }}">
{{ .Inner }} {{ .Inner -}}
</div> </div>
{{- /* remove whitespaces */ -}}
+5 -2
View File
@@ -1,9 +1,12 @@
{{- $group := printf "tabs-%v" (default .Parent.Ordinal (.Parent.Get 0)) -}} {{- $group := printf "tabs-%v" (default .Parent.Ordinal (.Parent.Get 0)) -}}
{{- $tab := printf "%s-%d" $group .Ordinal }} {{- $tab := printf "%s-%d" $group .Ordinal -}}
<input type="radio" class="toggle" name="{{ $group }}" id="{{ $tab }}" {{ if not .Ordinal }}checked="checked"{{ end }} /> <input type="radio" class="toggle" name="{{ $group }}" id="{{ $tab }}" {{ if not .Ordinal }}checked="checked"{{ end }} />
{{- /* remove whitespaces */ -}}
<label for="{{ $tab }}"> <label for="{{ $tab }}">
{{- .Get 0 -}} {{- .Get 0 -}}
</label> </label>
{{- /* remove whitespaces */ -}}
<div class="book-tabs-content markdown-inner"> <div class="book-tabs-content markdown-inner">
{{- .Inner -}} {{ .Inner -}}
</div> </div>
{{- /* remove whitespaces */ -}}
+3 -1
View File
@@ -1,3 +1,5 @@
{{- /* remove whitespaces */ -}}
<div class="book-tabs"> <div class="book-tabs">
{{ .Inner }} {{- .Inner -}}
</div> </div>
{{- /* remove whitespaces */ -}}