-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with multiple references to the same footnote #25
Comments
Thanks @jsma, this looks like a worthwhile addition. In particular, the use of duplicate IDs is a concern, so regardless of the additional features, the fact that this prevents editors from inadvertently creating invalid HTML is a good thing.
|
Can you clarify? I haven't had my morning tea yet ;) The template tag was just a quick workaround for the limitation of the Django template language where you can't do a dictionary lookup using an attribute of another object e.g. |
Yes, sorry. I was instinctively wary at first when I saw your If it's just looking up items from a dict, which has previously been assembled e.g. when instantiating or As a worse example, a bad implementation might be if Like I said, you haven't given any example implementation, so I'm sorry I doubted you, but better safe than sorry. |
Ah, sorry if the link wasn't noticeable in my initial post but the implementation is here in my fork: https://github.com/GreenLightGo/wagtail-footnotes/pull/1/files |
The current implementation assigns an ID to
<sup>
elements based on the footnote's index.wagtail-footnotes/wagtail_footnotes/blocks.py
Line 47 in 0a13e37
This leads to duplicate id values so that browsers (tested in Chrome and Firefox) will only return to the first occurrence in the copy. This can cause issues if the first instance of "[1]" is not currently visible (e.g. in a collapsed accordion), the browser won't do anything when the "Back to content" link is clicked.
I've started working on an implementation to fix this situation which borrows ideas from Wikipedia. They handle this by always assigning unique IDs and then have individual links back to each reference in the copy, using letters of the alphabet. If there is a single reference, then the caret is clickable, otherwise the caret is not clickable, only the letters are:
I have a basic WIP in my fork so that the block rendering will handle assigning unique IDs to the links and tracks these on the page object so when footnotes are rendered, they can be accessed.
This WIP does not currently change anything on the front-end. I'm still experimenting but so far can solve our issue by using a custom template and template tag to process multiple back links. For simplicity, I'm just using integers as the link text but it shouldn't be too hard to convert these to letters of the alphabet a la Wikipedia:
And a simple template tag since we can't do variable lookups in dictionaries:
Let me know if something like this could be considered for inclusion. Happy to make a formal and comprehensive PR, but looking for feedback first. Thanks!
The text was updated successfully, but these errors were encountered: