2021-01-10 22:51:10 -08:00
|
|
|
{{ $source := (readFile (printf "code/%s" (.Get 1))) }}
|
|
|
|
{{ $allLines := split $source "\n" }}
|
2019-08-26 18:48:12 -07:00
|
|
|
{{ if not (eq (int (.Get 2)) 1) }}
|
2021-01-10 22:51:10 -08:00
|
|
|
{{ .Scratch.Set "remLines" (after (sub (int (.Get 2)) 1) $allLines) }}
|
2019-08-26 18:48:12 -07:00
|
|
|
{{ else }}
|
2021-01-10 22:51:10 -08:00
|
|
|
{{ .Scratch.Set "remLines" $allLines }}
|
2019-08-26 18:48:12 -07:00
|
|
|
{{ end }}
|
2021-01-10 22:51:10 -08:00
|
|
|
{{ $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) (.Scratch.Get "remLines") }}
|
|
|
|
|
2020-08-12 01:37:55 -07:00
|
|
|
{{ if (.Get 4) }}
|
|
|
|
{{ .Scratch.Set "opts" (printf ",%s" (.Get 4)) }}
|
|
|
|
{{ else }}
|
|
|
|
{{ .Scratch.Set "opts" "" }}
|
|
|
|
{{ end }}
|
2021-01-10 22:51:10 -08:00
|
|
|
|
2021-01-17 18:23:43 -08:00
|
|
|
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1) "submoduleLinks" .Site.Params.submoduleLinks) }}
|
|
|
|
|
|
|
|
{{ if eq (.Get 2) (.Get 3) }}
|
|
|
|
{{ .Scratch.Set "comment" (printf ", line %d" (.Get 2)) }}
|
|
|
|
{{ else }}
|
|
|
|
{{ .Scratch.Set "comment" (printf ", lines %d through %d" (.Get 2) (.Get 3)) }}
|
2021-01-10 22:51:10 -08:00
|
|
|
{{ end }}
|
2021-01-17 18:23:43 -08:00
|
|
|
{{ 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"))) }}
|