diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-03-11 20:40:26 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-03-11 20:40:26 +0100 |
commit | 95d62004a07d8bb6d2b94a56112fd419db7eeb65 (patch) | |
tree | b0958861ece2af8aa1b3e14b604c4c49f0728793 /docs/layouts | |
parent | 68bf1511f2be39b6576d882d071196e477c72c9f (diff) | |
parent | c0290655825e7bb36e13fb39f89d85b392cf1adc (diff) |
Merge commit 'c0290655825e7bb36e13fb39f89d85b392cf1adc'
Diffstat (limited to 'docs/layouts')
-rw-r--r-- | docs/layouts/shortcodes/code.html | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/docs/layouts/shortcodes/code.html b/docs/layouts/shortcodes/code.html index 4c12b0f29..83220c47d 100644 --- a/docs/layouts/shortcodes/code.html +++ b/docs/layouts/shortcodes/code.html @@ -1,5 +1,10 @@ {{ $file := .Get "file" }} -{{ $isHTML := strings.HasSuffix $file "html" }} +{{ $.Scratch.Set "codeLang" "" }} +{{ $suffix := findRE "(\\.[^.]+)$" $file 1 }} +{{ with $suffix }} +{{ $.Scratch.Set "codeLang" (index . 0 | strings.TrimPrefix ".") }} +{{ end }} +{{ with .Get "codeLang" }}{{ $.Scratch.Set "codeLang" . }}{{ end }} <div class="code relative" id="{{ $file | urlize}}"> {{- with $file -}} <div class="filename san-serif f6 dib lh-solid pl2 pv2">{{.}}</div> @@ -11,7 +16,7 @@ {{/* Functionality located within filesaver.js The copy here is located in the css with .copy class so it can be replaced with JS on success */}} {{end}} <div class="code-copy-content nt3" {{with .Get "download"}}id="{{.}}"{{end}}> - {{ if .Get "nocode" }}{{ .Inner }}{{ else }}{{ if $isHTML }}{{- highlight .Inner "html" "" | -}}{{ else }}<pre><code>{{- .Inner | string -}}</code></pre>{{ end }}{{ end }} + {{ if .Get "nocode" }}{{ $.Inner }}{{ else }}{{ with $.Scratch.Get "codeLang" }}{{- highlight $.Inner . "" | -}}{{ else }}<pre><code>{{- .Inner | string -}}</code></pre>{{ end }}{{ end }} </div> </div> |