markdown-parity-check 0.2.30 → 0.2.32

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/README.md CHANGED
@@ -4,7 +4,7 @@ A command-line tool and TypeScript library that compares the main content of a p
4
4
 
5
5
  ## Install
6
6
 
7
- The package needs **Node.js 22 or newer**. It is MIT licensed. GitHub Actions tests Node.js 22 and 24 on Windows and Ubuntu.
7
+ The package needs **Node.js 22 or newer**. It is MIT licensed. GitHub Actions tests Node.js 22, 24 and 26 on Windows and Ubuntu.
8
8
 
9
9
  Run it without installing anything:
10
10
 
@@ -78,10 +78,10 @@ A value that is outside these ranges, or that is not a plain run of digits, stop
78
78
 
79
79
  ### Example output
80
80
 
81
- This is the text report for the matching fixture pair in this repository, run with version 0.2.30 on 2026-11-02. The exact command is in the Development section below. The text report ends with a list of limitations, which is omitted here:
81
+ This is the text report for the matching fixture pair in this repository, run with version 0.2.32 on 2026-11-04. The exact command is in the Development section below. The text report ends with a list of limitations, which is omitted here:
82
82
 
83
83
  ```text
84
- markdown-parity-check 0.2.30 (offline mode)
84
+ markdown-parity-check 0.2.32 (offline mode)
85
85
  Result: PASS (0 error(s), 0 warning(s), 1 info)
86
86
 
87
87
  HTML: test/fixtures/same/page.html (file, 1,017 bytes, base https://example.com/page)
@@ -245,10 +245,10 @@ Only after that check does it create the GitHub release with the verified tarbal
245
245
  GitHub Actions publishes every version from 0.1.2 on with npm trusted publishing, and each one carries a provenance attestation. To check one, install it in an empty directory and ask npm to verify the signatures. Replace the version with the one you want to check.
246
246
 
247
247
  ```sh
