Function to reindex footnotes

Love footnotes! Also noticed that it auto-increments when creating a new footnote, e.g. using keyboard shortcut.

workflow/steps:

  1. when deleting a footnote from the main text, the footnote doesn’t get deleted. This is okay in case of accidental deletion of the reference tag
  2. but when manually going down and deleting the footnote, no reindexing happens.

Here’s where no-reindexing could be a huge issue. Suppose you have 100 footnotes and now have to delete footnote #3. At this point it’s just not feasible to manually decrement all the 97 footnotes after it. It’d be a huge pain-point for the biggest footnote users.

One suggestion would be a note-wide footnote reindexing button, which can be a secondary function in the footnote button. Click it and all the footnotes in the note will be reindexed. Benefits:

  1. people tend to not mix footnotes format i.e. using index and text footnote. So it’s safe.
  2. this does not run dynamically when editing, but only when user triggers it; so it doesn’t impact editing performance.

Even better, this can also run each time when an actual footnote item (not the reference, since people might just be editing/moving it around) is deleted. I’m guessing implementation can be efficient if detection of footnote deletion is efficient, which should be (it’s similar to when markdown numbered list reindexes itself when item is added/removed).

note for developer: just be mindful of surjective footnotes (many to 1) if this is implemented since reindexing involves remapping values.

Hi there,

Glad to hear that you are loving footnotes, and many thanks for leaving us some feedback about them!

This behaviour may be intended, but i’ll pass this onto the development team to consider if not.

In the meantime if you’ve any further queries or questions, let me know as i’d be happy to help :slight_smile:

cc - @matteo

Hi there,

there is another case for when reindexing footnotes would be valuable. If one inserts a footnote above an existing one (e.g. [1]), the number of the new footnote is incremented (e.g. [2]). But in this case [1] comes after [2] which makes no sense from a reading point of view. In this case a renumbering of footnotes and reindexing would be appropriate.
In the note app Joplin footnotes are handled like this, even the inline footnotes.