Trim whitespace in more places

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
Danila Fedorin 2024-05-21 21:42:35 -07:00
parent 48bdf9ef08
commit 8a5bbf460b
2 changed files with 35 additions and 35 deletions

View File

@ -1,12 +1,12 @@
{{ $scratch := .scratch }} {{- $scratch := .scratch -}}
{{ $scratch.Set "bestLength" -1 }} {{- $scratch.Set "bestLength" -1 -}}
{{ $scratch.Set "bestUrl" (printf "%s/code/%s" .siteSourceUrl .path) }} {{- $scratch.Set "bestUrl" (printf "%s/code/%s" .siteSourceUrl .path) -}}
{{ $filePath := .path }} {{- $filePath := .path -}}
{{ range $path, $url := .submoduleLinks }} {{- range $path, $url := .submoduleLinks -}}
{{ $bestLength := $scratch.Get "bestLength" }} {{- $bestLength := $scratch.Get "bestLength" -}}
{{ if and (le $bestLength (len $path)) (hasPrefix $filePath $path) }} {{- if and (le $bestLength (len $path)) (hasPrefix $filePath $path) -}}
{{ $scratch.Set "bestLength" (len $path) }} {{- $scratch.Set "bestLength" (len $path) -}}
{{ $scratch.Set "bestPath" $path }} {{- $scratch.Set "bestPath" $path -}}
{{ $scratch.Set "bestUrl" (printf "%s%s" $url (strings.TrimPrefix $path $filePath)) }} {{- $scratch.Set "bestUrl" (printf "%s%s" $url (strings.TrimPrefix $path $filePath)) -}}
{{ end }} {{- end -}}
{{ end }} {{- end -}}

View File

@ -1,28 +1,28 @@
{{ $source := (readFile (printf "code/%s" (.Get 1))) }} {{- $source := (readFile (printf "code/%s" (.Get 1))) -}}
{{ $allLines := split $source "\n" }} {{- $allLines := split $source "\n" -}}
{{ if not (eq (int (.Get 2)) 1) }} {{- if not (eq (int (.Get 2)) 1) -}}
{{ .Scratch.Set "remLines" (after (sub (int (.Get 2)) 1) $allLines) }} {{- .Scratch.Set "remLines" (after (sub (int (.Get 2)) 1) $allLines) -}}
{{ else }} {{- else -}}
{{ .Scratch.Set "remLines" $allLines }} {{- .Scratch.Set "remLines" $allLines -}}
{{ end }} {{- end -}}
{{ $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) (.Scratch.Get "remLines") }} {{- $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) (.Scratch.Get "remLines") -}}
{{ if (.Get 4) }} {{- if (.Get 4) -}}
{{ .Scratch.Set "opts" (printf ",%s" (.Get 4)) }} {{- .Scratch.Set "opts" (printf ",%s" (.Get 4)) -}}
{{ else }} {{- else -}}
{{ .Scratch.Set "opts" "" }} {{- .Scratch.Set "opts" "" -}}
{{ end }} {{- end -}}
{{ if (.Get 5) }} {{- if (.Get 5) -}}
{{ .Scratch.Set "hidden" (.Get 5) }} {{- .Scratch.Set "hidden" (.Get 5) -}}
{{ end }} {{- end -}}
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }} {{- 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 "linerangestr.html" (dict "scratch" .Scratch "from" (.Get 2) "to" (.Get 3)) -}}
{{ with (.Scratch.Get "hidden") }} {{- with (.Scratch.Get "hidden") -}}
<details><summary>{{ . | markdownify }}</summary> <details><summary>{{ . | markdownify }}</summary>
{{ end }} {{- end -}}
{{- $groupconfig := dict {{- $groupconfig := dict
"url" (.Scratch.Get "bestUrl") "url" (.Scratch.Get "bestUrl")
"basePath" (.Scratch.Get "bestPath") "basePath" (.Scratch.Get "bestPath")
@ -34,7 +34,7 @@
"language" (.Get 0) "language" (.Get 0)
"opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) (.Scratch.Get "opts")) "opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) (.Scratch.Get "opts"))
-}} -}}
{{ partial "highlightgroup.html" $groupconfig }} {{- partial "highlightgroup.html" $groupconfig -}}
{{ with (.Scratch.Get "hidden") }} {{- with (.Scratch.Get "hidden") -}}
</details> </details>
{{ end }} {{- end -}}