From d03aa181e3608f2aefe0b2fa4e52a43cb4a63872 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Mon, 26 Aug 2019 18:48:12 -0700 Subject: [PATCH] Update the codelines shortcode --- themes/vanilla/layouts/shortcodes/codelines | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/themes/vanilla/layouts/shortcodes/codelines b/themes/vanilla/layouts/shortcodes/codelines index b5d16a6..d275582 100644 --- a/themes/vanilla/layouts/shortcodes/codelines +++ b/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) "" }}