From f5d1e41ecf636c8e42cd572c37df8c2ad32724be Mon Sep 17 00:00:00 2001 From: dacharyc Date: Mon, 28 Sep 2026 08:43:37 -0400 Subject: [PATCH 1/2] fix: parse Markdown blocks for pagination detection 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 --- package-lock.json | 737 +++++++++++++++++- package.json | 4 + src/helpers/detect-pagination.ts | 104 ++- .../checks/single-fetch-completeness.test.ts | 88 ++- test/unit/helpers/detect-pagination.test.ts | 133 ++++ 5 files changed, 1046 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1069139..b4084e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,9 @@ "dependencies": { "chalk": "^5.4.1", "commander": "^13.1.0", + "mdast-util-from-markdown": "^2.0.3", + "mdast-util-gfm-table": "^2.0.0", + "micromark-extension-gfm-table": "^2.1.2", "node-html-parser": "^7.1.0", "picomatch": "^4.0.4", "turndown": "^7.2.2", @@ -22,6 +25,7 @@ }, "devDependencies": { "@eslint/js": "^10.0.1", + "@types/mdast": "^4.0.4", "@types/node": "^22.13.4", "@types/picomatch": "^4.0.3", "@types/turndown": "^5.0.6", @@ -1254,6 +1258,15 @@ "assertion-error": "^2.0.1" } }, + "node_modules/@types/debug": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz", + "integrity": "sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw==", + "license": "MIT", + "dependencies": { + "@types/ms": "*" + } + }, "node_modules/@types/deep-eql": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", @@ -1282,6 +1295,21 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/mdast": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", + "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/@types/ms": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz", + "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==", + "license": "MIT" + }, "node_modules/@types/node": { "version": "22.19.11", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.11.tgz", @@ -1314,6 +1342,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "license": "MIT" + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "8.56.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.56.0.tgz", @@ -1872,6 +1906,16 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/character-entities": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz", + "integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/cli-cursor": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", @@ -2091,7 +2135,6 @@ "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "dev": true, "license": "MIT", "dependencies": { "ms": "^2.1.3" @@ -2105,6 +2148,19 @@ } } }, + "node_modules/decode-named-character-reference": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.3.0.tgz", + "integrity": "sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q==", + "license": "MIT", + "dependencies": { + "character-entities": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -2112,6 +2168,28 @@ "dev": true, "license": "MIT" }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/devlop": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz", + "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==", + "license": "MIT", + "dependencies": { + "dequal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/dom-serializer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", @@ -3091,6 +3169,16 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/longest-streak": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.1.0.tgz", + "integrity": "sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/magic-string": { "version": "0.30.21", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", @@ -3129,6 +3217,587 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/markdown-table": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.4.tgz", + "integrity": "sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/mdast-util-from-markdown": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.3.tgz", + "integrity": "sha512-W4mAWTvSlKvf8L6J+VN9yLSqQ9AOAAvHuoDAmPkz4dHf553m5gVj2ejadHJhoJmcmxEnOv6Pa8XJhpxE93kb8Q==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark": "^4.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0", + "unist-util-stringify-position": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-table": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-2.0.0.tgz", + "integrity": "sha512-78UEvebzz/rJIxLvE7ZtDd/vIQ0RHv+3Mh5DR96p7cS7HsBhYIICDBCu8csTNWNO6tBWfqXPWekRuj2FNOGOZg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "markdown-table": "^3.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-phrasing": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", + "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-markdown": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.3.tgz", + "integrity": "sha512-wgyJtgUkUcdU7zci7uuwc/tzoAhm0TswWhaXuvnWolqug+8jY7bgNkBBL0dYBnHgc/tHL7lCzRdPsdUxUKKBqw==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "longest-streak": "^3.0.0", + "mdast-util-phrasing": "^4.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "micromark-util-html-tag-name": "^2.0.0", + "unist-util-visit": "^5.0.0", + "zwitch": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", + "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.3.tgz", + "integrity": "sha512-oGYfQzHSG5dOMovQcJ3fyTmZlWAWpi0XA0sJwJs+i6OT88o1+Jtw/8z0CmdowSLxGhhFK89rQ/oXph/wN02PNw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "@types/debug": "^4.0.0", + "debug": "^4.0.0", + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "micromark-core-commonmark": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-combine-extensions": "^2.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-edit-map": "^1.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-subtokenize": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-core-commonmark": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.4.tgz", + "integrity": "sha512-wxEeE8v8XVvOrxn1TZj74qYhAtTQsSqufHVS3uNVyT1MupXxhyaHk8/9xDNPh9BmL77QNDgWTkZ3RsYHB2ry7w==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "micromark-factory-destination": "^2.0.0", + "micromark-factory-label": "^2.0.0", + "micromark-factory-space": "^2.1.0", + "micromark-factory-title": "^2.0.0", + "micromark-factory-whitespace": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-edit-map": "^1.0.0", + "micromark-util-html-tag-name": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-subtokenize": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.3" + } + }, + "node_modules/micromark-extension-gfm-table": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-2.1.2.tgz", + "integrity": "sha512-pRzm4kDTu0MjlmBkxmS9yYhw60nncfcEwu9NNdPFSQEFXS95ZKyIIyTSHu/o3ReBUrLKYEq+7YaXCRn/bPB4MA==", + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-factory-destination": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", + "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-label": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", + "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-space": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.1.0.tgz", + "integrity": "sha512-fS8hnLIjnjvdQIj39Geug8wWsR0HrYZ43KShKxNfwT7t2LOHo/LbWZEzEaSOjwtjdCsjoE6syHhonEzW0zv0+Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-title": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", + "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-whitespace": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", + "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-chunked": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", + "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-classify-character": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", + "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-combine-extensions": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", + "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-chunked": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-numeric-character-reference": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", + "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-string": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz", + "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-edit-map": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-edit-map/-/micromark-util-edit-map-1.0.0.tgz", + "integrity": "sha512-Pa2ljlsEL6sVwFaYeyrOLSYbQt73JvGbPOYFq+9AElXiSnfI5Q4465RRZ1sHv7lDjDOnGRDDaqPXqClqWK/q1Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-encode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", + "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-html-tag-name": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", + "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-normalize-identifier": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", + "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-resolve-all": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", + "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-sanitize-uri": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", + "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-subtokenize": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", + "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-types": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.3.tgz", + "integrity": "sha512-oxB2Ik03hI0gv+VNn9tnh1t1YEe9MDPptViAEgfdf3YQHsn0pzGTgCdlSCJXcwhqm8phaEuM7zeEu3QQzVBrPg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, "node_modules/micromatch": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", @@ -3189,7 +3858,6 @@ "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, "license": "MIT" }, "node_modules/msw": { @@ -4011,6 +4679,61 @@ "dev": true, "license": "MIT" }, + "node_modules/unist-util-is": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.1.tgz", + "integrity": "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-stringify-position": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", + "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-visit": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.1.0.tgz", + "integrity": "sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0", + "unist-util-visit-parents": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-visit-parents": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.2.tgz", + "integrity": "sha512-goh1s1TBrqSqukSc8wrjwWhL0hiJxgA8m4kFxGlQ+8FYQ3C/m11FcTs4YYem7V664AhHVvgoQLk890Ssdsr2IQ==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/until-async": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/until-async/-/until-async-3.0.2.tgz", @@ -4323,6 +5046,16 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/zwitch": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz", + "integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } } } } diff --git a/package.json b/package.json index 1587d8d..5bc3e06 100644 --- a/package.json +++ b/package.json @@ -83,6 +83,9 @@ "dependencies": { "chalk": "^5.4.1", "commander": "^13.1.0", + "mdast-util-from-markdown": "^2.0.3", + "mdast-util-gfm-table": "^2.0.0", + "micromark-extension-gfm-table": "^2.1.2", "node-html-parser": "^7.1.0", "picomatch": "^4.0.4", "turndown": "^7.2.2", @@ -91,6 +94,7 @@ }, "devDependencies": { "@eslint/js": "^10.0.1", + "@types/mdast": "^4.0.4", "@types/node": "^22.13.4", "@types/picomatch": "^4.0.3", "@types/turndown": "^5.0.6", diff --git a/src/helpers/detect-pagination.ts b/src/helpers/detect-pagination.ts index cf9e049..715aa69 100644 --- a/src/helpers/detect-pagination.ts +++ b/src/helpers/detect-pagination.ts @@ -11,6 +11,10 @@ * only the latter is a defect. */ +import { fromMarkdown } from 'mdast-util-from-markdown'; +import { gfmTableFromMarkdown } from 'mdast-util-gfm-table'; +import { gfmTable } from 'micromark-extension-gfm-table'; +import type { Nodes, PhrasingContent } from 'mdast'; import { scanRawLinks } from './classify-markdown-links.js'; export type PaginationSignalType = 'n-of-m' | 'pagination-param' | 'next-link' | 'link-header'; @@ -101,7 +105,7 @@ const BARE_PAGED_PATH = const MAX_SIGNAL_TEXT = 80; /** - * What may precede an "N of M" phrase on its line for it to read as a + * What may precede an "N of M" phrase in its block for it to read as a * pagination note rather than prose: markdown structure (blockquote, list * marker, table cell, emphasis) and at most one short label such as * "Note:". A phrase inside a sentence ("If 3 out of 50 pages fail, the @@ -110,6 +114,67 @@ const MAX_SIGNAL_TEXT = 80; */ const NOTE_LEAD = /^[\s>*_\-+|#\d.)]*(?:\*\*|__)?(?:[A-Za-z][\w ]{0,24}:\s*)?(?:\*\*|__)?\s*$/; +interface PaginationTextBlock { + offset: number; + text: string; +} + +function paginationContent(content: string): { + textBlocks: PaginationTextBlock[]; + visibleContent: string; +} { + const tree = fromMarkdown(content, { + extensions: [gfmTable()], + mdastExtensions: [gfmTableFromMarkdown()], + }); + const visible = content.split(''); + const textBlocks: PaginationTextBlock[] = []; + + const visit = (node: Nodes): void => { + const start = node.position?.start.offset; + const end = node.position?.end.offset; + if (start === undefined || end === undefined) return; + + if (node.type === 'code' || (node.type === 'html' && node.value.startsWith('', + ])('passes prose and examples without fetching a continuation: %s', async (paragraph) => { + const ctx = cachedCtx([{ url: `${ORIGIN}/docs/checks`, content: `# Checks\n\n${paragraph}` }]); + const fetchSpy = vi.spyOn(ctx.http, 'fetch'); + const result = await check.run(ctx); + expect(result.status).toBe('pass'); + expect(result.details).toMatchObject({ paginatedPages: 0, passBucket: 1 }); + expect(pageResults(result)).toMatchObject([ + { status: 'pass', paginated: false, signals: [], issues: [] }, + ]); + expect(pageResults(result)[0].continuation).toBeUndefined(); + expect(fetchSpy).not.toHaveBeenCalled(); + }); + + it.each(['\n', '\r\n'])( + 'fetches only the real continuation after examples with line ending %j', + async (lineEnding) => { + const next = `${ORIGIN}/docs/models.md?page=2`; + server.use(http.get(`${ORIGIN}/docs/models.md`, markdown(catalog(2)))); + const content = [ + '# Models', + '', + ' [Next page](/docs/example?page=2)', + '', + '', + '', + '>> Note:', + '>> Showing 100 of', + `>> 102 models. [Next page](${next})`, + '', + catalog(), + ] + .join('\n') + .replace(/\n/g, lineEnding); + const ctx = cachedCtx([{ url: `${ORIGIN}/docs/models`, content }]); + const fetchSpy = vi.spyOn(ctx.http, 'fetch'); + + const result = await check.run(ctx); + expect(result.status).toBe('pass'); + const [page] = pageResults(result); + expect(page.signals.map((signal) => signal.type)).toEqual(['n-of-m', 'next-link']); + expect(page.signals[0].offset).toBe(content.indexOf('Showing')); + expect(page.continuation).toMatchObject({ + url: next, + offset: content.indexOf(`[Next page](${next})`), + atTop: true, + outcome: 'ok', + }); + expect(fetchSpy).toHaveBeenCalledExactlyOnceWith(next); + }, + ); + + it.each(['\n', '\r\n'])( + 'fails a genuine note without a continuation with line ending %j', + async (lineEnding) => { + const content = 'Models\n===\nShowing 100 of 102 models.'.replace(/\n/g, lineEnding); + const ctx = cachedCtx([{ url: `${ORIGIN}/docs/models`, content }]); + const fetchSpy = vi.spyOn(ctx.http, 'fetch'); + const result = await check.run(ctx); + expect(result.status).toBe('fail'); + expect(result.details?.reasons).toMatchObject({ missing: 1 }); + expect(pageResults(result)[0].signals[0].offset).toBe(content.indexOf('Showing')); + expect(fetchSpy).not.toHaveBeenCalled(); + }, + ); + it('passes pagination declared at the top with an absolute URL that resolves', async () => { const next = `${ORIGIN}/docs/models.md?page=2`; server.use(http.get(`${ORIGIN}/docs/models.md`, markdown(catalog(2)))); diff --git a/test/unit/helpers/detect-pagination.test.ts b/test/unit/helpers/detect-pagination.test.ts index 537e9eb..3d8cb9d 100644 --- a/test/unit/helpers/detect-pagination.test.ts +++ b/test/unit/helpers/detect-pagination.test.ts @@ -72,6 +72,40 @@ describe('detectPagination', () => { expect(detectPagination(content, { baseUrl: BASE }).signals).toEqual([]); }); + it.each([64, 72, 80, 100, 200])( + 'ignores illustrative prose hard-wrapped at %i columns', + (width) => { + const paragraph = + 'For checks that test multiple pages, results are proportional. If 3 out of 50 pages fail, ' + + 'the check scores ~94% of its weight. The cache served 12 of 20 results, and page 2 of 5 ' + + 'in the wizard shows the token.'; + const lines = ['']; + for (const word of paragraph.split(' ')) { + const last = lines.length - 1; + if (!lines[last]) lines[last] = word; + else if (lines[last].length + word.length + 1 <= width) lines[last] += ` ${word}`; + else lines.push(word); + } + const content = `# Checks\n\n${lines.join('\n')}`; + expect(detectPagination(content, { baseUrl: BASE }).signals).toEqual([]); + }, + ); + + it.each([ + "Observed on a catalog's markdown\nvariant: 100 of 102 entries shown, a note at the bottom.", + "Observed on a catalog's markdown variant:\n100 of 102 entries shown, a note at the bottom.", + 'If\n3 out of 50 pages fail, the check scores 94%.', + 'The cache served\n12 of 20 results, and the wizard shows the token.', + 'Note: this listing is windowed,\nshowing 100 of 102 entries.', + '- The cache served\n 12 of 20 results, and the wizard shows the token.', + '> The cache served\n12 of 20 results, and the wizard shows the token.', + 'The cache served\n[previous results](/docs/cache)\n12 of 20 results.', + 'The cache served\n`cached entries`\n12 of 20 results.', + 'The cache served\r\n12 of 20 results, and the wizard shows the token.', + ])('ignores a phrase on a continuation line of prose: %s', (content) => { + expect(detectPagination(content, { baseUrl: BASE }).signals).toEqual([]); + }); + it('accepts an "N of M" note behind blockquote, list, emphasis, table, or label prefixes', () => { for (const line of [ '> Showing 100 of 102 models.', @@ -89,6 +123,51 @@ describe('detectPagination', () => { } }); + it.each([ + '> The cache served\n> 12 of 20 results.', + '>> The cache served\n>> 12 of 20 results.', + '> - The cache served\n> 12 of 20 results.', + '- > The cache served\n > 12 of 20 results.', + '[The cache served](/cache)\n12 of 20 results.', + '`If`\n3 out of 50 pages fail, the check scores 94%.', + 'Showing 100 of\n\n102 models', + 'Showing 100 of\n```text\nUnrelated sample\n```\n102 models', + 'Showing 100 of\n- 102 models', + '| Showing 100 of | 102 models |', + 'Showing 100 of `unrelated sample` 102 models', + 'Showing 100 of 102 models', + '# Example\n\n Showing 100 of 102 models.', + '# Example\n\n\tShowing 100 of 102 models.', + '', + ])('ignores non-declarations with either line ending: %s', (content) => { + for (const lineEnding of ['\n', '\r\n']) { + expect( + detectPagination(content.replace(/\n/g, lineEnding), { baseUrl: BASE }).signals, + ).toEqual([]); + } + }); + + it.each([' ', '\t', '> '])( + 'ignores all pagination signals inside indented code: %j', + (indent) => { + const example = + 'Showing 100 of 102 models. [Next page](/models?page=2) Fetch /models?offset=100 or https://docs.example.com/models?cursor=next'; + const result = detectPagination(`# Example\n\n${indent}${example}`, { baseUrl: BASE }); + expect(result.signals).toEqual([]); + expect(result.continuation).toBeUndefined(); + }, + ); + + it.each([ + '', + '', + '\n\nShowing 25 of 80 items', + ])('preserves real notes and source offsets with either line ending: %s', (input) => { + for (const lineEnding of ['\n', '\r\n']) { + const content = input.replace(/\n/g, lineEnding); + const result = detectPagination(content, { baseUrl: BASE }); + expect(result.signals).toEqual([ + { type: 'n-of-m', text: 'Showing 25 of 80', offset: content.indexOf('Showing') }, + ]); + } + }); + + it.each([ + 'Showing 25 of 80 items\nfrom the catalog.', + '\nShowing 25 of 80 items\nfrom the catalog.', + '# Models\nShowing 25 of 80 items', + 'Models\n===\nShowing 25 of 80 items', + 'Models\n---\nShowing 25 of 80 items', + 'Other text.\n\nShowing 25 of 80 items', + 'Other text.\n \t\nShowing 25 of 80 items', + 'Other text.\n## Showing 25 of 80 items', + 'Other text.\n> Showing 25 of 80 items\n> from the catalog.', + '- Other item.\n- Showing 25 of 80 items\n from the catalog.', + '1. Other item.\n2. Showing 25 of 80 items\n from the catalog.', + '| Status |\n| --- |\n| Showing 25 of 80 items |', + 'Note:\nShowing 25 of 80 items', + '- Note:\n Showing 25 of 80 items', + '> Note:\n> Showing 25 of 80 items', + '**Showing 25 of 80 items\nfrom the catalog.**', + '_Showing 25 of 80 items\nfrom the catalog._', + '```text\nAn example.\n```\nShowing 25 of 80 items', + '~~~text\nAn example.\n~~~\nShowing 25 of 80 items', + ])('preserves a declaration and its offset across block boundaries: %s', (content) => { + const result = detectPagination(content, { baseUrl: BASE }); + expect(result.signals).toEqual([ + { type: 'n-of-m', text: 'Showing 25 of 80', offset: content.indexOf('Showing') }, + ]); + expect(result.continuation).toBeUndefined(); + }); + it('detects "N of M" phrasing without a link and reports no continuation', () => { const content = `# Models\n\n- a\n- b\n\nShowing 100 of 102 models.`; const result = detectPagination(content, { baseUrl: BASE }); From 9a4c34c34610f08f2daad044a2de36adebd1a2ee Mon Sep 17 00:00:00 2001 From: dacharyc Date: Mon, 28 Sep 2026 09:02:10 -0400 Subject: [PATCH 2/2] fix: ignore indented HTML comments in pagination detection 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. --- src/helpers/detect-pagination.ts | 5 +++- .../checks/single-fetch-completeness.test.ts | 30 ++++++++++++++++++- test/unit/helpers/detect-pagination.test.ts | 14 +++++++-- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/helpers/detect-pagination.ts b/src/helpers/detect-pagination.ts index 715aa69..f1e5856 100644 --- a/src/helpers/detect-pagination.ts +++ b/src/helpers/detect-pagination.ts @@ -135,7 +135,10 @@ function paginationContent(content: string): { const end = node.position?.end.offset; if (start === undefined || end === undefined) return; - if (node.type === 'code' || (node.type === 'html' && node.value.startsWith('', + '', + ]) { + const content = comment + .split('\n') + .map((line) => `${' '.repeat(spaces)}${line}`) + .join(lineEnding); + const ctx = cachedCtx([{ url: `${ORIGIN}/docs/checks`, content }]); + const fetchSpy = vi + .spyOn(ctx.http, 'fetch') + .mockRejectedValue(new Error('Unexpected continuation fetch')); + + const result = await check.run(ctx); + expect(fetchSpy).not.toHaveBeenCalled(); + expect(result.status).toBe('pass'); + expect(result.details).toMatchObject({ paginatedPages: 0, passBucket: 1 }); + expect(pageResults(result)[0].signals).toEqual([]); + expect(pageResults(result)[0].continuation).toBeUndefined(); + } + } + }, + ); + it.each(['\n', '\r\n'])( 'fetches only the real continuation after examples with line ending %j', async (lineEnding) => { @@ -129,7 +157,7 @@ describe('single-fetch-completeness', () => { '', ' [Next page](/docs/example?page=2)', '', - '', '