2019-08-20 20:12:18 -07:00
|
|
|
{{ $s := (readFile (printf "code/%s" (.Get 1))) }}
|
|
|
|
{{ $t := split $s "\n" }}
|
2019-08-26 18:48:12 -07:00
|
|
|
{{ 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") }}
|
2020-08-12 01:37:55 -07:00
|
|
|
{{ if (.Get 4) }}
|
|
|
|
{{ .Scratch.Set "opts" (printf ",%s" (.Get 4)) }}
|
|
|
|
{{ else }}
|
|
|
|
{{ .Scratch.Set "opts" "" }}
|
|
|
|
{{ end }}
|
2020-09-27 14:41:56 -07:00
|
|
|
<div class="highlight-group">
|
|
|
|
<div class="highlight-label">From <a href="https://dev.danilafe.com/Web-Projects/blog-static/src/branch/master/code/{{ .Get 1 }}">{{ path.Base (.Get 1) }}</a>,
|
|
|
|
{{ if eq (.Get 2) (.Get 3) }}line {{ .Get 2 }}{{ else }} lines {{ .Get 2 }} through {{ .Get 3 }}{{ end }}</div>
|
2020-09-27 14:47:25 -07:00
|
|
|
{{ highlight (delimit $v "\n") (.Get 0) (printf "linenos=table,linenostart=%d%s" (.Get 2) (.Scratch.Get "opts")) }}
|
2020-09-27 14:41:56 -07:00
|
|
|
</div>
|