diff options
Diffstat (limited to 'themes/default/layouts/_default/_markup/render-codeblock.html')
-rw-r--r-- | themes/default/layouts/_default/_markup/render-codeblock.html | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/themes/default/layouts/_default/_markup/render-codeblock.html b/themes/default/layouts/_default/_markup/render-codeblock.html index f18f0d3..ab9a786 100644 --- a/themes/default/layouts/_default/_markup/render-codeblock.html +++ b/themes/default/layouts/_default/_markup/render-codeblock.html @@ -1,22 +1,25 @@ -{{- $caption := .Attributes.caption -}} -{{- $type := .Type | default "text" -}} -{{- $options := .Attributes.options | default "default=1" -}} -{{- $hash := print (truncate 8 "" (sha256 .Inner)) .Ordinal -}} -{{- $id := print "code-block-" $hash -}} +{{- $caption := .Attributes.caption -}} +{{- $type := .Type | default "text" -}} +{{- $options := .Attributes.options | default "default=1" -}} +{{- $hash := print (truncate 3 "" (sha256 .Inner)) (truncate 3 "" (sha256 .Page.RelPermalink)) .Ordinal -}} +{{- $id := print "code-block:" $hash | safeURL -}} +{{- $highlight := highlight .Inner $type (print $options ",lineAnchors=" "code-line:" $hash) -}} <code-block id="{{ $id }}" {{ if in (lower $options) "linenos" }}data-lines=""{{ end }}> <header> <language-label> <a href="#{{ $id }}">{{ $type }}</a> </language-label> - <button hidden=""> - {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/copy.svg")) }} - <span>Copy</span> - </button> </header> - {{ highlight .Inner $type (print $options ",lineAnchors=" "code-line-" $hash) }} + <code-content contenteditable="true" spellcheck="false"> + {{- replace $highlight + `class="lnlinks"` + `contenteditable="false" class="lnlinks"` + | safeHTML + -}} + </code-content> </code-block> -{{ with $caption }} +{{- with $caption -}} <footer>{{ . | markdownify }}</footer> -{{ end }} +{{- end -}} |