Fix false pagination failures in hard-wrapped Markdown - #150
Merged
Merged
Conversation
Prevent hard-wrapped prose from producing false pagination failures. Use CommonMark parsing with GFM tables to preserve block boundaries and source offsets, retain inline prose context, and exclude code and comments from continuation detection. Add regression coverage for wrapping, nested containers, LF/CRLF, inline formatting, cross-block counts, and check-level request counts. Fixes #149
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Indented HTML comments can still produce false pagination signals.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Fixes false pagination detection in hard-wrapped Markdown by using block-aware AST parsing.
Changes:
- Parses paragraphs, headings, and GFM table cells while preserving offsets.
- Excludes code and comments from pagination scanning.
- Adds comprehensive regression and check-level tests.
| File | Description |
|---|---|
src/helpers/detect-pagination.ts |
Adds AST-based pagination parsing. |
test/unit/helpers/detect-pagination.test.ts |
Covers wrapping, blocks, offsets, and exclusions. |
test/unit/checks/single-fetch-completeness.test.ts |
Verifies outcomes and continuation requests. |
package.json |
Adds Markdown parser dependencies. |
package-lock.json |
Locks added dependencies. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Recognize comment nodes with leading indentation without altering source offsets. Cover zero to four spaces, LF/CRLF, multiline and unclosed comments, zero continuation requests, and real continuation offsets after indented comments. Addresses the review finding on PR #150.
This was referenced Sep 28, 2026
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 #149.
single-fetch-completenesspreviously decided whether an "N of M" phrase was a pagination declaration using only the text preceding it on its physical line. Hard-wrapping ordinary prose could therefore turn a complete page into a failure with "no continuation link found".Scope
Adds
mdast-util-from-markdown,mdast-util-gfm-table,micromark-extension-gfm-table, and Markdown AST types. The shared link scanner, continuation URL policy, scoring rules, and other checks are not refactored in this PR. Detection remains deliberately conservative about prose that merely describes pagination.Validation
npm test -- --reporter=dot: 1,877 tests passed across 68 files.npm run lintnpm run buildnpm run version:checknpm run format:checkRegression assertions verify zero continuation requests for illustrative prose and code/comment examples, exactly one request for a genuine continuation, and continued failures for genuine incomplete content without a continuation link.