Question: add to footnote in a render hook?

I’d like to render images with titles as figures, through image render hooks, like this:

{{- if .Title -}}
{{- end -}}

<img src="{{- $image_source.url | safeURL -}}" alt="{{- .Text -}}">

{{- if .Title -}}
        {{ .Title | .Page.RenderString }}
{{- 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,

![image](/image.png "title[^1]")


[^1]: Footnote content

Is there a solution?


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.

1 Like

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.

There is not. Footnotes are handled by the markdown renderer, and render hooks short circuit that.

I see. Thanks mate.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.