Markdown footnotes not working
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.
- The entire footnote section is wrapped in
<section class="footnotes">
- The back reference link has the
footnote-backref
class - 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?
-
Changelog entry added, if necessary -
Documentation created/updated -
Tests added for this feature/bug -
Tested in all supported browsers -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the database guides -
Link to e2e tests MR added if this MR has Requires e2e tests label. See the Test Planning Process. -
Security reports checked/validated by reviewer