Links within footnotes break the footnote
Describe the bug
When adding links to footnote text, either before or after creating the footnote (turning it into a <sup> element), the links is wrapped in its own <sup>, and any text before and after is wrapped in their own <sup> elements.
Steps to reproduce
- Add a link to part of a string which you want to turn into a footnote.
- Turn that text into a footnote.
Craft CMS version
5.7.1.1
Plugin version
5.1.0
Multi-site?
No
Additional context
No response
I'll see what can be done about this, but I believe it's largely due to how CKEditor handles the sup element and other tags like an anchor tag. Secondly, it's also a little tricky in that footnotes are themselves considered to be links.
We're probably going to have to revise how the footnotes are handled anyway to address this. Rather than relying on using a <sup> element, it'll probably end up being similar to a link node where you can add whatever content you like.
Thanks for the explanation Josh, sounds tricky. It's too bad CKE handles things so differently, as I was using links inside footnotes without issues in the Redactor version.
Just discovered on a current project that any inline markup breaks the footnote in the same manner (e.g. bold, italics, etc). Given that things like publication titles are frequently inside footnote/endnote content, and those are routinely italicized, this issue is wreaking more havoc on me than I thought!
Yeah, I'll need to figure this one out sooner rather than later, and rethink my approach. Will keep you posted (just not going to be a quick fix!)
Ran into this too. For now, I chose the nuclear option – a regex that unwraps the <sup class="footnote"> elements:
$html = preg_replace_callback(
'#<(\w+)[^>]*>\s*(<sup\s+class="footnote">.*?</sup>)\s*</\1>#i',
function ($matches) {
return $matches[2];
},
$html
);
Hi, was there any update on this? Have also just run into the same issue
Haven't had the chance to look at this, but it's essentially a brand-new implementation I need to look at.
For others following, the route I've decided on for now is to instruct my clients to use markdown for formatting within each footnote, and then I apply the markdown filter to the footnotes in-template.
Just noting that we recently discovered this is impacting a client site as well. Looking forward to a resolution.