Skip to content

Commit

Permalink
Merge pull request #1007 from pjkaufman/master
Browse files Browse the repository at this point in the history
Fix `Re-Index Footnotes` Not Working for Markdown Link Values
  • Loading branch information
pjkaufman authored Feb 1, 2024
2 parents 4cd434c + 83ada15 commit 4a0724a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
31 changes: 31 additions & 0 deletions __tests__/move-footnotes-to-the-bottom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
`,
},
],
});
32 changes: 31 additions & 1 deletion __tests__/re-index-footnotes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
`,
},
],
});

2 changes: 1 addition & 1 deletion src/rules/re-index-footnotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class ReIndexFootnotes extends RuleBuilder<ReIndexFootnotesOption
nameKey: 'rules.re-index-footnotes.name',
descriptionKey: 'rules.re-index-footnotes.description',
type: RuleType.FOOTNOTE,
ruleIgnoreTypes: [IgnoreTypes.code, IgnoreTypes.inlineCode, IgnoreTypes.math, IgnoreTypes.yaml, IgnoreTypes.link, IgnoreTypes.wikiLink, IgnoreTypes.tag],
ruleIgnoreTypes: [IgnoreTypes.code, IgnoreTypes.inlineCode, IgnoreTypes.math, IgnoreTypes.yaml, IgnoreTypes.tag],
});
}
get OptionsClass(): new () => ReIndexFootnotesOptions {
Expand Down

0 comments on commit 4a0724a

Please sign in to comment.