From 8a5bbf460bb789b0bd8626127968afe3f45be2f6 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 21 May 2024 21:42:35 -0700 Subject: [PATCH] Trim whitespace in more places Signed-off-by: Danila Fedorin --- layouts/partials/geturl.html | 24 ++++++++-------- layouts/shortcodes/codelines.html | 46 +++++++++++++++---------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/layouts/partials/geturl.html b/layouts/partials/geturl.html index f501ae9..3a00321 100644 --- a/layouts/partials/geturl.html +++ b/layouts/partials/geturl.html @@ -1,12 +1,12 @@ -{{ $scratch := .scratch }} -{{ $scratch.Set "bestLength" -1 }} -{{ $scratch.Set "bestUrl" (printf "%s/code/%s" .siteSourceUrl .path) }} -{{ $filePath := .path }} -{{ range $path, $url := .submoduleLinks }} -{{ $bestLength := $scratch.Get "bestLength" }} -{{ if and (le $bestLength (len $path)) (hasPrefix $filePath $path) }} -{{ $scratch.Set "bestLength" (len $path) }} -{{ $scratch.Set "bestPath" $path }} -{{ $scratch.Set "bestUrl" (printf "%s%s" $url (strings.TrimPrefix $path $filePath)) }} -{{ end }} -{{ end }} +{{- $scratch := .scratch -}} +{{- $scratch.Set "bestLength" -1 -}} +{{- $scratch.Set "bestUrl" (printf "%s/code/%s" .siteSourceUrl .path) -}} +{{- $filePath := .path -}} +{{- range $path, $url := .submoduleLinks -}} +{{- $bestLength := $scratch.Get "bestLength" -}} +{{- if and (le $bestLength (len $path)) (hasPrefix $filePath $path) -}} +{{- $scratch.Set "bestLength" (len $path) -}} +{{- $scratch.Set "bestPath" $path -}} +{{- $scratch.Set "bestUrl" (printf "%s%s" $url (strings.TrimPrefix $path $filePath)) -}} +{{- end -}} +{{- end -}} diff --git a/layouts/shortcodes/codelines.html b/layouts/shortcodes/codelines.html index 5188e01..e71ad42 100644 --- a/layouts/shortcodes/codelines.html +++ b/layouts/shortcodes/codelines.html @@ -1,28 +1,28 @@ -{{ $source := (readFile (printf "code/%s" (.Get 1))) }} -{{ $allLines := split $source "\n" }} -{{ if not (eq (int (.Get 2)) 1) }} -{{ .Scratch.Set "remLines" (after (sub (int (.Get 2)) 1) $allLines) }} -{{ else }} -{{ .Scratch.Set "remLines" $allLines }} -{{ end }} -{{ $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) (.Scratch.Get "remLines") }} +{{- $source := (readFile (printf "code/%s" (.Get 1))) -}} +{{- $allLines := split $source "\n" -}} +{{- if not (eq (int (.Get 2)) 1) -}} +{{- .Scratch.Set "remLines" (after (sub (int (.Get 2)) 1) $allLines) -}} +{{- else -}} +{{- .Scratch.Set "remLines" $allLines -}} +{{- end -}} +{{- $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) (.Scratch.Get "remLines") -}} -{{ if (.Get 4) }} -{{ .Scratch.Set "opts" (printf ",%s" (.Get 4)) }} -{{ else }} -{{ .Scratch.Set "opts" "" }} -{{ end }} +{{- if (.Get 4) -}} +{{- .Scratch.Set "opts" (printf ",%s" (.Get 4)) -}} +{{- else -}} +{{- .Scratch.Set "opts" "" -}} +{{- end -}} -{{ if (.Get 5) }} -{{ .Scratch.Set "hidden" (.Get 5) }} -{{ end }} +{{- if (.Get 5) -}} +{{- .Scratch.Set "hidden" (.Get 5) -}} +{{- end -}} -{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }} -{{ partial "linerangestr.html" (dict "scratch" .Scratch "from" (.Get 2) "to" (.Get 3)) }} +{{- partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) -}} +{{- partial "linerangestr.html" (dict "scratch" .Scratch "from" (.Get 2) "to" (.Get 3)) -}} -{{ with (.Scratch.Get "hidden") }} +{{- with (.Scratch.Get "hidden") -}}
{{ . | markdownify }} -{{ end }} +{{- end -}} {{- $groupconfig := dict "url" (.Scratch.Get "bestUrl") "basePath" (.Scratch.Get "bestPath") @@ -34,7 +34,7 @@ "language" (.Get 0) "opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) (.Scratch.Get "opts")) -}} -{{ partial "highlightgroup.html" $groupconfig }} -{{ with (.Scratch.Get "hidden") }} +{{- partial "highlightgroup.html" $groupconfig -}} +{{- with (.Scratch.Get "hidden") -}}
-{{ end }} +{{- end -}}