diff options
author | tdro <tdro@noreply.example.com> | 2023-10-07 20:19:06 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2023-10-07 20:19:06 -0400 |
commit | 286b14e540b35dcb5ca30c507dd36c106d79d1a9 (patch) | |
tree | 0e41da3d3b76da9a6bd77fb7a71cd19c4c4ed97b /themes/default/layouts/_default/_markup/render-codeblock.html | |
parent | 9fabe86ebb7f4b3d04ccd0aabf3a0a62e5088e8c (diff) | |
download | canory-286b14e540b35dcb5ca30c507dd36c106d79d1a9.tar.gz canory-286b14e540b35dcb5ca30c507dd36c106d79d1a9.tar.bz2 canory-286b14e540b35dcb5ca30c507dd36c106d79d1a9.zip |
themes/default/layouts/_default/_markup/render-codeblock: Support content editable
Diffstat (limited to 'themes/default/layouts/_default/_markup/render-codeblock.html')
-rw-r--r-- | themes/default/layouts/_default/_markup/render-codeblock.html | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/themes/default/layouts/_default/_markup/render-codeblock.html b/themes/default/layouts/_default/_markup/render-codeblock.html index 1321d8e..542c9a6 100644 --- a/themes/default/layouts/_default/_markup/render-codeblock.html +++ b/themes/default/layouts/_default/_markup/render-codeblock.html @@ -3,6 +3,11 @@ {{- $options := .Attributes.options | default "default=1" -}} {{- $hash := print (truncate 3 "" (sha256 .Inner)) (truncate 3 "" (sha256 .Page.RelPermalink)) .Ordinal -}} {{- $id := print "code-block:" $hash | safeURL -}} +{{- $edit := "false" -}} + +{{- if not (in $options "linenos=1") -}} + {{- $edit = "true" -}} +{{- end -}} <code-block id="{{ $id }}" {{ if in (lower $options) "linenos" }}data-lines=""{{ end }}> <header> @@ -10,9 +15,11 @@ <a href="#{{ $id }}">{{ $type }}</a> </language-label> </header> - {{ highlight .Inner $type (print $options ",lineAnchors=" "code-line:" $hash) }} + <code-content contenteditable="{{ $edit }}"> + {{- highlight .Inner $type (print $options ",lineAnchors=" "code-line:" $hash) -}} + </code-content> </code-block> -{{ with $caption }} +{{- with $caption -}} <footer>{{ . | markdownify }}</footer> -{{ end }} +{{- end -}} |