Problem/Motivation

Footnote IDs have random strings added since #194558: Non-unique list item IDs in order to avoid duplicate IDs on pages which contain more than one block of formatted text with footnotes.

Since #3572013: Make citation appended string deterministic instead of random so it is consistent across requests for the same URL the IDs are stable as long as the reference text is the same. If the text changes, the anchor link to the reference changes.

In some cases, users are confident that they will never insert new footnotes between other footnotes (thereby changing the auto-number) or are never using auto-numbers, and they would prefer therefore to just have the anchor link match the citation ID or manually inserted citation text.

Steps to reproduce

  1. Add footnotes to text
  2. Change the text
  3. Notice that the anchor link changes

Proposed resolution

Add an option to the filter configuration to remove the hashed text portion of the anchor link altogether and just use the citation (or citation with suffix if identical and not collapsed).

Remaining tasks

  1. Merge request
  2. Test coverage

User interface changes

New option in filter configuration

API changes

N/A

Data model changes

N/A

CommentFileSizeAuthor
#2 make_random_ids_optional-3450120_1.patch3.18 KBjohn_b

Issue fork footnotes-3450120

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

John_B created an issue. See original summary.

john_b’s picture

Status: Active » Needs review
StatusFileSize
new3.18 KB

Attached patch adds a checkbox which makes the addition of a radom string to each footnote ID optional. Patch for current dev, does not apply to 3.1.0.

rudolfbyker’s picture

I also need this. Alternate solution: Use an ID like `node-x-footnote-y` where x is the node ID and y is the footnote's ordinal or value.

scott_euser’s picture

Status: Needs review » Needs work

Can switch away from random as long as its unique, e.g. perhaps as @rudolfbyker noted (though I haven't look in depth at implications). In any case needs MR + test coverage to match. Thanks!

scott_euser’s picture

Version: 3.1.x-dev » 4.0.x-dev

scott_euser changed the visibility of the branch 3450120-make-footnote-link-consistent to hidden.

scott_euser’s picture

Okay got a chance to hit this issue myself and I I like the suggestion in #4. Since status quo is always random, nobody could yet have a dedicated link to a specific footnote, so I don't think we need to make this opt-in/opt-out. Added comments to the MR to make it clear.

scott_euser’s picture

Status: Needs work » Needs review

Okay this is now ready, let me know if it works for you

dieterholvoet’s picture

Status: Needs review » Reviewed & tested by the community

For me this fixes the issue where links from citations to grouped references at the bottom of the page weren't working anymore.

dieterholvoet’s picture

Status: Reviewed & tested by the community » Needs work

Never mind, that doesn't fix it. I now have citations that link to #footnote1, while the footnote has an ID of footnote1-0. That's on a page with multiple text areas with footnotes and with all of them aggregated at the bottom of the page. This issue might be caused by the fact that the same footnote is referenced multiple times on the same page.

scott_euser’s picture

To note, in another issue #3572013: Make citation appended string deterministic instead of random so it is consistent across requests for the same URL I have been working on making them deterministic at least; so still having an appended suffix, but reliably the same (unless the content changes). That seems to have sorted a number of issues for us in a publication with ~1400 footnotes here: https://internationalaisafetyreport.org/publication/international-ai-saf... - worth considering for those following this issue? It could render this feature redundant as I think that approach gives best of both worlds BUT it still has the hash of the text which would change if the text changes (but then even with this one, with auto-numbering if you add a new footnote, you'd break links or be linking to wrong thing).

john_b’s picture

Our problem is that content creators have shared links to footnotes from way back assuming the IDs can be stable. Our old content does not change. A new system of deterministic links would be fine going forward but would be a problem for old links.

scott_euser’s picture

Maybe another checkbox/option in the Filter config to opt out of it then?

Can have a seperate follow-up issue later to eg group them into fieldsets or something to make the UI. a bit more obvious (e.g. advanced options type thing)

scott_euser’s picture

Title: Make random strings optional, to allow linking to footnotes. » Make hashed anchor link suffixes optional, to allow linking to the same footnote citation even if text changes
Issue summary: View changes

Okay I have updated the issue summary to be more clear and reflect the current state + what I'd consider the proposed resolution. Please comment if you agree and for those who are after the feature, feel free to contribute the merge request, I'd be happy to review and check.

scott_euser changed the visibility of the branch 3450120-make-consistent to hidden.

scott_euser changed the visibility of the branch 4.0.x to hidden.

scott_euser changed the visibility of the branch 3.0.x to hidden.

scott_euser’s picture

Status: Needs work » Needs review

Here's a quick draft of this, I tested with an auto-value + a set value on a clean install and it worked okay, but it definitely needs a more real-world test.

scott_euser’s picture

I'd ideally like to get this in the next release. Can one of the followers requesting this please take a moment to review. Would be greatly appreciated!

john_b’s picture

Status: Needs review » Reviewed & tested by the community

This is working on an established site with many footnotes. I looked at the code.

  • scott_euser committed ace3e11c on 4.0.x
    feat: #3450120 Make hashed anchor link suffixes optional, to allow...
scott_euser’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for confirming. Also updated to use existing method to avoid regressing on #3590374: Warning when > 26 footnotes on page in this scenario (a - z, aa, ab, etc). Added further test coverage of this via display via block as well in case.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.