248
- mkdir verify-mpc && cd verify-mpc && npm init -y && npm install markdown-parity-check@0.2.30 --ignore-scripts && npm audit signatures
248
+ mkdir verify-mpc && cd verify-mpc && npm init -y && npm install markdown-parity-check@0.2.32 --ignore-scripts && npm audit signatures
249
249
  ```
250
250
 
251
- `npm audit signatures` checks the registry signature and the provenance attestation of each installed package that has one. The attestation of this package names three things to compare with what you expect: the repository `github.com/erekola/markdown-parity-check`, the workflow file `.github/workflows/release.yml` and the commit that produced the tarball. The npm version page shows them under Provenance. Tag `v0.2.30` must point at that same commit, and `gh api repos/erekola/markdown-parity-check/commits/v0.2.30 --jq .sha` prints it. A mismatch is a reason not to use that version. Provenance proves which workflow built a release and from which commit. It does not prove that the code is safe, so reading the source and the dependencies stays your job.
251
+ `npm audit signatures` checks the registry signature and the provenance attestation of each installed package that has one. The attestation of this package names three things to compare with what you expect: the repository `github.com/erekola/markdown-parity-check`, the workflow file `.github/workflows/release.yml` and the commit that produced the tarball. The npm version page shows them under Provenance. Tag `v0.2.32` must point at that same commit, and `gh api repos/erekola/markdown-parity-check/commits/v0.2.32 --jq .sha` prints it. A mismatch is a reason not to use that version. Provenance proves which workflow built a release and from which commit. It does not prove that the code is safe, so reading the source and the dependencies stays your job.
252
252
 
253
253
  ## Security
254
254
 
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.30\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 --html-profile generic|starlight\n HTML extraction rules (default: generic). Starlight includes inactive tab panels.\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> Timeout in milliseconds for each fetch and for the parse-and-compare step\n (default: 15000). When it runs out the exit code is 2.\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";
3
+ export declare const HELP = "markdown-parity-check 0.2.32\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 --html-profile generic|starlight\n HTML extraction rules (default: generic). Starlight includes inactive tab panels.\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> Timeout in milliseconds for each fetch and for the parse-and-compare step\n (default: 15000). When it runs out the exit code is 2.\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 {
@@ -384,7 +384,7 @@ export function compare(html, markdown, options = {}) {
384
384
  const findings = [];
385
385
  const bothBases = options.bothBases ?? false;
386
386
  if (html.confidence === 'low') {
387
- findings.push({ code: 'EXTRACTION_LOW_CONFIDENCE', severity: 'warning', direction: 'html_only', message: 'HTML main content was taken from <body> because no <main>, <article> or [role=main] element exists; page chrome may leak into the comparison. Use --selector to narrow it.' });
387
+ findings.push({ code: 'EXTRACTION_LOW_CONFIDENCE', severity: 'warning', direction: 'html_only', message: 'HTML main content was taken from <body> because no eligible visible main-content element was found; page chrome may leak into the comparison. Use --selector to narrow it.' });
388
388
  }
389
389
  for (const i of html.issues)
390
390
  findings.push({ code: i.code, severity: i.severity, direction: 'html_only', message: i.message, html: { line: i.line, excerpt: i.excerpt } });
package/dist/src/html.js CHANGED
@@ -763,7 +763,7 @@ function pickRoot(doc, selector, notes, issues) {
763
763
  }
764
764
  const body = selectOne('body', doc.children);
765
765
  if (body instanceof Element) {
766
- notes.push('No <main>, <article> or [role=main] element; fell back to <body> with lower extraction confidence.');
766
+ notes.push('No eligible visible main-content element was found; fell back to <body> with lower extraction confidence.');
767
767
  return { root: body, strategy: 'body-fallback', confidence: 'low' };
768
768
  }
769
769
  throw new HtmlExtractError('Document has no <body> element.');
@@ -19,6 +19,14 @@ export declare function excerpt(text: string, max?: number): string;
19
19
  /** Masks every "scheme://(name):secret@" userinfo, leaving the scheme and an unmasked "***@" behind so the rest
20
20
  * of the URL (host, path, query, fragment) reaches the ordinary run-based masking below as one unbroken run. */
21
21
  export declare function maskParenUserinfo(text: string): string;
22
+ /** Whether position `at` falls inside the parenthesized name or the secret of a nextParenUserinfo match, the same
23
+ * span maskParenUserinfo hides. Only a match that starts inside the same HIDDEN_SCAN window insideHiddenUrlPart
24
+ * itself uses can count. The regular expression search runs on a prefix of the text that ends
25
+ * PAREN_USERINFO_MATCH_SPAN characters after that window. The prefix keeps every index and is not cut on the
26
+ * left, so the word boundary at the start of a match sees the same character as on the whole text, and every match
27
+ * that starts inside the window sees the same name and secret windows. Up to 0.2.30 the search ran on the whole
28
+ * text and went on to its end when nothing matched, so a file with many bare autolinks took quadratic time. */
29
+ export declare function insideParenUserinfo(text: string, at: number): boolean;
22
30
  /**
23
31
  * Whether position at of a source text lies in a part of a URL that maskHref hides: user information, a query
24
32
  * value or the fragment. GFM links a bare address it finds inside another URL on its own: the part after the
@@ -43,8 +43,10 @@ export function normalizeCode(code) {
43
43
  return code.replace(/\r\n?/g, '\n').replace(/\n+$/, '');
44
44
  }
45
45
  // Terminal control characters (ANSI escape sequences, C0 and C1 controls) and the Unicode bidi controls reach a text report unescaped if a
46
- // compared page or an argument carries one, while --format json is already safe because JSON.stringify escapes
47
- // every control character. Tab, newline and carriage return are kept: they are ordinary formatting, and by the
46
+ // compared page or an argument carries one. --format json is safe only in part on its own: JSON.stringify escapes
47
+ // the C0 controls (U+0000 to U+001F) and lone surrogates, and leaves U+007F, the C1 controls and the bidi controls
48
+ // literal. It is safe in practice because renderJson sends every string value through redactText first, so this
49
+ // strip covers the JSON output as well. Tab, newline and carriage return are kept: they are ordinary formatting, and by the
48
50
  // time most report text reaches this point strictNormalize has already collapsed them to a single space anyway.
49
51
  // C1 controls (U+0080 to U+009F) include the single-byte CSI (U+009B), which some terminals read as an escape. The bidi
50
52
  // controls (U+202A to U+202E and U+2066 to U+2069) reorder the text a reader sees, so a quoted excerpt could read
@@ -301,6 +303,11 @@ const HIDDEN_SCAN = 4096;
301
303
  // HIDDEN_SCAN below already makes for the same class of problem.
302
304
  const PAREN_USERINFO_START = /\b([a-z][a-z0-9+.-]{0,31}):\/\/\(/giu;
303
305
  const PAREN_USERINFO_SCAN = HIDDEN_SCAN;
306
+ // How far past a position a match that STARTS before that position can read. The scheme is at most 32 characters
307
+ // and "://(" is 4, so nameStart is at most 35 past that position. The ")" must be followed by ":" inside
308
+ // the name window, so secretStart is at most nameStart + PAREN_USERINFO_SCAN, and the secret window ends at most
309
+ // PAREN_USERINFO_SCAN after that. 36 + 2 * PAREN_USERINFO_SCAN covers all three with one character to spare.
310
+ const PAREN_USERINFO_MATCH_SPAN = 36 + 2 * PAREN_USERINFO_SCAN;
304
311
  /** Finds the next "scheme://(name):secret@" match at or after `from`. See the fail-closed rationale above. */
305
312
  function nextParenUserinfo(text, from) {
306
313
  const re = new RegExp(PAREN_USERINFO_START.source, PAREN_USERINFO_START.flags);
@@ -341,14 +348,19 @@ export function maskParenUserinfo(text) {
341
348
  return out + text.slice(pos);
342
349
  }
343
350
  /** Whether position `at` falls inside the parenthesized name or the secret of a nextParenUserinfo match, the same
344
- * span maskParenUserinfo hides. The search starts and stops within the same HIDDEN_SCAN window
345
- * insideHiddenUrlPart itself uses, so a link deep inside a large document does not rescan the whole source. */
346
- function insideParenUserinfo(text, at) {
351
+ * span maskParenUserinfo hides. Only a match that starts inside the same HIDDEN_SCAN window insideHiddenUrlPart
352
+ * itself uses can count. The regular expression search runs on a prefix of the text that ends
353
+ * PAREN_USERINFO_MATCH_SPAN characters after that window. The prefix keeps every index and is not cut on the
354
+ * left, so the word boundary at the start of a match sees the same character as on the whole text, and every match
355
+ * that starts inside the window sees the same name and secret windows. Up to 0.2.30 the search ran on the whole
356
+ * text and went on to its end when nothing matched, so a file with many bare autolinks took quadratic time. */
357
+ export function insideParenUserinfo(text, at) {
347
358
  const from = Math.max(0, at - HIDDEN_SCAN);
348
359
  const to = Math.min(text.length, at + HIDDEN_SCAN);
360
+ const haystack = text.slice(0, Math.min(text.length, to + PAREN_USERINFO_MATCH_SPAN));
349
361
  let pos = from;
350
362
  while (pos < to) {
351
- const m = nextParenUserinfo(text, pos);
363
+ const m = nextParenUserinfo(haystack, pos);
352
364
  if (!m || m.start >= to)
353
365
  return false;
354
366
  const hiddenStart = m.nameStart - 1; // the "("
@@ -1,2 +1,2 @@
1
1
  export declare const TOOL_NAME = "markdown-parity-check";
2
- export declare const TOOL_VERSION = "0.2.30";
2
+ export declare const TOOL_VERSION = "0.2.32";
@@ -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.30';
5
+ export const TOOL_VERSION = '0.2.32';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown-parity-check",
3
- "version": "0.2.30",
3
+ "version": "0.2.32",
4
4
  "description": "Compares the main content of a web page's HTML and Markdown representations and reports concrete differences.",
5
5
  "keywords": [
6
6
  "markdown",