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;
vertical-align: middle;
text-decoration: none;
margin-inline-start: .25em;
}
&: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.
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 %}}
+1 -1
View File
@@ -1,6 +1,6 @@
<h{{ .Level }} id="{{ .Anchor }}" {{- with .Attributes.class -}}class="{{ . }}"{{- end -}}>
{{- .Text -}}
{{- if default true .Attributes.anchor }}
{{- if default true .Attributes.anchor -}}
<a class="anchor" href="#{{ .Anchor }}">#</a>
{{- end -}}
</h{{ .Level }}>
@@ -16,7 +16,7 @@
{{- else with (resources.Get $path) -}}
{{- $destination = .RelPermalink -}}
{{- else -}}
{{- warnf "Reference '%s' not found in '%s'" .Destination .Page.Permalink -}}
{{- warnf "Reference '%s' not found in '%s'" .Destination .Page.RelPermalink -}}
{{- end -}}
{{- with $url.RawQuery -}}
+7 -7
View File
@@ -19,16 +19,16 @@
<li>
{{- $isRemote := (urls.Parse .URL).IsAbs -}}
<a href="{{ .URL }}"
{{- with $class }}class="{{ delimit . " " }}"{{ end -}}
{{- with .Title }}title="{{ . }}"{{ end -}}
{{- if $isRemote }}target="_blank" rel="noopener"{{ end -}}>
{{- with $class }} class="{{ delimit . " " }}"{{- end -}}
{{- with .Title }} title="{{ . }}"{{- end -}}
{{- if $isRemote }} target="_blank" rel="noopener"{{- end -}}>
{{- .Pre -}}
{{ template "book-menu-title" . }}
{{- template "book-menu-title" . -}}
{{- .Post -}}
</a>
{{- with .Children }}
{{ template "book-menu-hugo" (dict "Page" $.Page "Menu" .) }}
{{- end }}
{{- with .Children -}}
{{- template "book-menu-hugo" (dict "Page" $.Page "Menu" .) -}}
{{- end -}}
</li>
{{- end -}}
</ul>
+3 -1
View File
@@ -1,13 +1,15 @@
{{- if not (.Page.Store.Get "asciinema") -}}
<!-- Include asciinema player only first time -->
{{- /* remove whitespaces */ -}}
<link rel="stylesheet" href="{{ "asciinema/asciinema-player.css" | relURL }}" />
{{- /* remove whitespaces */ -}}
<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 -}}
{{- with (partial "docs/links/portable-image" (dict "Page" .Page "Destination" (index .Params "cast"))) -}}
{{- $opts := newScratch -}}
{{- $opts.Set "asciinema" $.Params -}}
{{- $opts.DeleteInMap "asciinema" "cast" -}}
+3 -2
View File
@@ -1,5 +1,6 @@
{{- $style := default "default" (.Get "style") -}}
<span class="book-badge {{ $style }}">
{{- with .Get "title" }}<span class="book-badge-title">{{ . | plainify }}</span>{{ end -}}
{{- with .Get "value" }}<span class="book-badge-value">{{ . | 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 -}}
</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 }}">
{{- .InnerDeindent -}}
</a>
{{- /* remove whitespaces */ -}}
+4 -7
View File
@@ -1,9 +1,7 @@
{{- /* remove whitespace */ -}}
{{- with .Get "href" -}}
{{- $destination := partial "docs/links/portable-link" (dict "Page" $.Page "Destination" .) -}}
<a class="book-card{{ with $.Get "class" }} {{ . }}{{ end }}" href="{{ $destination | safeURL }}">
<div><a class="book-card{{ with $.Get "class" }} {{ . }}{{ end }}" href="{{ . | safeURL }}">
{{- template "book-card-content" $ -}}
</a>
</a></div>
{{- else -}}
<div class="book-card{{ with .Get "class" }} {{ . }}{{ end }}">
{{- template "book-card-content" $ -}}
@@ -14,9 +12,8 @@
{{- with .Get "image" -}}
{{- $destination := partial "docs/links/portable-image" (dict "Page" $.Page "Destination" .) -}}
<img src="{{ $destination | safeURL }}" />
{{- end }}
{{- end -}}
<div class="markdown-inner">
{{ with .Inner }}{{ . }}{{ end }}
{{ with .Inner }}{{ . }}{{ end -}}
</div>
{{- end -}}
{{- /* remove whitespace */ -}}
+9 -9
View File
@@ -1,21 +1,21 @@
{{- $ratio := (split (.Get "ratio") ":") -}}
{{- 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 }}">
{{ range $index, $content := split .InnerDeindent "<--->" }}
{{- range $index, $content := split .InnerDeindent "<--->" -}}
{{- $grow := default 1 (index $ratio $index) -}}
<div class="flex-even markdown-inner" style="flex-grow: {{ $grow }};">
{{ $content | safeHTML }}
{{- $content | safeHTML -}}
</div>
{{ end }}
{{- end -}}
</div>
{{ else }}
{{- if .Get "ratio" }}<style>{{ range $index, $grow := $ratio }}
{{- else -}}
{{- if .Get "ratio" -}}<style>{{- range $index, $grow := $ratio -}}
.book-columns-{{ $.Ordinal }}>ul>li:nth-child({{ $index | add 1 }}){
flex-grow: {{ default 1 $grow }};
}
{{ end }}</style>{{ end -}}
{{- end -}}</style>{{- end -}}
<div class="book-columns book-columns-{{ .Ordinal }}{{ with .Get "class" }} {{ . }}{{ end }}">
{{ .InnerDeindent | safeHTML }}
{{ .Inner | safeHTML -}}
</div>
{{ end -}}
{{- end -}}
+5 -3
View File
@@ -1,7 +1,9 @@
{{- /* remove whitespaces */ -}}
<details {{ if or (.Get "open") (in .Params "open") }}open{{ end }}>
{{- $summary := cond .IsNamedParams (.Get "title") (.Get 0) -}}
<summary>{{ $summary | .Page.RenderString }}</summary>
{{- /* remove whitespaces */ -}}
<div class="markdown-inner">
{{ .InnerDeindent | safeHTML }}
</div>
</details>
{{ .Inner | safeHTML -}}
</div></details>
{{- /* remove whitespaces */ -}}
+3 -1
View File
@@ -1,3 +1,5 @@
{{- /* remove whitespaces */ -}}
<blockquote class="book-hint {{ default "default" (.Get 0) }}">
{{ .Inner | safeHTML }}
{{ .Inner | safeHTML -}}
</blockquote>
{{- /* remove whitespaces */ -}}
-1
View File
@@ -1,4 +1,3 @@
{{- /* remove whitespaces */ -}}
{{- $destination := partial "docs/links/portable-image" (dict "Page" .Page "Destination" (.Get "src")) -}}
<label class="book-image" for="book-image-toggle-{{ .Ordinal }}">
<input class="hidden toggle" type="checkbox" id="book-image-toggle-{{ .Ordinal }}" />
+10 -8
View File
@@ -1,19 +1,21 @@
{{- if not (.Page.Store.Get "katex") -}}
<!-- Include katex only first time -->
{{- /* remove whitespaces */ -}}
<link rel="stylesheet" href="{{ "katex/katex.min.css" | relURL }}" />
{{- /* remove whitespaces */ -}}
<script defer src="{{ "katex/katex.min.js" | relURL }}"></script>
{{ with resources.Get "katex.json" }}
<script defer src="{{ "katex/auto-render.min.js" | relURL }}" onload="renderMathInElement(document.body, {{ .Content | safeJS }});"></script>
{{ end }}
{{- with resources.Get "katex.json" -}}
<script defer src="{{ "katex/auto-render.min.js" | relURL }}" onload="renderMathInElement(document.body, {{ . | minify }});"></script>
{{- end -}}
{{- .Page.Store.Set "katex" true -}}
{{- end -}}
{{ if .Inner }}
{{- if .Inner -}}
<span>
{{- if .Get "display" }}
{{- if .Get "display" -}}
\[ {{ .Inner }} \]
{{ else }}
{{- else -}}
\( {{ .Inner }} \)
{{ end -}}
{{- end -}}
</span>
{{ end }}
{{- end -}}
+7 -5
View File
@@ -1,12 +1,14 @@
{{ if not (.Page.Store.Get "mermaid") }}
{{- if not (.Page.Store.Get "mermaid") -}}
<!-- Include mermaid only first time -->
{{- /* remove whitespaces */ -}}
<script src="{{ "mermaid.min.js" | relURL }}"></script>
{{ with resources.Get "mermaid.json" }}
{{- with resources.Get "mermaid.json" -}}
<script>mermaid.initialize({{ .Content | safeJS }})</script>
{{ end }}
{{ .Page.Store.Set "mermaid" true }}
{{ end }}
{{- end -}}
{{- .Page.Store.Set "mermaid" true -}}
{{- end -}}
<pre class="mermaid{{ with .Get "class" }} {{ . }}{{ end }}">
{{- .Inner | htmlEscape | safeHTML -}}
</pre>
{{- /* remove whitespaces */ -}}
+3 -1
View File
@@ -1,3 +1,5 @@
{{- /* remove whitespaces */ -}}
<div class="book-steps {{ with .Get "class" }}{{ . }}{{ end }}">
{{ .Inner }}
{{ .Inner -}}
</div>
{{- /* remove whitespaces */ -}}
+5 -2
View File
@@ -1,9 +1,12 @@
{{- $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 }} />
{{- /* remove whitespaces */ -}}
<label for="{{ $tab }}">
{{- .Get 0 -}}
</label>
{{- /* remove whitespaces */ -}}
<div class="book-tabs-content markdown-inner">
{{- .Inner -}}
{{ .Inner -}}
</div>
{{- /* remove whitespaces */ -}}
+3 -1
View File
@@ -1,3 +1,5 @@
{{- /* remove whitespaces */ -}}
<div class="book-tabs">
{{ .Inner }}
{{- .Inner -}}
</div>
{{- /* remove whitespaces */ -}}