1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-09-20 12:12:09 +00:00
seirdy.one/layouts/_default/_markup/render-codeblock-figure.html
Rohan Kumar 84cde2e97f
Internal: create + use figure shortcodes + hooks
Create a for <figcaption> and a render hook for code snippets inside
figures, replacing some ugly and complex inline HTML in my markdown
sources.

The only visible change is slightly worse HTML alignment and programming
language indicators (with microdata).

This removed the need to use one of the regex replacements in the
processed_content.html shortcode, and increased the minimum required
Hugo version to 0.93.
2022-04-18 21:15:29 -07:00

23 lines
535 B
HTML

{{ $contents := .Inner | htmlEscape }}
{{ $samp := false }}
{{ with .Attributes }}
{{ range $k, $v := . }}
{{ if strings.HasPrefix $k "var" }}
{{ $after := printf `<var translate="yes">%s</var>` $v }}
{{ $contents = $contents | replaceRE $v $after }}
{{ else if and (eq $k "samp")}}
{{ $samp = $v }}
{{ end }}
{{ end }}
{{ end }}
<pre tabindex="0">
{{- if $samp -}}
<samp itemprop="text">
{{- $contents | safeHTML -}}
</samp>
{{- else -}}
<code itemprop="text">
{{- $contents | safeHTML -}}
</code>
{{- end -}}
</pre>