I’d like to render images with titles as figures, through image render hooks, like this:
{{- if .Title -}}
<figure>
{{- end -}}
<img src="{{- $image_source.url | safeURL -}}" alt="{{- .Text -}}">
{{- if .Title -}}
<figcaption>
{{ .Title | .Page.RenderString }}
</figcaption>
</figure>
{{- end -}}
The problem is that if the title of image contains a footnote reference, it doesn’t get rendered as a footnote, but instead, just plain text. For instance,
Hijacking the image render hook to generate a figure element instead of an img element will produce invalid HTML. The figure element will be wrapped within a p element. That’s not allowed.
If you want to insert a figure, use the figure shortcode or create your own.
Well, I suppose that it is a sort of solution, if I just avoid using render hook altogether. But I’d still like to know if there’s a way, in a more general sense, to add footnote inside a rendering hook.