Skip to content

Fix false pagination failures in hard-wrapped Markdown - #150

Merged
dacharyc merged 2 commits into
mainfrom
fix/149-pagination-markdown-blocks
Sep 28, 2026
Merged

dacharyc merged 2 commits into
mainfrom
fix/149-pagination-markdown-blocks

Conversation

@dacharyc

Copy link
Copy Markdown
Member

Summary

Closes #149.

single-fetch-completeness previously 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".

  • Parse CommonMark with GFM table support and evaluate declarations within paragraphs, headings, and individual table cells.
  • Preserve source offsets while handling nested blockquotes/lists, multiline notes, emphasis, link labels, and LF/CRLF consistently.
  • Keep inline prose context and prevent count matches from spanning unrelated blocks, code, or comments.
  • Exclude fenced/indented code and HTML comments before the existing continuation-link scanner runs.
  • Add paired false-positive/genuine-note regressions and check-level assertions for pass/fail outcomes and exact HTTP request counts.

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 lint
  • npm run build
  • npm run version:check
  • npm run format:check

Regression 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.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Indented HTML comments can still produce false pagination signals.

Review effort: Balanced
Findings: 1 Medium severity

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.

Comment thread src/helpers/detect-pagination.ts Outdated
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.
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.

single-fetch-completeness: hard-wrapped prose produces false "N of M" pagination signals

2 participants