diff --git a/layouts/partials/highlightgroup.html b/layouts/partials/highlightgroup.html index ff4f92b..34387e6 100644 --- a/layouts/partials/highlightgroup.html +++ b/layouts/partials/highlightgroup.html @@ -1,8 +1,9 @@ -{{- page.Scratch.Set "highlightGroupAttrs" (printf "data-base-path=\"%s\" data-file-path=\"%v\"" .basePath .path) -}} +{{- $scratch := newScratch -}} +{{- $scratch.Set "highlightGroupAttrs" (printf "data-base-path=\"%s\" data-file-path=\"%v\"" .basePath .path) -}} {{- if (or .firstLine .lastLine) -}} -{{- page.Scratch.Add "highlightGroupAttrs" (printf " data-first-line=\"%v\" data-last-line=\"%v\"" .firstLine .lastLine) -}} +{{- $scratch.Add "highlightGroupAttrs" (printf " data-first-line=\"%v\" data-last-line=\"%v\"" .firstLine .lastLine) -}} {{- end -}} {{- if eq (lower .language) "agda" -}} -{{- page.Scratch.Add "highlightGroupAttrs" " data-agda-block" -}} +{{- $scratch.Add "highlightGroupAttrs" " data-agda-block" -}} {{- end -}} -{{ partial "group.html" (dict "url" .url "path" .path "comment" .comment "content" (highlight .code .language .opts) "attrs" (page.Scratch.Get "highlightGroupAttrs")) }} +{{ partial "group.html" (dict "url" .url "path" .path "comment" .comment "content" (highlight .code .language .opts) "attrs" ($scratch.Get "highlightGroupAttrs")) }} diff --git a/layouts/shortcodes/block.html b/layouts/shortcodes/block.html index 4169e92..2da311e 100644 --- a/layouts/shortcodes/block.html +++ b/layouts/shortcodes/block.html @@ -1,3 +1,3 @@
- {{ .Inner }} + {{- .Inner -}}
diff --git a/layouts/shortcodes/codeblock.html b/layouts/shortcodes/codeblock.html index 9f0ae45..fc3731b 100644 --- a/layouts/shortcodes/codeblock.html +++ b/layouts/shortcodes/codeblock.html @@ -1,11 +1,12 @@ -{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1)) }} +{{- $scratch := newScratch -}} +{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 1)) -}} {{- $groupconfig := dict - "url" (.Scratch.Get "bestUrl") - "basePath" (.Scratch.Get "bestPath") + "url" ($scratch.Get "bestUrl") + "basePath" ($scratch.Get "bestPath") "path" (.Get 1) "comment" ", entire file" "code" (readFile (printf "code/%s" (.Get 1))) "language" (.Get 0) "opts" "linenos=table" -}} -{{ partial "highlightgroup.html" $groupconfig }} +{{- partial "highlightgroup.html" $groupconfig -}} diff --git a/layouts/shortcodes/codelines.html b/layouts/shortcodes/codelines.html index 7a032e2..90d127b 100644 --- a/layouts/shortcodes/codelines.html +++ b/layouts/shortcodes/codelines.html @@ -1,40 +1,41 @@ {{- $source := (readFile (printf "code/%s" (.Get 1))) -}} {{- $allLines := split $source "\n" -}} +{{- $scratch := newScratch -}} {{- 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 -}} -{{- .Scratch.Set "remLines" $allLines -}} +{{- $scratch.Set "remLines" $allLines -}} {{- 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) -}} -{{- .Scratch.Set "opts" (printf ",%s" (.Get 4)) -}} +{{- $scratch.Set "opts" (printf ",%s" (.Get 4)) -}} {{- else -}} -{{- .Scratch.Set "opts" "" -}} +{{- $scratch.Set "opts" "" -}} {{- end -}} {{- if (.Get 5) -}} -{{- .Scratch.Set "hidden" (.Get 5) -}} +{{- $scratch.Set "hidden" (.Get 5) -}} {{- end -}} -{{- partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1)) -}} -{{- partial "linerangestr.html" (dict "scratch" .Scratch "from" (.Get 2) "to" (.Get 3)) -}} +{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 1)) -}} +{{- partial "linerangestr.html" (dict "scratch" $scratch "from" (.Get 2) "to" (.Get 3)) -}} -{{- with (.Scratch.Get "hidden") -}} -
{{ . | markdownify }} +{{- with ($scratch.Get "hidden") -}} +
{{- . | markdownify -}} {{- end -}} {{- $groupconfig := dict - "url" (.Scratch.Get "bestUrl") - "basePath" (.Scratch.Get "bestPath") + "url" ($scratch.Get "bestUrl") + "basePath" ($scratch.Get "bestPath") "path" (.Get 1) - "comment" (.Scratch.Get "comment") + "comment" ($scratch.Get "comment") "code" (delimit $lines "\n") "firstLine" (int (.Get 2)) "lastLine" (int (.Get 3)) "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 -}} -{{- with (.Scratch.Get "hidden") -}} +{{- with ($scratch.Get "hidden") -}}
{{- end -}} diff --git a/layouts/shortcodes/codeurl.html b/layouts/shortcodes/codeurl.html index 6854324..f97d5a5 100644 --- a/layouts/shortcodes/codeurl.html +++ b/layouts/shortcodes/codeurl.html @@ -1,2 +1,3 @@ -{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 0)) }} -{{- .Scratch.Get "bestUrl" -}} +{{- $scratch := newScratch -}} +{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 0)) -}} +{{- $scratch.Get "bestUrl" -}} diff --git a/layouts/shortcodes/details.html b/layouts/shortcodes/details.html index 5b99942..e63e260 100644 --- a/layouts/shortcodes/details.html +++ b/layouts/shortcodes/details.html @@ -1,4 +1,4 @@
- {{ .Get "summary" | markdownify }} - {{ .Inner | markdownify }} + {{- .Get "summary" | markdownify -}} + {{- .Inner | markdownify -}}
diff --git a/layouts/shortcodes/dialog.html b/layouts/shortcodes/dialog.html index 68e0266..57ab011 100644 --- a/layouts/shortcodes/dialog.html +++ b/layouts/shortcodes/dialog.html @@ -1,3 +1,3 @@

