Repository navigation
fix: skip link syntax inside code when extracting links - #49
Open
radish-miyazaki wants to merge 2 commits into
Open
radish-miyazaki wants to merge 2 commits into
radish-miyazaki wants to merge 2 commits into
Conversation
extractLinks scanned the raw body for [text](target), so Go code such as errors.AsType[*E](err) inside an inline code span or a fenced code block was reported as a broken link. Scan a copy masked by maskCode, the same masking footnote scanning has used since okfcli#33. maskCode preserves byte offsets, so text and target are still sliced from the original body. graph and backlinks call ExtractLinks, so they stop seeing these false links too. Closes okfcli#48 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also shorten the extractLinks doc comment; maskCode's comment already explains why code is masked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
What
extractLinksnow scans a copy of the body masked bymaskCode, so[text](target)inside inline code spans and fenced code blocks is no longer treated as a link.Why
Go code that calls a generic function with an explicit type argument, such as
errors.AsType[*E](err), has the[...](...)shape. When it appears in documentation,validatereported it asokf/links/broken(anERRORbefore #33, aWARNsince). See #48 for the repro.#33 added
maskCodeso that footnote scanning skips code (#26). This change applies the same masking to link extraction.How
extractLinksfinds[,],(and)in the masked copy.maskCodepreserves byte offsets, so text and target are still sliced from the original body. A link whose text contains code, such as[`cfg`](cfg.md), keeps its original text.graphandbacklinkscallExtractLinks, so they stop seeing these false links too.maskCodedoc comment and added one sentence to the README's validation section.Tests
Regression tests, written first and failing before the fix:
TestExtractLinks_IgnoresCode: inline code and a fenced block yield no links; a real link and a link with code in its text are still extracted with their original text.TestValidate_LinkInCodeIgnored: nobroken linkfinding for code-only link syntax.Local checks:
Closes #48
Drafted with Claude Code, reviewed and tested locally.
🤖 Generated with Claude Code