Shortcode and footnotes

Continuing the discussion from Isolation of links and footnotes inside codeblocks:

I can’t make this work.

This is my shortcode:

{{- /* HOW TO USE
{{% quotebox boxstyle="qbs_generic" qmarkstyle="qbm_doublequotationmark" boxcolour="qbc_blue" attribalign="txt_right" citeby="" citelink="" citerel="noopener external" pubtitle="" publink="" pubrel="noopener external" %}}
content
{{% /quotebox %}}
*/ -}}
{{- /* Changelog:
  1. To avoid confusion:
    * replaced src prefix with cite
    * replaced attrib prefix with pub
  2. converted to $var
*/ -}}
{{- $boxstyle     := .Get "boxstyle"    -}}
{{- $boxcolour    := .Get "boxcolour"   -}}
{{- $qmarkstyle   := .Get "qmarkstyle"  -}}
{{- $attribalign  := .Get "attribalign" -}}
{{- $citeby       := or (.Get "citeby")   (.Get "srctitle")   -}}
{{- $citelink     := or (.Get "citelink") (.Get "srclink")    -}}
{{- $citerel      := or (.Get "citerel")  (.Get "srcrel")     -}}
{{- $pubtitle     := or (.Get "pubtitle") (.Get "attribto")   -}}
{{- $publink      := or (.Get "publink")  (.Get "attriblink") -}}
{{- $pubrel       := or (.Get "pubrel")   (.Get "attribrel")  -}}
<figure class="quote_box {{ with $boxstyle }}{{ . }}{{ end }} {{ with $boxcolour }}{{ . }}{{ end }}">
  <blockquote class="{{ with $qmarkstyle }}{{ . }}{{ end }}"{{ with $citelink }} cite="{{ . }}"{{ end }}>
    {{- .Inner | markdownify -}}
  </blockquote>
  {{ with or $pubtitle $citeby }}
  <figcaption class="attribution_name {{ with $attribalign }}{{ . }}{{ end }}">
    <p><cite>{{ with $citelink }}<a href="{{ . }}" rel="dct:title {{ with $citerel }}{{ . }}{{ end }}" referrerpolicy="strict-origin-when-cross-origin">{{ end }}{{ with $citeby }}{{ . | markdownify }}{{ end }}{{ with $citelink }}</a>{{ end }}{{ with and $citeby $pubtitle }}{{ i18n "quote_src" }} {{ end }}</cite>{{ with $pubtitle }}{{ with $publink }}<a href="{{ . }}" rel="dct:creator {{ with $pubrel }}{{ . }}{{ end }}" referrerpolicy="strict-origin-when-cross-origin">{{ end }}{{ . | markdownify }}{{ with $publink }}</a>{{ end }}{{ end }}</p>
  </figcaption>
  {{ end }}
</figure>

However, when I add footnotes, it doesn’t render if it is outside. Example:

{{% quotebox boxstyle="qbs_generic" qmarkstyle="qbm_doublequotationmark" boxcolour="qbc_blue" attribalign="txt_right" citeby="" citelink="" citerel="noopener external" pubtitle="" publink="" pubrel="noopener external" %}}
content [^some-footnote]
{{% /quotebox %}}

[^some-footnote]: this is a footnote

It renders like this: Pasteboard - Uploaded Image

My only option is to do it like this:

{{% quotebox boxstyle="qbs_generic" qmarkstyle="qbm_doublequotationmark" boxcolour="qbc_blue" attribalign="txt_right" citeby="" citelink="" citerel="noopener external" pubtitle="" publink="" pubrel="noopener external" %}}
content [^some-footnote]
[^some-footnote]: this is a footnote
{{% /quotebox %}}

But the footnote will be rendered inside, like so: Pasteboard - Uploaded Image

I’ve been struggling with it since last year, and only took the time to ask about it today. ^^;;

Not sure what I did incorrectly to have broken the feature.

1) Don’t pass .Inner through markdownify when invoking a shortcode with the {{% foo %}} notation. That’s what the {{% foo %}} notation does.

2) Don’t trim the white space before {{ .Inner }}. You have to be careful when mixing markdown with HTML. See start and end conditions in https://spec.commonmark.org/0.30/#html-blocks.

Try it:

git clone --single-branch -b hugo-forum-topic-43832 https://github.com/jmooring/hugo-testing hugo-forum-topic-43832
cd hugo-forum-topic-43832
hugo server
1 Like

Ahhh!!! That’s what’s causing it. The two combination was keeping me from seeing it work. I only tried removing one but not the other.

Thank you very very much!

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