Break up code creating highlight groups and pass in line numbers

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
Danila Fedorin 2024-05-21 20:39:21 -07:00
parent a6a14c3909
commit 67da389005
2 changed files with 20 additions and 2 deletions

View File

@ -1,2 +1,10 @@
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }}
{{ partial "highlightgroup.html" (dict "url" (.Scratch.Get "bestUrl") "path" (.Get 1) "comment" ", entire file" "code" (readFile (printf "code/%s" (.Get 1))) "language" (.Get 0) "opts" "linenos=table") }}
{{ $groupconfig := dict
"url" (.Scratch.Get "bestUrl")
"path" (.Get 1)
"comment" ", entire file"
"code" (readFile (printf "code/%s" (.Get 1)))
"language" (.Get 0)
"opts" "linenos=table"
}}
{{ partial "highlightgroup.html" $groupconfig }}

View File

@ -23,7 +23,17 @@
{{ with (.Scratch.Get "hidden") }}
<details><summary>{{ . | markdownify }}</summary>
{{ end }}
{{ partial "highlightgroup.html" (dict "url" (.Scratch.Get "bestUrl") "path" (.Get 1) "comment" (.Scratch.Get "comment") "code" (delimit $lines "\n") "language" (.Get 0) "opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) (.Scratch.Get "opts"))) }}
{{ $groupconfig := dict
"url" (.Scratch.Get "bestUrl")
"path" (.Get 1)
"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"))
}}
{{ partial "highlightgroup.html" $groupconfig }}
{{ with (.Scratch.Get "hidden") }}
</details>
{{ end }}