Update the codelines shortcode

This commit is contained in:
Danila Fedorin 2019-08-26 18:48:12 -07:00
parent 94d242414f
commit d03aa181e3

View File

@ -1,5 +1,9 @@
{{ $s := (readFile (printf "code/%s" (.Get 1))) }} {{ $s := (readFile (printf "code/%s" (.Get 1))) }}
{{ $t := split $s "\n" }} {{ $t := split $s "\n" }}
{{ $u := after (.Get 2) $t }} {{ if not (eq (int (.Get 2)) 1) }}
{{ $v := first (sub (int (.Get 3)) (int (.Get 2))) $u }} {{ .Scratch.Set "u" (after (sub (int (.Get 2)) 1) $t) }}
{{ else }}
{{ .Scratch.Set "u" $t }}
{{ end }}
{{ $v := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) (.Scratch.Get "u") }}
{{ highlight (delimit $v "\n") (.Get 0) "" }} {{ highlight (delimit $v "\n") (.Get 0) "" }}