- {{ .Inner }} + {{- .Inner -}}

diff --git a/layouts/shortcodes/githubsnippet.html b/layouts/shortcodes/githubsnippet.html index 4629313..6ffc901 100644 --- a/layouts/shortcodes/githubsnippet.html +++ b/layouts/shortcodes/githubsnippet.html @@ -5,6 +5,7 @@ {{- $line := .Get 4 -}} {{- $lines := split (trim .Inner "\n") "\n" -}} +{{- $scratch := newScratch -}} {{- $url := printf "https://github.com/%s/blob/%s/%s#L%d" $repo $commit $file $line -}} -{{- partial "linerangestr.html" (dict "scratch" .Scratch "from" 0 "to" $line) -}} -{{- partial "highlightgroup.html" (dict "url" $url "path" $file "comment" (.Scratch.Get "comment") "code" (trim .Inner "\n") "language" $lang) -}} +{{- partial "linerangestr.html" (dict "scratch" $scratch "from" 0 "to" $line) -}} +{{- partial "highlightgroup.html" (dict "url" $url "path" $file "comment" ($scratch.Get "comment") "code" (trim .Inner "\n") "language" $lang) -}} diff --git a/layouts/shortcodes/message.html b/layouts/shortcodes/message.html index 6a1c5c8..4c84f9f 100644 --- a/layouts/shortcodes/message.html +++ b/layouts/shortcodes/message.html @@ -1,10 +1,10 @@ - {{ if (eq (.Get 1) "reader") }} - {{ partial "icon.html" "moon" }} - {{ else }} - {{ partial "icon.html" "sun" }} - {{ end }} + {{- if (eq (.Get 1) "reader") -}} + {{- partial "icon.html" "moon" -}} + {{- else -}} + {{- partial "icon.html" "sun" -}} + {{- end -}} - {{ .Inner }} + {{- .Inner -}} diff --git a/layouts/shortcodes/rawblock.html b/layouts/shortcodes/rawblock.html index 01a42bb..9511479 100644 --- a/layouts/shortcodes/rawblock.html +++ b/layouts/shortcodes/rawblock.html @@ -1,9 +1,10 @@ -{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 0) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }} +{{- $scratch := newScratch -}} +{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 0) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) -}} {{- $groupconfig := dict - "url" (.Scratch.Get "bestUrl") - "basePath" (.Scratch.Get "bestPath") + "url" ($scratch.Get "bestUrl") + "basePath" ($scratch.Get "bestPath") "path" (.Get 0) "comment" ", entire file" "content" (safeHTML (printf "
%s
" (htmlEscape (readFile (printf "code/%s" (.Get 0)))))) -}} -{{ partial "group.html" $groupconfig }} +{{- partial "group.html" $groupconfig -}} diff --git a/layouts/shortcodes/sidenote.html b/layouts/shortcodes/sidenote.html index 65dda90..e488f9c 100644 --- a/layouts/shortcodes/sidenote.html +++ b/layouts/shortcodes/sidenote.html @@ -1,13 +1,13 @@ - - -{{ if $offset := .Get 3 }} - -{{ else }} - -{{ end }} -[{{ i18n "note" }}: -{{ .Inner }} + + +{{- if $offset := .Get 3 -}} + +{{- else -}} + +{{- end -}} +[{{- i18n "note" -}}: +{{- .Inner -}} ] diff --git a/layouts/shortcodes/todo.html b/layouts/shortcodes/todo.html index b8e2537..e93f0fa 100644 --- a/layouts/shortcodes/todo.html +++ b/layouts/shortcodes/todo.html @@ -1,3 +1,3 @@
- TODO: {{ .Inner }} + TODO: {{- .Inner -}}