trwnh.com/unified.test.hugo/layouts/_default/_markup/render-codeblock.html

29 lines
No EOL
1 KiB
HTML

{{- $result := transform.HighlightCodeBlock . }}
{{- $caption := .Attributes.caption }}
{{- $title := .Attributes.title }}
{{- if $caption }}
{{- printf "<!-- begin figure with codeblock %s -->" (string (add .Ordinal 1)) | safeHTML }}
<figure class="figure-with-codeblock"{{if $title}} title="{{$title}}"{{end}}>
{{ with $title }}<header class="codeblock__header"><p class="codeblock__title">{{.}}</p></header>{{ end }}
<div class="codeblock highlight">
<pre class="chroma">
{{$result.Inner}}
</pre>
</div>
<figcaption>{{$caption | markdownify}}</figcaption>
</figure>
{{ printf "<!-- end figure with codeblock %s -->" (string (add .Ordinal 1)) | safeHTML }}
{{ else }}
{{- printf "<!-- begin codeblock %s -->" (string (add .Ordinal 1)) | safeHTML }}
<div class="codeblock highlight">
{{- with $title }}
<header class="codeblock__header">
<p class="codeblock__title">{{.}}</p>
</header>
{{- end }}
<pre class="chroma">
{{$result.Inner}}
</pre>
</div>
{{- printf "<!-- end codeblock %s -->" (string (add .Ordinal 1)) | safeHTML }}
{{ end }}