Skip to content

fix(linter): end index link paths at their own closing paren - #61

Merged
fohara merged 1 commit into
mainfrom
fix/60-index-link-parsing
Aug 13, 2026
Merged

fix(linter): end index link paths at their own closing paren#61
fohara merged 1 commit into
mainfrom
fix/60-index-link-parsing

Conversation

@fohara

@fohara fohara commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Closes #60.

Problem

extract_markdown_link_path in the orphan rule took a link destination from the first ]( to rfind(')') — the last parenthesis on the line rather than the one closing the link. An index entry with a trailing parenthetical:

- [Alpha](tasks/alpha.md) (historical, superseded)

yielded the path tasks/alpha.md) (historical, superseded, which matches no file, so alpha.md was reported as W_INDEX_ORPHAN despite being right there in the index.

Two links on one line broke both: [Alpha](a.md) and [Beta](b.md) yields a.md) and [Beta](b.md, whose last component still ends in .md, so the .md guard passed and a nonsense path was recorded as a legitimate reference. Using find for the opening delimiter also meant only the first link on any line was considered.

Fix

  • display::extract_link_paths scans 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.
  • The orphan rule collects all destinations on a line and keeps those naming a Markdown file or a directory. A CommonMark link title (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

  • Unit tests on both scanners: trailing parenthetical, mid-sentence parenthetical, immediately-adjacent parenthetical, two links on one line, nested parens, titles, angle brackets, spaces.
  • End-to-end lash lint tests over the issue's exact project: no W_INDEX_ORPHAN, while a genuinely unreferenced file is still flagged exactly once.

A trailing parenthetical or a second link on the line made
W_INDEX_ORPHAN fire for files the index does reference.

Closes #60.
@fohara
fohara merged commit 520bea4 into main Aug 13, 2026
21 checks passed
@fohara
fohara deleted the fix/60-index-link-parsing branch August 13, 2026 19:27
@fohara fohara mentioned this pull request Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

W_INDEX_ORPHAN false positive: index link parsing uses rfind(')'), so a later ')' on the line hides the reference

1 participant