Skip to content

Ignore Markdown code when parsing wikilinks#53

Merged
TroyHernandez merged 3 commits into
mainfrom
fix/lint-skip-code-spans
Jun 7, 2026
Merged

Ignore Markdown code when parsing wikilinks#53
TroyHernandez merged 3 commits into
mainfrom
fix/lint-skip-code-spans

Conversation

@TroyHernandez

Copy link
Copy Markdown
Contributor

Problem

parse_wikilinks() ran a bare \[\[([^]]+)\]\] regex over every line, with no awareness of code regions. R's [[ ]] list indexing inside a fenced block or inline code span got extracted as a wikilink, so lint() reported spurious broken links for ordinary code samples:

  • `merged[[name]] <- project[[name]]` → broken link name
  • .subagent_registry[[uuid]] in a fenced diagram → broken link uuid

Fix

New strip_code() helper blanks out code before extraction:

  • Fenced blocks (``` / ~~~) are dropped via a vectorized cumsum fence tracker.
  • Inline spans (`...`) are stripped from the remaining lines.
  • An unterminated fence swallows to EOF (safer to miss a link than invent one).

parse_wikilinks() calls it first, so lint(), outlinks(), backlinks(), and vault_graph() all benefit.

Tests

Added a test_parse.R case with [[ ]] in both a fenced block and an inline span, asserting real links still resolve and code-embedded ones don't. Full suite: 583 results, all OK.

Version

Bumped to 0.6.3.3 (dev marker), separate commit.

R's [[ ]] list indexing inside fenced blocks or inline code spans was
being extracted as wikilinks, producing spurious broken-link findings in
lint(). strip_code() drops fenced blocks and inline spans before the
[[...]] regex runs, so outlinks/backlinks/vault_graph see real links only.
@TroyHernandez TroyHernandez deleted the fix/lint-skip-code-spans branch June 7, 2026 03:48
@TroyHernandez TroyHernandez restored the fix/lint-skip-code-spans branch June 7, 2026 03:48
@TroyHernandez TroyHernandez reopened this Jun 7, 2026
@TroyHernandez TroyHernandez merged commit c20e51d into main Jun 7, 2026
4 checks passed
@TroyHernandez TroyHernandez deleted the fix/lint-skip-code-spans branch June 7, 2026 03:55
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.

1 participant