diff --git a/layouts/_default/_markup/render-blockquote.html b/layouts/_default/_markup/render-blockquote.html index 4b205ceff0..87cb807bb0 100644 --- a/layouts/_default/_markup/render-blockquote.html +++ b/layouts/_default/_markup/render-blockquote.html @@ -15,8 +15,7 @@ "title" $alerttitle "expanded" (cond (eq $alertsign "+") true (cond (eq $alertsign "-") false "")) ) }} -{{- else }} +{{ else -}}
- {{- $text | safeHTML }} --{{- end }} \ No newline at end of file +{{ $text | safeHTML }} +{{ end }} \ No newline at end of file diff --git a/layouts/_default/_markup/render-codeblock-math.html b/layouts/_default/_markup/render-codeblock-math.html index b036704879..1b500d5501 100644 --- a/layouts/_default/_markup/render-codeblock-math.html +++ b/layouts/_default/_markup/render-codeblock-math.html @@ -3,4 +3,4 @@ "attributes" .Attributes "content" .Inner "align" (index .Attributes "align") -) }} \ No newline at end of file +) }} diff --git a/layouts/_default/_markup/render-codeblock-mermaid.html b/layouts/_default/_markup/render-codeblock-mermaid.html index 43e379a091..0c26791f1d 100644 --- a/layouts/_default/_markup/render-codeblock-mermaid.html +++ b/layouts/_default/_markup/render-codeblock-mermaid.html @@ -3,4 +3,4 @@ "attributes" .Attributes "content" .Inner "align" (index .Attributes "align") -) }} \ No newline at end of file +) }} diff --git a/layouts/partials/shortcodes/attachments.html b/layouts/partials/shortcodes/attachments.html index 061c5675a9..be25c15ea6 100644 --- a/layouts/partials/shortcodes/attachments.html +++ b/layouts/partials/shortcodes/attachments.html @@ -5,7 +5,6 @@ {{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'attachments' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration#5180" $page.File.Filename }} {{- end }} {{- $color := .color | default "" }} -{{- $content := .content }} {{- $style := .style | default "default" }} {{- if and (not $color) (eq (len $color) 0) }} {{- $style = .style | default "transparent" }} @@ -46,7 +45,7 @@ {{- with $page }} {{- if ne .BundleType "leaf" }} {{- warnf "%q: UNSUPPORTED usage of 'attachments' shortcode found while using Hugo >= 0.112.0, use a leaf bundle instead; see https://mcshelby.github.io/hugo-theme-relearn/shortcodes/attachments/index.html#single-language" $page.File.Filename }} -{{- end }} +{{- end -}} {{- end }} \ No newline at end of file diff --git a/layouts/partials/shortcodes/children.html b/layouts/partials/shortcodes/children.html index a2e3931094..a7e96d66bd 100644 --- a/layouts/partials/shortcodes/children.html +++ b/layouts/partials/shortcodes/children.html @@ -5,80 +5,63 @@ {{- end }} {{- $showhidden := .showhidden | default false }} {{- if eq (printf "%T" $showhidden) "string" }} - {{- $showhidden = (eq $showhidden "true") }} + {{- $showhidden = (eq $showhidden "true") }} {{- end }} {{- $style := .style | default "li" }} {{- $depth := .depth | default 1 }} {{- $withDescription := .description | default false }} {{- if eq (printf "%T" $withDescription) "string" }} - {{- $withDescription = (eq $withDescription "true") }} + {{- $withDescription = (eq $withDescription "true") }} {{- end }} {{- $sortTerm := .sort | lower }} {{- $containerstyle := .containerstyle | default "ul" }} {{- if( and (not (eq $style "li") ) (eq $containerstyle "ul" ) ) }} - {{- $containerstyle = "div" }} + {{- $containerstyle = "div" }} {{- end }} -{{- with $page }} +{{- with $page -}} {{ (printf "<%s class=\"children children-%s children-sort-%s\">" $containerstyle $style $sortTerm)|safeHTML }} - {{- $pages := partial "pageHelper/pagesBy.html" (dict "page" . "by" $sortTerm) }} - {{- template "childs" dict "menu" $pages "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "page" . }} + {{- $pages := partial "pageHelper/pagesBy.html" (dict "page" . "by" $sortTerm) }} + {{- template "childs" dict "menu" $pages "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "page" . }} {{ (printf "%s>" $containerstyle)|safeHTML }} {{- end }} {{- define "childs" }} - {{ $page := .page }} - {{- range .menu }} - {{- $hidden := and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }} - {{- if not $hidden }} - {{- if not .IsHome }} - {{- if hasPrefix $.style "h" }} - {{- $num := sub ( int (trim $.style "h") ) 1 }} - {{- $numn := add $num $.count }} -{{ (printf "
{{ . }}
- {{- end }} -{{- end }} - - {{- else if eq $.style "li" }} -{{ (printf "<%s>" $.style)|safeHTML }}{{ if .RelPermalink }}{{ .Title }}{{ else }}{{ .Title }}{{ end }} -{{- if $.description }} - {{- with or .Description .Summary -}} -{{ . }}
- {{- end }} -{{- end }} - - {{- else }} -{{ (printf "<%s>" $.style)|safeHTML }}{{ if .RelPermalink }}{{ .Title }}{{ else }}{{ .Title }}{{ end }}{{ (printf "%s>" $.style)|safeHTML }} -{{- if $.description }} - {{- with or .Description .Summary -}} -{{ . }}
- {{- end }} -{{- end }} - - {{- end }} - {{- end }} - {{- if lt $.count $.depth }} - - {{- if eq $.style "li" }} + {{- end }} + {{- end }} + {{- end }} + {{- if lt $.count $.depth }} + {{- if eq $.style "li" }} {{- (printf "<%s>" $.containerstyle)|safeHTML }} - {{- end }} - - {{- $pages := partial "pageHelper/pagesBy.html" (dict "page" . "by" $.sortTerm) }} - {{- template "childs" dict "menu" $pages "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "page" $page }} - - {{- if eq $.style "li" }} + {{- end }} + {{- $pages := partial "pageHelper/pagesBy.html" (dict "page" . "by" $.sortTerm) }} + {{- template "childs" dict "menu" $pages "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "page" $page }} + {{- if eq $.style "li" }} {{- (printf "%s>" $.containerstyle)|safeHTML }} - {{- end }} - {{- end }} - - {{- if not .IsHome }} - {{- if eq $.style "li" }} + {{- end }} + {{- end }} + {{- if not .IsHome }} + {{- if eq $.style "li" }} {{- (printf "%s>" $.style)|safeHTML -}} - {{- end }} - {{- end }} - {{- end }} - {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} {{- end }} \ No newline at end of file diff --git a/layouts/partials/shortcodes/expand.html b/layouts/partials/shortcodes/expand.html index f78f2724be..bb4632eedc 100644 --- a/layouts/partials/shortcodes/expand.html +++ b/layouts/partials/shortcodes/expand.html @@ -3,7 +3,11 @@ {{- $page = .context }} {{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'expand' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration#5180" $page.File.Filename }} {{- end }} -{{- $content := .content }} +{{- $content := trim .content "\n\r\t " }} +{{- $hasContent := ne (strings.TrimLeft "" $content) "" }} +{{- if not (hasPrefix $content "<") }} + {{- $content = printf "
\n%s" $content }} +{{- end }} {{- $title := .title | default (T "Expand-title") }} {{- $title = trim $title " " }} {{- $expanded := .expanded | default false }} @@ -16,14 +20,16 @@ {{- end }} {{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $page) .id }} {{- with $page }} + {{- if $hasContent -}}
+ {{- end }} {{- end }} \ No newline at end of file diff --git a/layouts/partials/shortcodes/highlight.html b/layouts/partials/shortcodes/highlight.html index 94a58426ea..2b42ceae34 100644 --- a/layouts/partials/shortcodes/highlight.html +++ b/layouts/partials/shortcodes/highlight.html @@ -106,4 +106,6 @@ )}} {{- else }} {{- $content | safeHTML }} + {{- if and (not $hl_inline) (not (hasSuffix $content "\n")) }} +{{ end }} {{- end }} \ No newline at end of file diff --git a/layouts/partials/shortcodes/math.html b/layouts/partials/shortcodes/math.html index 8ed9daadd2..f78f3aec2f 100644 --- a/layouts/partials/shortcodes/math.html +++ b/layouts/partials/shortcodes/math.html @@ -21,7 +21,7 @@ {{- $attributes = merge $attributes (dict "class" (delimit (append (index $attributes "class" | default slice) "math" slice) " ")) }} {{- $attributes = merge $attributes (dict "class" (delimit (append (index $attributes "class" | default slice) (printf "align-%s" $align) slice) " ")) }} -{{- with $page }} +{{- with $page -}} " (trim $content "\n\r\t ")) "" }} +{{- $content := trim .content "\n\r\t " }} +{{- $hasContent := ne (strings.TrimLeft "" $content) "" }} +{{- if not (hasPrefix $content "<") }} + {{- $content = printf "
\n%s" $content }} +{{- end }} {{- $style := .style | default "default" }} {{- $title := .title }} {{- if not $title }} @@ -44,10 +47,10 @@ {{- end }} {{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $page) .id }} {{- with $page }} - {{- if or $icon $title $hasContent }} + {{- if or $icon $title $hasContent -}}
{{- end }} {{- end }} diff --git a/layouts/partials/shortcodes/openapi.html b/layouts/partials/shortcodes/openapi.html index 80ab2fc7df..d9a8f1053b 100644 --- a/layouts/partials/shortcodes/openapi.html +++ b/layouts/partials/shortcodes/openapi.html @@ -24,7 +24,7 @@ {{- end }} {{- end }} {{- end }} -{{- with $page }} +{{- with $page -}}" $content) "" }} + {{- if not (hasPrefix $content "<") }} + {{- $content = printf "
\n%s" $content }} + {{- end }} {{- $style := .style | default $style | default (cond (ne $color "") "filled" "initial") }} {{- $title := .title }} {{- if not $title }} @@ -40,14 +45,16 @@ {{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} {{- $icon = printf "fa-fw fas fa-%s" $icon }} {{- end }} - {{- $tabs = $tabs | append (dict - "color" $color - "content" .content - "icon" $icon - "itemid" (printf "%s%s" ($title | $page.RenderString | plainify | anchorize) ($icon | plainify | anchorize)) - "style" $style - "title" $title - ) }} + {{- if $hasContent }} + {{- $tabs = $tabs | append (dict + "color" $color + "content" $content + "icon" $icon + "itemid" (printf "%s%s" ($title | $page.RenderString | plainify | anchorize) ($icon | plainify | anchorize)) + "style" $style + "title" $title + ) }} + {{- end }} {{- end }} {{- end }} {{- $color = .color | default "" }} @@ -76,10 +83,11 @@ {{- $icon = printf "fa-fw fas fa-%s" $icon }} {{- end }} {{- with $page }} + {{- if len $tabs -}}
{{ end }} -{{ .content | safeHTML }}