MichaBrugger / obsidian-footnotes

Makes creating footnotes in Obsidian more fun!
124 stars 15 forks source link

Re-index footnotes (already in readme, but putting it here) #20

Closed timfong888 closed 1 year ago

timfong888 commented 1 year ago

Reindexing, meaning, when a footnote is placed earlier in the document of an existing footnote, would do the following: 1) Renumber the new footnote to be in order from the previous footnote 2) Change each downstream footnote so that all footnote indexes in the document are in order, in sequence 3) Change the listing at the bottom by inserting the new footnote in its appropriate place 4) Change the listing by renumbering the existing footnotes that are downstream from the newly inserted one

This doesn't seem that straightforward since the code doesn't (as far as I can tell) doesn't currently have a way to do a "find and replace" at the time of insert based on line number within Obsidian document.

In other words, when a new footnote needs to be inserted at line n, only search through lines 1:n-1 to find the highest value of the footnote index. That value +1 will be the value of the footnote.

Similar logic for subsequent footnotes, but I don't think that's possible, so not really sure how this would be implemented.

Comprehensive-Jason commented 1 year ago

I've been discussing this possible feature in #14. Could you give the Linter plugin's Re-index footnotes feature a try and see if that satisfies your needs?

The dev of that plugin is much more familiar with find-and-replace type operations. There are a couple issues with that plugin's implementation of the function (discussed in #14 ), but I think it will be a lot easier to ask that dev to fix the issues rather than me making a completely new version of the same function. If you're okay with it, I will point users who want re-indexing to Linter in the README.

Comprehensive-Jason commented 1 year ago

I have decided to point users to Linter in the README and Plugin wiki if they want this feature.