fix(linter): end index link paths at their own closing paren - #61
Merged
Conversation
A trailing parenthetical or a second link on the line made W_INDEX_ORPHAN fire for files the index does reference. Closes #60.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #60.
Problem
extract_markdown_link_pathin the orphan rule took a link destination from the first](torfind(')')— the last parenthesis on the line rather than the one closing the link. An index entry with a trailing parenthetical:yielded the path
tasks/alpha.md) (historical, superseded, which matches no file, soalpha.mdwas reported asW_INDEX_ORPHANdespite being right there in the index.Two links on one line broke both:
[Alpha](a.md) and [Beta](b.md)yieldsa.md) and [Beta](b.md, whose last component still ends in.md, so the.mdguard passed and a nonsense path was recorded as a legitimate reference. Usingfindfor the opening delimiter also meant only the first link on any line was considered.Fix
display::extract_link_pathsscans a line for every link, ending each destination at the parenthesis that closes its link, with nested parentheses balanced and angle-bracketed destinations unwrapped.display::extract_link_path(already doing the forward scan for a single link) now delegates to it.path.md "Title") is stripped, but only as a fallback — a bare path containing spaces is tried whole first, so[A](tasks/my file.md)still resolves.Tests
lash linttests over the issue's exact project: noW_INDEX_ORPHAN, while a genuinely unreferenced file is still flagged exactly once.