From 83ada154b386f7807bb9d33a649d2194877ae1af Mon Sep 17 00:00:00 2001 From: Peter Kaufman Date: Thu, 1 Feb 2024 14:31:42 -0500 Subject: [PATCH] fixed an issue with links being present not properly being hanlded by re-index footnotes --- .../move-footnotes-to-the-bottom.test.ts | 31 ++++++++++++++++++ __tests__/re-index-footnotes.test.ts | 32 ++++++++++++++++++- src/rules/re-index-footnotes.ts | 2 +- 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/__tests__/move-footnotes-to-the-bottom.test.ts b/__tests__/move-footnotes-to-the-bottom.test.ts index 2938d7cf..179b0ffd 100644 --- a/__tests__/move-footnotes-to-the-bottom.test.ts +++ b/__tests__/move-footnotes-to-the-bottom.test.ts @@ -274,5 +274,36 @@ ruleTest({ [^3]: D `, }, + { // accounts for https://github.com/platers/obsidian-linter/issues/1006 + testName: 'Moving footnotes to the bottom of the file should properly order values even when links are present', + before: dedent` + Paragraph 1. [^4] + ${''} + Paragraph 2. [^1] + ${''} + Paragraph 3. [^2] + ${''} + Paragraph 4. [^3] + ${''} + [^1]: [1111](111) + [^2]: [2222](222) + [^3]: [3333](333) + [^4]: [4444](4444) + `, + after: dedent` + Paragraph 1. [^4] + ${''} + Paragraph 2. [^1] + ${''} + Paragraph 3. [^2] + ${''} + Paragraph 4. [^3] + ${''} + [^4]: [4444](4444) + [^1]: [1111](111) + [^2]: [2222](222) + [^3]: [3333](333) + `, + }, ], }); diff --git a/__tests__/re-index-footnotes.test.ts b/__tests__/re-index-footnotes.test.ts index 37b4eb6d..db4f47ce 100644 --- a/__tests__/re-index-footnotes.test.ts +++ b/__tests__/re-index-footnotes.test.ts @@ -93,6 +93,36 @@ ruleTest({ More text. `, }, + { // accounts for https://github.com/platers/obsidian-linter/issues/1006 + testName: 'Re-indexing footnotes with links as the referenced values should keep the references to text correlation', + before: dedent` + Paragraph 1. [^4] + ${''} + Paragraph 2. [^1] + ${''} + Paragraph 3. [^2] + ${''} + Paragraph 4. [^3] + ${''} + [^4]: [4444](4444) + [^1]: [1111](111) + [^2]: [2222](222) + [^3]: [3333](333) + `, + after: dedent` + Paragraph 1. [^1] + ${''} + Paragraph 2. [^2] + ${''} + Paragraph 3. [^3] + ${''} + Paragraph 4. [^4] + ${''} + [^1]: [4444](4444) + [^2]: [1111](111) + [^3]: [2222](222) + [^4]: [3333](333) + `, + }, ], }); - diff --git a/src/rules/re-index-footnotes.ts b/src/rules/re-index-footnotes.ts index 07dc0a7f..5ea5f1d8 100644 --- a/src/rules/re-index-footnotes.ts +++ b/src/rules/re-index-footnotes.ts @@ -13,7 +13,7 @@ export default class ReIndexFootnotes extends RuleBuilder ReIndexFootnotesOptions {