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

29 lines
1 KiB
HTML
Raw Normal View History

{{- $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 }}
2024-10-12 18:45:14 +00:00
<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 }}