{{- $root := .Get "root" | default "alchemist" -}} {{- $path := .Get "path" | default "README.md" | printf "%s/%s" $root -}} {{- $content := readFile $path | htmlUnescape -}} {{- $content := split $content "\n" -}} {{- $start := .Get "from" | default "1" | int | add -1 }} {{- $end := .Get "to" | default (len $content) | int }} {{- $end := sub $end $start }} {{- $content := after $start (first (add $start $end) $content) -}} {{- $content := delimit $content "\n" -}} {{- $highlight := .Get "highlight" | default "true" -}} {{- if eq $highlight "true" }} {{- $language := .Get "language" | default ( cond (or (strings.HasSuffix $path ".kt") (strings.HasSuffix $path ".kts")) "kotlin" ( cond (strings.HasSuffix $path ".yml") "yaml" ( cond (strings.HasSuffix $path ".md") "markdown" ( replaceRE "^.*\\.(\\w+)$" "$1" $path ) ) ) ) -}}
Click to show / hide code
{{- else -}} {{- $content -}} {{- end -}}