Use CommonMark for shared Markdown link extraction - #154
Merged
Merged
Conversation
Replace handwritten link extraction with the shared CommonMark/GFM parser. Preserve source offsets, vendor table defenses, classification policies, and request budgets. Add extraction and consumer regressions covering references, nested destinations, code and comments, entity decoding, images, and sampling. Document intentional behavior corrections. Fixes #151
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Score-affecting behavior changed without the repository-required scoring-version and synchronized documentation updates.
Review effort: Balanced
Findings: 1
What changed in this PR
Replaces handwritten Markdown link extraction with shared CommonMark/GFM parsing across discovery, validation, portability, and pagination.
Changes:
- Adds parser-backed extraction with correct references, decoding, offsets, and exclusions.
- Preserves consumer-specific URL and pagination behavior.
- Adds broad regression coverage and documentation.
| File | Description |
|---|---|
src/helpers/parse-markdown.ts |
Adds shared CommonMark/GFM parser. |
src/helpers/classify-markdown-links.ts |
Replaces manual link scanning with AST extraction. |
src/helpers/detect-pagination.ts |
Reuses shared parser and scanner. |
src/checks/content-discoverability/llms-txt-valid.ts |
Uses shared extraction for llms.txt links. |
docs/checks/content-structure.md |
Documents portability extraction rules. |
docs/checks/content-discoverability.md |
Documents llms.txt link handling. |
working-notes/page-discovery-notes.md |
Records migration decisions and behavior. |
test/unit/helpers/classify-markdown-links.test.ts |
Covers extraction contracts and edge cases. |
test/unit/helpers/detect-pagination.test.ts |
Covers reference decoding and offsets. |
test/unit/helpers/get-markdown-content.test.ts |
Covers fetching and limits. |
test/unit/helpers/get-page-urls.test.ts |
Covers discovery and sampling behavior. |
test/unit/checks/markdown-link-portability.test.ts |
Covers navigation-only portability checks. |
test/unit/checks/llms-txt-valid.test.ts |
Covers validation with parsed links. |
test/unit/checks/llms-txt-links-resolve.test.ts |
Covers reference-link resolution. |
test/unit/checks/llms-txt-links-markdown.test.ts |
Covers Markdown checks for references. |
test/unit/checks/llms-txt-coverage.test.ts |
Covers parsed-link coverage behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.

Summary
Closes #151.
Regression Coverage
Validation
npm test: 1,906 tests pass across 68 files.npm run lint: passed.npm run build: passed.npm run version:check: passed..vscode/settings.json; that file is not included in this PR.Validation was run locally on Node 25.2.1; CI covers Node 22 and 24.