blob: 435a12b7cd8005cf1bcbd9dc599aecf3d0c6d37e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
{{- $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 -}}
{{- $edit := "false" -}}
{{- if not (in $options "linenos=1") -}}
{{- $edit = "true" -}}
{{- end -}}
<code-block id="{{ $id }}" {{ if in (lower $options) "linenos" }}data-lines=""{{ end }}>
<header>
<language-label>
<a href="#{{ $id }}">{{ $type }}</a>
</language-label>
</header>
<code-content contenteditable="{{ $edit }}" spellcheck="false">
{{- highlight .Inner $type (print $options ",lineAnchors=" "code-line:" $hash) -}}
</code-content>
</code-block>
{{- with $caption -}}
<footer>{{ . | markdownify }}</footer>
{{- end -}}
|