Browse Source

Update the codelines shortcode

sidenotes
Danila Fedorin 3 years ago
parent
commit
d03aa181e3
  1. 8
      themes/vanilla/layouts/shortcodes/codelines

8
themes/vanilla/layouts/shortcodes/codelines

@ -1,5 +1,9 @@
{{ $s := (readFile (printf "code/%s" (.Get 1))) }}
{{ $t := split $s "\n" }}
{{ $u := after (.Get 2) $t }}
{{ $v := first (sub (int (.Get 3)) (int (.Get 2))) $u }}
{{ if not (eq (int (.Get 2)) 1) }}
{{ .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) "" }}

Loading…
Cancel
Save