markdown-parity-check 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/cli.d.ts +1 -1
- package/dist/src/model.d.ts +1 -1
- package/dist/src/normalize.d.ts +3 -2
- package/dist/src/normalize.js +21 -5
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/dist/src/cli.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { type FetchOptions, type FetchResult } from './fetch.js';
|
|
3
|
-
export declare const HELP = "markdown-parity-check 0.2.
|
|
3
|
+
export declare const HELP = "markdown-parity-check 0.2.7\nCompares the main content of a web page's HTML and Markdown representations and reports concrete\nmissing, added and changed blocks.\n\nUsage:\n markdown-parity-check --url <https://example.com/page> [--markdown-url <url>] [options]\n markdown-parity-check --html-file <page.html> --markdown-file <page.md> [--base-url <url>] [options]\n\nModes:\n --url <url> Fetch <url> twice: with Accept: text/html and with Accept: text/markdown.\n --markdown-url <url> Fetch the Markdown from this explicit address instead (requires --url).\n --html-file <path> Offline: local HTML file (requires --markdown-file).\n --markdown-file <path> Offline: local Markdown file (requires --html-file).\n --base-url <url> Offline: base for resolving relative links on both sides.\n\nOptions:\n --selector <css> CSS selector for the HTML main content (default: main, article, [role=main], then body).\n --front-matter keep|strip\n Markdown front matter. keep (default) removes nothing and warns when the document\n starts with a YAML-looking fenced block; strip removes that leading block.\n --format text|json Report format (default: text).\n --output <path> Write the report to a file instead of stdout. Refuses to overwrite an input file.\n --timeout-ms <n> Per-fetch timeout in milliseconds (default: 15000).\n --max-bytes <n> Cap on decoded response bytes per fetch (default: 5242880).\n --strict Treat warnings as rejecting findings too.\n --help, -h Show this help.\n --version, -V Show the version.\n\nExit codes:\n 0 comparison completed, no rejecting finding\n 1 comparison completed, rejecting content or delivery differences found\n 2 input, fetch, parse or report error prevented a reliable comparison\n\nOnly http(s) URLs to public addresses are fetched; loopback, private, link-local and other non-public\naddresses are refused, also behind DNS and redirects. No JavaScript is executed. Exit 0 does not prove\nsemantic equivalence.\n";
|
|
4
4
|
export declare class CliError extends Error {
|
|
5
5
|
}
|
|
6
6
|
export interface CliArgs {
|
package/dist/src/model.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export type BlockType = 'heading' | 'paragraph' | 'listItem' | 'table' | 'code';
|
|
|
2
2
|
export interface Link {
|
|
3
3
|
/** Visible anchor text, strictly normalized. */
|
|
4
4
|
text: string;
|
|
5
|
-
/** Href
|
|
5
|
+
/** Href as the parser returned it, with character references decoded, before resolution against a base URL. */
|
|
6
6
|
rawHref: string;
|
|
7
7
|
/** Href resolved against the document base, or null when it could not be resolved. */
|
|
8
8
|
resolved: string | null;
|
package/dist/src/normalize.d.ts
CHANGED
|
@@ -21,10 +21,11 @@ export type HrefRelation = 'same' | 'different' | 'uncertain';
|
|
|
21
21
|
/**
|
|
22
22
|
* How two references relate when neither could be resolved, which is the case for two relative
|
|
23
23
|
* links and no base URL. A textual difference alone does not make two targets different: ./guide
|
|
24
|
-
* and guide are the same address under every base.
|
|
24
|
+
* and guide are the same address under every base. Both references are first reduced to the string the URL
|
|
25
|
+
* parser reads (urlParserInput), so the segment counts and the kinds below describe what is resolved.
|
|
25
26
|
*
|
|
26
27
|
* 'same': the two resolve equal under synthetic bases that cover every way a base takes part in
|
|
27
|
-
* resolution, so they are equal under any base. The bases are two origins with different schemes, and
|
|
28
|
+
* resolution, so they are equal under any http or https base, which is the kind of base a web page has. The bases are two origins with different schemes, and
|
|
28
29
|
* for each, two sets of names that share none (directory segment, file and query), each used as a
|
|
29
30
|
* directory, a file and a file with a query, all deeper than any ".." segment in either reference. Two
|
|
30
31
|
* name sets are needed because a reference that climbs above its start and descends again, such as
|
package/dist/src/normalize.js
CHANGED
|
@@ -15,7 +15,7 @@ export function strictNormalize(text) {
|
|
|
15
15
|
export function looseNormalize(text) {
|
|
16
16
|
return strictNormalize(text)
|
|
17
17
|
.toLowerCase()
|
|
18
|
-
// Map typographic quotes and dashes to plain forms for alignment
|
|
18
|
+
// Map typographic quotes and dashes to plain forms, for alignment and for classifying minor text differences.
|
|
19
19
|
.replace(/[\u2018\u2019\u201a\u2032]/g, "'")
|
|
20
20
|
.replace(/[\u201c\u201d\u201e\u2033]/g, '"')
|
|
21
21
|
.replace(/[\u2010-\u2015\u2212]/g, '-')
|
|
@@ -223,13 +223,29 @@ export function hrefDifference(a, b) {
|
|
|
223
223
|
parts.push('fragment');
|
|
224
224
|
return parts.length ? parts.join(', ') : 'nothing visible';
|
|
225
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* The string the URL parser actually reads (WHATWG URL, basic URL parser): leading and trailing C0 controls
|
|
228
|
+
* and spaces are removed, and so is every ASCII tab and newline wherever it is. ".\t./guide" is "../guide" to
|
|
229
|
+
* the parser, so counting ".." segments in the raw text found none where the parser climbs one (found by an
|
|
230
|
+
* outside review, 2026-09-12).
|
|
231
|
+
*/
|
|
232
|
+
function urlParserInput(href) {
|
|
233
|
+
let start = 0;
|
|
234
|
+
let end = href.length;
|
|
235
|
+
while (start < end && href.charCodeAt(start) <= 0x20)
|
|
236
|
+
start++;
|
|
237
|
+
while (end > start && href.charCodeAt(end - 1) <= 0x20)
|
|
238
|
+
end--;
|
|
239
|
+
return href.slice(start, end).replace(/[\t\n\r]/g, '');
|
|
240
|
+
}
|
|
226
241
|
/**
|
|
227
242
|
* How two references relate when neither could be resolved, which is the case for two relative
|
|
228
243
|
* links and no base URL. A textual difference alone does not make two targets different: ./guide
|
|
229
|
-
* and guide are the same address under every base.
|
|
244
|
+
* and guide are the same address under every base. Both references are first reduced to the string the URL
|
|
245
|
+
* parser reads (urlParserInput), so the segment counts and the kinds below describe what is resolved.
|
|
230
246
|
*
|
|
231
247
|
* 'same': the two resolve equal under synthetic bases that cover every way a base takes part in
|
|
232
|
-
* resolution, so they are equal under any base. The bases are two origins with different schemes, and
|
|
248
|
+
* resolution, so they are equal under any http or https base, which is the kind of base a web page has. The bases are two origins with different schemes, and
|
|
233
249
|
* for each, two sets of names that share none (directory segment, file and query), each used as a
|
|
234
250
|
* directory, a file and a file with a query, all deeper than any ".." segment in either reference. Two
|
|
235
251
|
* name sets are needed because a reference that climbs above its start and descends again, such as
|
|
@@ -241,8 +257,8 @@ export function hrefDifference(a, b) {
|
|
|
241
257
|
* (../guide and guide are equal at the root, ?q and ./?q under a directory base).
|
|
242
258
|
*/
|
|
243
259
|
export function relativeHrefRelation(a, b) {
|
|
244
|
-
const x = a
|
|
245
|
-
const y = b
|
|
260
|
+
const x = urlParserInput(a);
|
|
261
|
+
const y = urlParserInput(b);
|
|
246
262
|
if (x === y)
|
|
247
263
|
return 'same';
|
|
248
264
|
const pathOf = (h) => h.replace(/\\/g, '/').split(/[?#]/, 1)[0] ?? '';
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const TOOL_NAME = "markdown-parity-check";
|
|
2
|
-
export declare const TOOL_VERSION = "0.2.
|
|
2
|
+
export declare const TOOL_VERSION = "0.2.7";
|
package/dist/src/version.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
// Cloudflare Worker as well as under Node.js. test/version.test.ts fails the build when these differ
|
|
3
3
|
// from package.json, which stays the version the release workflow publishes.
|
|
4
4
|
export const TOOL_NAME = 'markdown-parity-check';
|
|
5
|
-
export const TOOL_VERSION = '0.2.
|
|
5
|
+
export const TOOL_VERSION = '0.2.7';
|
package/package.json
CHANGED