One way of splitting the .Content
variable would be to use conditional logic with the strings.Contains
method along with the split
and index
functions.
The following is untested but it might work.
{{/* store the beginning of the footnotes specific HTML generated by the Markdown processor into a variable */}}
{{ $footnotes:= `<section class="footnotes" role="doc-endnotes">` }}
{{ if strings.Contains .Content $footnotes }}
{{/* split content and store the result into a variable */}}
{{ $split := split .Content $footnotes }}
{{/* render content before footnotes */}}
{{ index $split 0 | safeHTML }}
<! -- fancy HTML --!>
{{/* render footnotes */}}
{{ index $split 1 | safeHTML }}
{{ else }}
{{ .Content }}
{{ end }}