Markdown footnote anchors are not working, both in the documentation as well as in issues, merge requests, etc. It seems that id attributes are missing. Here is a footnote as an example: 1
The footnote redirect from the footnote text to the footnote itself on https://docs.gitlab.com/ee/user/markdown.html seems to work now, but the link from the footnote to the footnote text seems to lead to a ">" at the end of the ToC. Is there already an official version where the footnotes are working? Our gitlab server doesn't seem to have a fix yet. :/
We are also running into this issue with documentation on our hosted CE instance.
From what I can gather, the issue is not wrong anchor tags, but missing id attributes.
This is how it looks on docs.gitlab.com under the Footnotes headline:
<p> You can add footnotes to your text as follows.<supid="fnref1"><ahref="#fn1"rel="footnote">1</a></sup></p>
and the corresponding Footnote:
<liid="fn1"><p> This is my awesome footnote. <ahref="#fnref1"rev="footnote">↩</a></p></li>
And this is the broken code on the /help/ subpages on gitlab.com and hosted instances:
<pdir="auto"> You can add footnotes to your text as follows.<sup><ahref="#fn1">1</a></sup></p>
<li><p> This is my awesome footnote. <ahref="#fnref1"rev="footnote"><gl-emojidata-name="leftwards_arrow_with_hook"data-unicode-version="1.1"><imgclass="emoji"title=":leftwards_arrow_with_hook:"alt=":leftwards_arrow_with_hook:"src="/assets/emoji/leftwards_arrow_with_hook-504714c5559b1bd35aa469be83069a923d1a25f364cac08c10df0195749e7b26.png"width="20"height="20"align="absmiddle"></gl-emoji></a></p></li>
Note how the id attributes are missing, so the anchor tag cannot work.
Concerning the remark @ostrokach made about the footnote pointing to the toc. This seems to be an issue with the toc generation. For whatever reason the toc entry for the footnotes is generated differently than all other entries and actually contains the needed id attribute:
The issue concerning the broken link that @ostrokach posted may be unrelated, as the markdown contains a broken link. Though I would still mark this as a bug, albeit a separate one.
We are also affected by this when browsing a project's files in GitLab: markdown files with footnotes are rendered incorrectly and behave as described above for the /help subpages: the id attribute is missing from both the note reference and the foot note itself, so that no link work.
We sanitize the html generated from user supplied markdown pretty thoroughly - this is stripping off the id attribute from the <li> tag that wraps the footnote.
We would either need to whitelist the id attribute (which I'm not sure is wise) or add the ids back in another step, like we do for header anchors.
@digitalmoksha I actually see few issues with whitelisting the id attribute unless they would conflict with existing id's. An alternative could be to prefix those id's instead of sanitizing them out completely.
@MCMic actually the markdown processor itself doesn't do any sanitization - and markdown supports mixing markdown and html. So we have to sanitize on top of that.
@jonas1 the ids can definitely conflict - each piece of markdown processed (such as each individual comment), the footnote id numbering starts over.
So if the issue has one footnote, it gets referenced with id="fnref1". If a comment also adds a footnote, it gets the same id, id="fnref1"
I think what we can do is add a random number to each footnote id. So the first one might be id="fnref1-1234567" and the second one might be id="fnref1-987651"