1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-12-25 18:22:09 +00:00
seirdy.one/layouts/shortcodes/codefigure.html

17 lines
607 B
HTML
Raw Normal View History

{{- $codeIndex := (.Page.Scratch.Get "codeIndex") -}}
2024-01-30 23:50:04 +00:00
{{- $id := (printf `code-%d` $codeIndex) -}}
{{- with .Get "id" -}}
{{- $id = . -}}
{{- end -}}
<!--
The full caption is too long for an aria-label;
just use the beginning for the label and the full thing for the aria description.
-->
<figure aria-labelledby="{{ $id }}" itemprop="hasPart" itemscope="" itemtype="https://schema.org/SoftwareSourceCode">
2022-06-09 01:17:33 +00:00
{{ if .Get "samp" -}}
{{ .Inner | .Page.RenderString | replaceRE "<code" "<samp" | replaceRE "</code>" "</samp>" | safeHTML -}}
{{- else -}}
{{ .Inner | .Page.RenderString -}}
2022-06-09 01:17:33 +00:00
{{- end }}
</figure>