Skip to content

Markdown footnotes not working

Brett Walker requested to merge 26375-markdown-footnotes-not-working into master

What does this MR do?

The sanitization filter removes all the footnote classes and ids. We now enable ids for footnotes, and add back the classes for wrapping the footnotes (allowing them to be styled properly).

Footnotes are numbered the same - the first one has id=fn1, the second is id=fn2, etc. In order to allow footnotes when rendering multiple markdown blocks on a page, we need to make each footnote reference unique.

We add a random number to each footnote (the same number can be used for a single render). So you get id=fn1-4335 and id=fn2-4335.

Note to UI/FE: In order to allow for easier styling, classes generated by CommonMark were carried through into the footnotes.

  1. The entire footnote section is wrapped in <section class="footnotes">
  2. The back reference link has the footnote-backref class
  3. The superscripted reference has the footnot-ref class
<p dir="auto">
  one footnote<sup class="footnote-ref"><a href="#fn1-9351" id="fnref1-9351">1</a></sup>
</p>
<section class="footnotes">
  <ol>
    <li id="fn1-9351">
      <p>one <a href="#fnref1-9351" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1"></gl-emoji></a></p>
    </li>
  </ol>
</section>

What are the relevant issue numbers?

Closes #26375 (closed)

Does this MR meet the acceptance criteria?

Edited by Brett Walker

Merge request reports