markdown-parity-check 0.2.15 → 0.2.17

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.
@@ -39,6 +39,10 @@ export interface AlignmentLimits {
39
39
  maxSimilarityWork: number;
40
40
  }
41
41
  export declare const DEFAULT_LIMITS: Readonly<AlignmentLimits>;
42
+ /** Fills in the defaults for any limit the caller did not set, and validates every one. Exported so
43
+ * compare.ts can resolve the same limits once and thread maxSimilarityWork into its own link-pairing budget
44
+ * (0.2.16). */
45
+ export declare function resolveLimits(limits: Partial<AlignmentLimits> | undefined): AlignmentLimits;
42
46
  /** Thrown when the comparison would exceed a documented resource limit. The caller reports it as an
43
47
  * error result (exit 2), never as a pass or a silently truncated comparison. */
44
48
  export declare class AlignmentLimitError extends Error {
package/dist/src/align.js CHANGED
@@ -32,7 +32,10 @@ export const DEFAULT_LIMITS = Object.freeze({
32
32
  maxSimilarityCandidates: MAX_SIMILARITY_CANDIDATES,
33
33
  maxSimilarityWork: Number.POSITIVE_INFINITY,
34
34
  });
35
- function resolveLimits(limits) {
35
+ /** Fills in the defaults for any limit the caller did not set, and validates every one. Exported so
36
+ * compare.ts can resolve the same limits once and thread maxSimilarityWork into its own link-pairing budget
37
+ * (0.2.16). */
38
+ export function resolveLimits(limits) {
36
39
  const out = { ...DEFAULT_LIMITS, ...(limits ?? {}) };
37
40
  for (const [k, v] of Object.entries(out)) {
38
41
  if (typeof v !== 'number' || Number.isNaN(v) || v <= 0)
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.15\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> 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";
3
+ export declare const HELP = "markdown-parity-check 0.2.17\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> 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/cli.js CHANGED
@@ -69,12 +69,29 @@ function rawWantsJson(argv) {
69
69
  }
70
70
  return wants;
71
71
  }
72
- function positiveInt(name, raw, fallback) {
72
+ // The largest delay Node's own timer accepts (2^31 - 1 ms, about 24.8 days). A larger value is not
73
+ // rejected by Node: it becomes a roughly 1 ms timeout instead, with a TimeoutOverflowWarning, so an
74
+ // error built from the value the caller gave would misreport what is actually going to happen
75
+ // (P-N4, found by an outside review 2026-09-28).
76
+ const MAX_TIMEOUT_MS = 2147483647;
77
+ function positiveInt(name, raw, fallback, max = Number.MAX_SAFE_INTEGER) {
73
78
  if (raw === undefined)
74
79
  return fallback;
75
- if (!/^\d+$/.test(raw) || Number(raw) <= 0)
76
- throw new CliError(`${name} must be a positive integer (got "${raw}").`);
77
- return Number(raw);
80
+ // maskUrl masks the whole value in one piece before it reaches a CliError message, unlike the generic
81
+ // report redactor further down the pipeline (redactText), whose run-based URL detection splits at a raw
82
+ // space inside the value and lets a fragment such as a password through unmasked (P-N3, found by an
83
+ // outside review 2026-09-28); a CLI argument is attacker input the moment it is echoed back in an error,
84
+ // whatever option it was given for.
85
+ const shown = () => maskUrl(raw);
86
+ if (!/^\d+$/.test(raw))
87
+ throw new CliError(`${name} must be a positive integer (got "${shown()}").`);
88
+ const n = Number(raw);
89
+ // A long enough run of digits overflows the IEEE 754 double to Infinity, which the old "> 0" check let
90
+ // through unrejected; Number.isFinite closes that, and max rejects a value this option cannot actually
91
+ // honor before it reaches the code that would silently reinterpret it (P-N4).
92
+ if (!Number.isFinite(n) || n <= 0 || n > max)
93
+ throw new CliError(`${name} must be a positive integer, at most ${max} (got "${shown()}").`);
94
+ return n;
78
95
  }
79
96
  export function parseCliArgs(argv) {
80
97
  let parsed;
@@ -126,7 +143,7 @@ export function parseCliArgs(argv) {
126
143
  frontMatter,
127
144
  format,
128
145
  output: v.output,
129
- timeoutMs: positiveInt('--timeout-ms', v['timeout-ms'], 15000),
146
+ timeoutMs: positiveInt('--timeout-ms', v['timeout-ms'], 15000, MAX_TIMEOUT_MS),
130
147
  maxBytes: positiveInt('--max-bytes', v['max-bytes'], 5 * 1024 * 1024),
131
148
  strict: v.strict ?? false,
132
149
  help: v.help ?? false,
@@ -159,7 +176,11 @@ export function parseCliArgs(argv) {
159
176
  throw new Error('not http(s)');
160
177
  }
161
178
  catch {
162
- throw new CliError(`--base-url must be an absolute http(s) URL (got "${args.baseUrl}").`);
179
+ // args.baseUrl is embedded directly, so it must be masked here rather than left to the generic
180
+ // redactText pass over stderr/JSON: a raw space breaks that pass's run-based URL detection into
181
+ // fragments too small to recognize as one URL, leaving user information such as a password visible
182
+ // (0.2.16, found by an outside review 2026-09-28). maskUrl handles the whole value correctly regardless.
183
+ throw new CliError(`--base-url must be an absolute http(s) URL (got "${maskUrl(args.baseUrl)}").`);
163
184
  }
164
185
  }
165
186
  }
@@ -303,18 +324,29 @@ export async function main(argv, io = { stdout: (s) => process.stdout.write(s),
303
324
  }
304
325
  catch (err) {
305
326
  let message;
327
+ let value;
306
328
  if (err instanceof FetchError)
307
329
  message = `Fetch failed (${err.kind}) for ${err.url}: ${err.message}`;
308
- else if (err instanceof CliError || err instanceof RunError)
330
+ else if (err instanceof CliError)
309
331
  message = err.message;
332
+ else if (err instanceof RunError) {
333
+ message = err.message;
334
+ value = err.value;
335
+ }
310
336
  else
311
337
  message = `Unexpected error: ${err.stack ?? String(err)}`;
312
- report = errorReport(options, html?.meta ?? null, markdown?.meta ?? null, message);
338
+ report = errorReport(options, html?.meta ?? null, markdown?.meta ?? null, message, value);
313
339
  try {
314
340
  emit(report, args, io);
315
341
  }
316
342
  catch (e2) {
317
- io.stderr(`Error: ${e2.message}\n`);
343
+ // The report itself could not be written (P-N5, found by an outside review 2026-09-28): up to here
344
+ // this fell through to a plain stderr line only, even under --format json, unlike every other error
345
+ // path in this function, which puts a JSON report on stdout too when JSON was asked for.
346
+ const writeMessage = e2.message;
347
+ if (args.format === 'json')
348
+ io.stdout(renderJson(errorReport(options, html?.meta ?? null, markdown?.meta ?? null, writeMessage)));
349
+ io.stderr(`Error: ${writeMessage}\n`);
318
350
  }
319
351
  io.stderr(`Error: ${message}\n`);
320
352
  return 2;
@@ -323,7 +355,12 @@ export async function main(argv, io = { stdout: (s) => process.stdout.write(s),
323
355
  emit(report, args, io);
324
356
  }
325
357
  catch (err) {
326
- io.stderr(`Error: ${err.message}\n`);
358
+ // Same P-N5 fallback as the error path above: a write failure got only a plain stderr line before,
359
+ // even under --format json.
360
+ const writeMessage = err.message;
361
+ if (args.format === 'json')
362
+ io.stdout(renderJson(errorReport(options, html?.meta ?? null, markdown?.meta ?? null, writeMessage)));
363
+ io.stderr(`Error: ${writeMessage}\n`);
327
364
  return 2;
328
365
  }
329
366
  return report.summary.exitCode;
@@ -39,7 +39,7 @@ export declare function diffNumbers(a: string[], b: string[]): {
39
39
  * whose text differs only in case or punctuation is one changed text and not a missing and an added link (0.2.13).
40
40
  * @internal Exported for test/compare-links.test.ts.
41
41
  */
42
- export declare function pairLinks(hLinks: Link[], mLinks: Link[]): {
42
+ export declare function pairLinks(hLinks: Link[], mLinks: Link[], maxWork?: number): {
43
43
  pairs: Array<[number, number]>;
44
44
  missing: number[];
45
45
  added: number[];
@@ -1,5 +1,5 @@
1
1
  // The comparison core: aligns blocks and turns the alignment into findings. Pure and network-free.
2
- import { align, UNCERTAIN_THRESHOLD } from './align.js';
2
+ import { align, resolveLimits, AlignmentLimitError, UNCERTAIN_THRESHOLD } from './align.js';
3
3
  import { excerpt, hrefDifference, looseNormalize, maskHref, redactText, relativeHrefRelation, visibleNumbers } from './normalize.js';
4
4
  // The excerpt masks the whole block text before it cuts it, so it is computed once per block. Up to 0.2.11 every
5
5
  // finding computed it again, and a block with thousands of link findings did that thousands of times (0.2.12).
@@ -73,7 +73,7 @@ const linkHref = (l, href) => (l.masked ? '***' : maskHref(href));
73
73
  * whose text differs only in case or punctuation is one changed text and not a missing and an added link (0.2.13).
74
74
  * @internal Exported for test/compare-links.test.ts.
75
75
  */
76
- export function pairLinks(hLinks, mLinks) {
76
+ export function pairLinks(hLinks, mLinks, maxWork = Number.POSITIVE_INFINITY) {
77
77
  const used = new Array(mLinks.length).fill(false);
78
78
  const lists = new Map();
79
79
  const heads = new Map();
@@ -113,6 +113,10 @@ export function pairLinks(hLinks, mLinks) {
113
113
  const seenInH = new Map();
114
114
  const pairs = [];
115
115
  let missing = [];
116
+ // Unresolved links with the same text and unequal counts scan the shared list below once per HTML link (step
117
+ // 2); work counts those scans so maxWork bounds the total the way maxSimilarityWork bounds align's own
118
+ // similarity search (0.2.16, found by an outside review 2026-09-28).
119
+ let work = 0;
116
120
  hLinks.forEach((hl, hi) => {
117
121
  let idx = -1;
118
122
  const k = seenInH.get(hl.text) ?? 0;
@@ -129,6 +133,10 @@ export function pairLinks(hLinks, mLinks) {
129
133
  else {
130
134
  const list = lists.get(key('text', hl.text)) ?? [];
131
135
  for (const i of list) {
136
+ work++;
137
+ if (work > maxWork) {
138
+ throw new AlignmentLimitError(`Comparison limit exceeded: pairing unresolved links by shared text needs more than ${maxWork} comparisons among ${hLinks.length} HTML and ${mLinks.length} Markdown links. Narrow the HTML content with --selector or compare a smaller page.`);
139
+ }
132
140
  if (!used[i] && sameTarget(hl, mLinks[i])) {
133
141
  idx = i;
134
142
  break;
@@ -186,9 +194,9 @@ export function pairLinks(hLinks, mLinks) {
186
194
  });
187
195
  return { pairs, missing, added };
188
196
  }
189
- function compareLinks(out, h, m, bothBases) {
197
+ function compareLinks(out, h, m, bothBases, maxSimilarityWork) {
190
198
  // Link targets are compared unmasked; every value that reaches a finding goes through maskHref.
191
- const { pairs, missing, added } = pairLinks(h.links, m.links);
199
+ const { pairs, missing, added } = pairLinks(h.links, m.links, maxSimilarityWork);
192
200
  const events = [...pairs.map(([hi, mi]) => ({ hi, mi })), ...missing.map((hi) => ({ hi, mi: -1 }))].sort((x, y) => x.hi - y.hi);
193
201
  for (const { hi, mi } of events) {
194
202
  const hl = h.links[hi];
@@ -256,6 +264,13 @@ function compareListItems(out, h, m) {
256
264
  }
257
265
  }
258
266
  function compareTables(out, h, m) {
267
+ // A spanned table already carries its one EXTRACTION_TABLE_SPAN_NOT_COMPARED issue from extraction; the cell
268
+ // positions html.ts still filled in are not reliable, so no cell-by-cell finding is added here (0.2.16).
269
+ // m.spanned matters just as much: a table that is spanned only inside a raw HTML block on the Markdown
270
+ // side (N-P-raw-html, found by an outside review 2026-09-28) carried unreliable cell positions there, and
271
+ // checking h.spanned alone still ran the cell-by-cell comparison below against them.
272
+ if (h.spanned || m.spanned)
273
+ return;
259
274
  const hc = h.cells ?? [];
260
275
  const mc = m.cells ?? [];
261
276
  const hCols = Math.max(0, ...hc.map((r) => r.length));
@@ -274,7 +289,7 @@ function compareTables(out, h, m) {
274
289
  }
275
290
  }
276
291
  }
277
- function comparePair(out, p, h, m, bothBases) {
292
+ function comparePair(out, p, h, m, bothBases, maxSimilarityWork) {
278
293
  if (p.kind === 'moved') {
279
294
  out.push({ code: 'ORDER_CHANGED', severity: 'warning', direction: 'both', message: `The ${label(h)} appears in a different position in the Markdown.`, html: side(h), markdown: side(m) });
280
295
  }
@@ -325,12 +340,13 @@ function comparePair(out, p, h, m, bothBases) {
325
340
  }
326
341
  if (h.type === 'listItem' && m.type === 'listItem')
327
342
  compareListItems(out, h, m);
328
- compareLinks(out, h, m, bothBases);
343
+ compareLinks(out, h, m, bothBases, maxSimilarityWork);
329
344
  }
330
345
  const SEVERITY_ORDER = { error: 0, warning: 1, info: 2 };
331
346
  export function compare(html, markdown, options = {}) {
332
347
  const a = html.blocks;
333
348
  const b = markdown.blocks;
349
+ const lim = resolveLimits(options.limits);
334
350
  const al = align(a, b, options.limits);
335
351
  const findings = [];
336
352
  const bothBases = options.bothBases ?? false;
@@ -342,7 +358,7 @@ export function compare(html, markdown, options = {}) {
342
358
  for (const i of markdown.issues)
343
359
  findings.push({ code: i.code, severity: i.severity, direction: 'markdown_only', message: i.message, markdown: { line: i.line, excerpt: i.excerpt } });
344
360
  for (const p of al.pairs)
345
- comparePair(findings, p, a[p.a], b[p.b], bothBases);
361
+ comparePair(findings, p, a[p.a], b[p.b], bothBases, lim.maxSimilarityWork);
346
362
  for (const i of al.unmatchedA) {
347
363
  const h = a[i];
348
364
  findings.push({ code: 'BLOCK_MISSING', severity: 'error', direction: 'html_only', message: `The ${label(h)} is in the HTML but not in the Markdown.`, html: side(h), before: excerpt(h.type === 'code' ? (h.code ?? h.text) : h.text) });
@@ -11,6 +11,12 @@ export interface HtmlExtractOptions {
11
11
  maxDepth?: number;
12
12
  }
13
13
  export declare class HtmlExtractError extends Error {
14
+ /** The user-supplied value the message names (here, --selector), capped the way worker.js's own cut()
15
+ * caps a reflected value: in its own field, not only interpolated into the sentence, and bounded so an
16
+ * arbitrarily long selector cannot make the error text arbitrarily long (V10-P3-01, found by an outside
17
+ * review 2026-09-28). Report rendering still masks every string, value included, through redactText. */
18
+ value?: string;
19
+ constructor(message: string, value?: string);
14
20
  }
15
21
  /** Default nesting limit for both extractors. The extraction walks the tree recursively, and a document
16
22
  * nested a few thousand levels deep exhausts the call stack (measured 2026-09-11: 5 000 nested div
package/dist/src/html.js CHANGED
@@ -5,6 +5,22 @@ import { selectAll, selectOne } from 'css-select';
5
5
  import { Element, Text } from 'domhandler';
6
6
  import { extractNumbers, looseNormalize, normalizeCode, resolveHref, strictNormalize } from './normalize.js';
7
7
  export class HtmlExtractError extends Error {
8
+ /** The user-supplied value the message names (here, --selector), capped the way worker.js's own cut()
9
+ * caps a reflected value: in its own field, not only interpolated into the sentence, and bounded so an
10
+ * arbitrarily long selector cannot make the error text arbitrarily long (V10-P3-01, found by an outside
11
+ * review 2026-09-28). Report rendering still masks every string, value included, through redactText. */
12
+ value;
13
+ constructor(message, value) {
14
+ super(message);
15
+ if (value !== undefined)
16
+ this.value = capValue(value);
17
+ }
18
+ }
19
+ /** Caps a value that a message reflects back to the caller, the same length worker.js's own cut() uses, and
20
+ * drops a trailing lone high surrogate a plain slice can leave behind. */
21
+ function capValue(s, n = 120) {
22
+ const cut = s.slice(0, n);
23
+ return /[\uD800-\uDBFF]$/.test(cut) ? cut.slice(0, -1) : cut;
8
24
  }
9
25
  /** Default nesting limit for both extractors. The extraction walks the tree recursively, and a document
10
26
  * nested a few thousand levels deep exhausts the call stack (measured 2026-09-11: 5 000 nested div
@@ -295,8 +311,11 @@ function listInfo(ctx, li) {
295
311
  }
296
312
  const info = { ordered, depth: ctx.listBase + Math.max(0, lists - 1), checked: taskState(li) };
297
313
  if (ordered && parent) {
314
+ const reversed = parent.attribs['reversed'] !== undefined;
298
315
  const ordinal = listOrdinals(ctx, parent).get(li);
299
- if (ordinal !== undefined)
316
+ // A reversed list's numbering is not compared (see listOrdinals); every item is left consistent instead of
317
+ // comparing only the first one.
318
+ if (ordinal !== undefined && !reversed)
300
319
  info.ordinal = ordinal;
301
320
  }
302
321
  return info;
@@ -326,15 +345,30 @@ function listOrdinals(ctx, ol) {
326
345
  out.set(item, n);
327
346
  n += reversed ? -1 : 1;
328
347
  });
348
+ // A reversed list only gives its first item a browser-shown number (see above); Markdown has no reversed list,
349
+ // so the later numbers are never compared. Up to 0.2.15 that was silent; listInfo below now also leaves every
350
+ // item's ordinal out, not only the ones already undefined (0.2.16, found by an outside review 2026-09-28).
351
+ if (reversed && items.length > 0) {
352
+ ctx.issues.push({ code: 'EXTRACTION_LIST_REVERSED_NOT_COMPARED', severity: 'info', message: 'This list is reversed; its numbering is not compared, because Markdown has no reversed list to compare it against.', line: lineOf(ctx, ol) });
353
+ }
329
354
  ctx.ordinals.set(ol, out);
330
355
  return out;
331
356
  }
332
- /** The state of the item's own checkbox, not one inside a nested list: true, false, or null without one. */
357
+ /** The state of the item's own checkbox, not one inside a nested list: true, false, or null without one. A
358
+ * checkbox hidden by the hidden or aria-hidden attribute, or wrapped in a hidden ancestor, is skipped like any
359
+ * other hidden content: its subtree is never pushed onto the stack, so an earlier hidden checkbox cannot answer
360
+ * for a later visible one (0.2.16, found by an outside review 2026-09-28). */
333
361
  function taskState(li) {
334
362
  const stack = [...li.children].reverse();
335
363
  while (stack.length > 0) {
336
364
  const node = stack.pop();
337
- if (!(node instanceof Element) || node.name === 'ul' || node.name === 'ol')
365
+ // A <template> element's content is inert: the browser never renders it as part of the document, the
366
+ // same reason hiddenInPage above treats it like a hidden ancestor for the main extraction. taskState had
367
+ // no matching check, so a checkbox sitting in a <template> answered for a later, real checkbox in the
368
+ // same item (found by an outside review 2026-09-28).
369
+ if (!(node instanceof Element) || node.name === 'ul' || node.name === 'ol' || node.name === 'template')
370
+ continue;
371
+ if (hiddenAttr(node))
338
372
  continue;
339
373
  if (node.name === 'input' && (node.attribs['type'] ?? '').toLowerCase() === 'checkbox')
340
374
  return node.attribs['checked'] !== undefined;
@@ -385,6 +419,12 @@ function starlightCode(pre) {
385
419
  const code = meaningful.length === 1 ? meaningful[0] : null;
386
420
  if (!(code instanceof Element) || code.name !== 'code')
387
421
  return visibleCode(pre.children);
422
+ // The specialized shape below reads code.children directly and never passes through visibleCode, so a
423
+ // hidden or aria-hidden <code> wrapper (the whole block, not one .ec-line inside it) was never checked and
424
+ // its lines were exported as if visible (found by an outside review 2026-09-28). A hidden wrapper has no
425
+ // visible code at all, the same outcome visibleCode itself gives a hidden element anywhere else.
426
+ if (hiddenAttr(code))
427
+ return '';
388
428
  const lines = code.children.filter((node) => !(node instanceof Text && !node.data.trim()));
389
429
  if (lines.length === 0 || !lines.every((node) => node instanceof Element && node.name === 'div' && hasClass(node, 'ec-line')))
390
430
  return visibleCode(pre.children);
@@ -395,7 +435,10 @@ function starlightCode(pre) {
395
435
  const language = pre.attribs['data-language'];
396
436
  const diffMarkers = Boolean(language) && language !== 'diff'
397
437
  && lines.some((line) => line instanceof Element && (hasClass(line, 'ins') || hasClass(line, 'del')));
398
- return lines.map((line) => starlightLineText(line.children.filter((node) => !gutter(node)), line, diffMarkers)).join('\n');
438
+ // A line hidden with the hidden attribute is not exported either: up to 0.2.15 every .ec-line reached the text
439
+ // regardless of visibility (0.2.16, found by an outside review 2026-09-28).
440
+ const visibleLines = lines.filter((line) => !(line instanceof Element && hiddenAttr(line)));
441
+ return visibleLines.map((line) => starlightLineText(line.children.filter((node) => !gutter(node)), line, diffMarkers)).join('\n');
399
442
  }
400
443
  /** One Expressive Code line as starlight-llms-txt exports it. The marker goes before the first text of the first
401
444
  * span that is not an indent span; a line whose first such span does not start with text gets no marker. */
@@ -500,6 +543,25 @@ function handleStarlightTabs(ctx, component) {
500
543
  ctx.listBase--;
501
544
  }
502
545
  }
546
+ /** Whether a table cell carries a rowspan or colspan that actually spans more than one row or column; an
547
+ * absent, empty or "1" value is the default and is not a span. An unparseable value is treated as a span too,
548
+ * because a plain grid reading cannot tell what it means either. */
549
+ function hasSpan(el) {
550
+ // rowspan="0" is a distinct HTML value: the cell extends through every remaining row of its row group, so
551
+ // it moves a following row's cell into a different column just as rowspan="2" does, but it was read as
552
+ // n > 1 like an ordinary count and 0 failed that test (found by an outside review 2026-09-28). colspan has
553
+ // no such magic zero value in the HTML parsing algorithm, so its own zero stays "not a span".
554
+ const spans = (attr, zeroIsSpan) => {
555
+ const v = el.attribs[attr];
556
+ if (v === undefined)
557
+ return false;
558
+ const n = Number.parseInt(v, 10);
559
+ if (!Number.isFinite(n))
560
+ return true;
561
+ return n > 1 || (zeroIsSpan && n === 0);
562
+ };
563
+ return spans('rowspan', true) || spans('colspan', false);
564
+ }
503
565
  function handleTable(ctx, table) {
504
566
  // The caption is content: a paragraph before the table, the way a Markdown table's title has to be written. Up to
505
567
  // 0.2.12 it was dropped with its text, numbers and links (found by an outside review 2026-09-26).
@@ -520,6 +582,15 @@ function handleTable(ctx, table) {
520
582
  return true;
521
583
  };
522
584
  const rows = selectAll('tr', table).filter((tr) => closestTable(tr) === table && shown(tr));
585
+ // A rowspan or colspan moves a cell's value into a column a plain row/column reading does not predict, so the
586
+ // table body is not compared, the way a footnote's content is not: the block is still pushed, so it keeps
587
+ // aligning with its Markdown counterpart instead of showing up as a missing and an added block, but compare.ts
588
+ // skips the cell-by-cell check for it once it sees the flag (0.2.16, found by an outside review 2026-09-28); the
589
+ // caption above is unaffected and stays compared either way.
590
+ const spanned = rows.some((tr) => tr.children.some((c) => c instanceof Element && (c.name === 'td' || c.name === 'th') && !isSkipped(c, ctx.root, ctx.profile) && hasSpan(c)));
591
+ if (spanned) {
592
+ ctx.issues.push({ code: 'EXTRACTION_TABLE_SPAN_NOT_COMPARED', severity: 'info', message: 'A table cell carries a rowspan or colspan attribute; a plain row/column reading cannot place its value reliably, so the table body was not compared.', line: lineOf(ctx, table) });
593
+ }
523
594
  const cells = [];
524
595
  const links = [];
525
596
  for (const tr of rows) {
@@ -539,7 +610,7 @@ function handleTable(ctx, table) {
539
610
  if (cells.length === 0)
540
611
  return;
541
612
  const text = cells.map((r) => r.join(' | ')).join(' \n ');
542
- pushBlock(ctx, { type: 'table', text: strictNormalize(text), cells, links }, table, table);
613
+ pushBlock(ctx, { type: 'table', text: strictNormalize(text), cells, links, ...(spanned ? { spanned: true } : {}) }, table, table);
543
614
  }
544
615
  function closestTable(el) {
545
616
  let cur = el.parent;
@@ -565,12 +636,12 @@ function pickRoot(doc, selector, notes, issues) {
565
636
  matches = selectAll(selector, doc.children).filter((n) => n instanceof Element);
566
637
  }
567
638
  catch (err) {
568
- throw new HtmlExtractError(`Invalid selector "${selector}": ${err.message}`);
639
+ throw new HtmlExtractError(`Invalid selector: ${err.message}`, selector);
569
640
  }
570
641
  if (matches.length === 0)
571
- throw new HtmlExtractError(`Selector "${selector}" matched no element.`);
642
+ throw new HtmlExtractError('Selector matched no element.', selector);
572
643
  if (matches.length > 1)
573
- notes.push(`Selector "${selector}" matched ${matches.length} elements; the first in document order was used.`);
644
+ notes.push(`Selector "${capValue(selector)}" matched ${matches.length} elements; the first in document order was used.`);
574
645
  return { root: matches[0], strategy: `selector:${selector}`, confidence: 'high' };
575
646
  }
576
647
  // A candidate the page hides is not its main content. Up to 0.2.12 the first candidate was taken as it was, so a
@@ -632,7 +703,7 @@ export function extractHtml(source, options = {}) {
632
703
  lineStarts.push(i + 1);
633
704
  if (profile === 'starlight')
634
705
  notes.push('Starlight profile: all associated tab panels are compared, including inactive panels; Expressive Code line boundaries and aside titles are retained.');
635
- const ctx = { profile, base, source, lineStarts, blocks: [], notes, root, listBase: 0, ordinals: new Map(), segments: new Map() };
706
+ const ctx = { profile, base, source, lineStarts, blocks: [], notes, root, listBase: 0, ordinals: new Map(), segments: new Map(), issues };
636
707
  // A selector that picks a heading, list item, table or pre keeps that block type, so the root goes
637
708
  // through handleBlock. Every other root is read as a container, a list included: handleBlock's list
638
709
  // branch reads only <li> children, and a root list would lose any other content it holds.
@@ -59,7 +59,11 @@ function inlineChildren(ctx, children, run, line) {
59
59
  // HTML side. Up to 0.2.12 only the tags were dropped and the text between them stayed (found by an outside review
60
60
  // 2026-09-26). Its content up to the matching closing tag is left out; without one the tag is reported.
61
61
  if (!tag.closing && (tag.attribs['hidden'] !== undefined || tag.attribs['aria-hidden'] === 'true')) {
62
- if (VOID_TAGS.has(tag.name) || /\/>\s*$/.test(node.value))
62
+ // A trailing "/>" on a non-void element is not a self-close in HTML: <span hidden/>text</span> does not
63
+ // show "text" in a browser either, only a void element's own tag ends there. Up to 0.2.15 the slash alone
64
+ // was read as a close, so a malformed but common self-closing spelling left hidden text visible (0.2.16,
65
+ // found by an outside review 2026-09-28).
66
+ if (VOID_TAGS.has(tag.name))
63
67
  continue;
64
68
  closes ??= closingTags(children);
65
69
  const end = closes.get(i) ?? -1;
@@ -335,6 +339,16 @@ function handleRawHtml(ctx, value, line) {
335
339
  const absolute = line !== undefined && inner !== undefined ? line + inner - 1 : line;
336
340
  ctx.blocks.push({ ...b, location: { line: absolute, blockIndex: ctx.blocks.length } });
337
341
  }
342
+ // The nested extraction's own structural "not compared" issues (a spanned table, a reversed list) were
343
+ // read off parsed.blocks only up to here; parsed.issues was silently dropped, so a page whose span or
344
+ // reversed numbering lived inside a raw HTML block in the Markdown showed only the generic
345
+ // MARKDOWN_RAW_HTML_PARSED note about readers that do not render HTML, with no disclosure that the span
346
+ // or the numbering itself was not reliably compared (N-P-raw-html, found by an outside review
347
+ // 2026-09-28). The line offset matches the block loop just above.
348
+ for (const i of parsed?.issues ?? []) {
349
+ const absolute = line !== undefined && i.line !== undefined ? line + i.line - 1 : line;
350
+ ctx.issues.push({ ...i, line: absolute });
351
+ }
338
352
  ctx.issues.push({ code: 'MARKDOWN_RAW_HTML_PARSED', severity: 'info', message: `A raw HTML block in the Markdown was parsed as HTML (${blocks.length} block(s)); Markdown readers that do not render HTML will not see it.`, line, excerpt: excerpt(textOnly) });
339
353
  }
340
354
  else if (textOnly !== '') {
@@ -28,6 +28,10 @@ export interface Block {
28
28
  depth?: number;
29
29
  /** Table cells row by row, strictly normalized. Only for type 'table'. */
30
30
  cells?: string[][];
31
+ /** Only for type 'table', HTML side: a cell carries a rowspan or colspan, so a plain row/column reading cannot
32
+ * place its value reliably. compare.ts skips the cell-by-cell check for this block and relies on the
33
+ * EXTRACTION_TABLE_SPAN_NOT_COMPARED issue extraction already raised (0.2.16). */
34
+ spanned?: boolean;
31
35
  /** Code content after normalizeCode: line endings normalized to LF and trailing newlines removed. Only for type 'code'. */
32
36
  code?: string;
33
37
  /** Where a list item sits in its list. Only for type 'listItem' (0.2.13). */
@@ -2,10 +2,17 @@ export declare function strictNormalize(text: string): string;
2
2
  export declare function looseNormalize(text: string): string;
3
3
  /** Code content: CRLF and CR line endings become LF and every trailing newline is removed; other whitespace is kept. */
4
4
  export declare function normalizeCode(code: string): string;
5
+ /** Removes ANSI escape sequences and other C0 controls from a value that may come from a compared page or a raw
6
+ * argument, so a plain --format text report cannot replay them at the terminal (0.2.16, found by an outside
7
+ * review 2026-09-28). */
8
+ export declare function stripControlChars(text: string): string;
5
9
  /** Extracts numeric tokens (prices, percentages, dates, versions, signed values) in source order. */
6
10
  export declare function extractNumbers(text: string): string[];
7
11
  /** Report excerpt: URLs inside the text are masked BEFORE truncation, so a cut query value cannot leak. */
8
12
  export declare function excerpt(text: string, max?: number): string;
13
+ /** Masks every "scheme://(name):secret@" userinfo, leaving the scheme and an unmasked "***@" behind so the rest
14
+ * of the URL (host, path, query, fragment) reaches the ordinary run-based masking below as one unbroken run. */
15
+ export declare function maskParenUserinfo(text: string): string;
9
16
  /**
10
17
  * Whether position at of a source text lies in a part of a URL that maskHref hides: user information, a query
11
18
  * value or the fragment. GFM links a bare address it finds inside another URL on its own: the part after the
@@ -16,7 +23,10 @@ export declare function excerpt(text: string, max?: number): string;
16
23
  * on the side of masking.
17
24
  */
18
25
  export declare function insideHiddenUrlPart(text: string, at: number): boolean;
19
- /** Masks user information, query values and fragments of every URL-like run in a piece of report text. */
26
+ /** Masks user information, query values and fragments of every URL-like run in a piece of report text.
27
+ * maskParenUserinfo runs first for the parenthesized-userinfo shape RUN cannot see as one run, and
28
+ * stripControlChars runs last so a raw ANSI escape from a compared page or an argument cannot reach a plain
29
+ * --format text report (0.2.16, found by an outside review 2026-09-28). */
20
30
  export declare function redactText(text: string): string;
21
31
  /**
22
32
  * The text with the parts that maskHref hides taken out of every URL-like run: user information, query values
@@ -34,6 +34,17 @@ export function looseNormalize(text) {
34
34
  export function normalizeCode(code) {
35
35
  return code.replace(/\r\n?/g, '\n').replace(/\n+$/, '');
36
36
  }
37
+ // Terminal control characters (ANSI escape sequences and other C0 controls) reach a text report unescaped if a
38
+ // compared page or an argument carries one, while --format json is already safe because JSON.stringify escapes
39
+ // every control character. Tab, newline and carriage return are kept: they are ordinary formatting, and by the
40
+ // time most report text reaches this point strictNormalize has already collapsed them to a single space anyway.
41
+ const CONTROL_CHARS = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g;
42
+ /** Removes ANSI escape sequences and other C0 controls from a value that may come from a compared page or a raw
43
+ * argument, so a plain --format text report cannot replay them at the terminal (0.2.16, found by an outside
44
+ * review 2026-09-28). */
45
+ export function stripControlChars(text) {
46
+ return text.replace(CONTROL_CHARS, '');
47
+ }
37
48
  // A numeric token: optional sign (ASCII hyphen, Unicode minus or plus) that is not preceded by a letter
38
49
  // or digit (so the "-09" in 2026-09-10 is a separator, not a sign), digits with inner separators
39
50
  // (decimal, thousands, date, time, version), optional percent or currency sign on either side.
@@ -258,6 +269,84 @@ function rewriteUrlRuns(text, rewrite) {
258
269
  }
259
270
  // How far insideHiddenUrlPart reads the token around a position. A longer token counts as hidden.
260
271
  const HIDDEN_SCAN = 4096;
272
+ // A userinfo wrapped in parentheses right after "scheme://", such as scheme://(name):secret@host, is not a
273
+ // URL-like run under RUN above, because "(" and ")" split runs there: "scheme://", the parenthesized name and
274
+ // the rest starting at the colon become three separate runs, and none of them alone looks like a URL with user
275
+ // information (found by an outside review 2026-09-28).
276
+ //
277
+ // Fail-closed (found by an outside review 2026-09-28): up to here the whole shape (scheme, name, secret and the
278
+ // closing "@") was one regex whose name and secret each carried a fixed quantifier cap (256 and 1024 characters).
279
+ // A name or secret one character longer than its own cap made the regex fail to match at that position at all, so
280
+ // the userinfo reached a report completely unmasked instead of masked, the opposite of what a redaction function
281
+ // should do when it cannot tell how long something is. nextParenUserinfo below finds the fixed "scheme://(" start
282
+ // with a small bounded regex (the scheme name itself is capped at 32 characters, which no real scheme name
283
+ // approaches) and then reads the name and the secret by hand with indexOf, inside PAREN_USERINFO_SCAN characters
284
+ // of that point: a name or secret near the old 256/1024 limits, or well past them, is found and masked all the
285
+ // same, as long as its closing ")" or its "@" sits within that window. When the secret's end cannot be found that
286
+ // way either (no "@" and no other stopping character before the window runs out), the match is still made and
287
+ // masked through the end of the window, because not knowing where a credential ends is a reason to mask more of
288
+ // it, not less. This keeps the scan linear in the length of the text: each "(" is looked at once, and the work
289
+ // done for it is bounded by PAREN_USERINFO_SCAN regardless of how long the rest of the text is, the same trade-off
290
+ // HIDDEN_SCAN below already makes for the same class of problem.
291
+ const PAREN_USERINFO_START = /\b([a-z][a-z0-9+.-]{0,31}):\/\/\(/giu;
292
+ const PAREN_USERINFO_SCAN = HIDDEN_SCAN;
293
+ /** Finds the next "scheme://(name):secret@" match at or after `from`. See the fail-closed rationale above. */
294
+ function nextParenUserinfo(text, from) {
295
+ const re = new RegExp(PAREN_USERINFO_START.source, PAREN_USERINFO_START.flags);
296
+ re.lastIndex = from;
297
+ for (let m = re.exec(text); m !== null; m = re.exec(text)) {
298
+ const nameStart = m.index + m[0].length;
299
+ const nameWindowEnd = Math.min(text.length, nameStart + PAREN_USERINFO_SCAN);
300
+ const nameWindow = text.slice(nameStart, nameWindowEnd);
301
+ const close = nameWindow.indexOf(')');
302
+ const stop = nameWindow.search(/[\s(]/);
303
+ if (close < 0 || (stop >= 0 && stop < close) || nameWindow[close + 1] !== ':') {
304
+ // No well-formed "):" landmark within the window: this "(" is not the shape we mask, so it is left as it is
305
+ // and the search resumes right after it, not from the start again.
306
+ re.lastIndex = nameStart;
307
+ continue;
308
+ }
309
+ const secretStart = nameStart + close + 2;
310
+ const secretWindowEnd = Math.min(text.length, secretStart + PAREN_USERINFO_SCAN);
311
+ const secretWindow = text.slice(secretStart, secretWindowEnd);
312
+ // Once the "):" landmark is found, this is the dangerous shape, so the secret is always masked from here on,
313
+ // through an "@", another character that could not be part of it, or the scan bound itself (fail-closed).
314
+ const stopChar = secretWindow.search(/[@\s()<>"']/);
315
+ const atStop = stopChar >= 0 && secretWindow[stopChar] === '@';
316
+ const secretEnd = stopChar < 0 ? secretWindowEnd : secretStart + stopChar;
317
+ return { start: m.index, scheme: m[1], nameStart, secretStart, secretEnd, end: atStop ? secretEnd + 1 : secretEnd };
318
+ }
319
+ return null;
320
+ }
321
+ /** Masks every "scheme://(name):secret@" userinfo, leaving the scheme and an unmasked "***@" behind so the rest
322
+ * of the URL (host, path, query, fragment) reaches the ordinary run-based masking below as one unbroken run. */
323
+ export function maskParenUserinfo(text) {
324
+ let out = '';
325
+ let pos = 0;
326
+ for (let m = nextParenUserinfo(text, pos); m !== null; m = nextParenUserinfo(text, pos)) {
327
+ out += text.slice(pos, m.start) + `${m.scheme}://***@`;
328
+ pos = m.end;
329
+ }
330
+ return out + text.slice(pos);
331
+ }
332
+ /** Whether position `at` falls inside the parenthesized name or the secret of a nextParenUserinfo match, the same
333
+ * span maskParenUserinfo hides. The search starts and stops within the same HIDDEN_SCAN window
334
+ * insideHiddenUrlPart itself uses, so a link deep inside a large document does not rescan the whole source. */
335
+ function insideParenUserinfo(text, at) {
336
+ const from = Math.max(0, at - HIDDEN_SCAN);
337
+ const to = Math.min(text.length, at + HIDDEN_SCAN);
338
+ let pos = from;
339
+ while (pos < to) {
340
+ const m = nextParenUserinfo(text, pos);
341
+ if (!m || m.start >= to)
342
+ return false;
343
+ const hiddenStart = m.nameStart - 1; // the "("
344
+ if (at >= hiddenStart && at < m.secretEnd)
345
+ return true;
346
+ pos = m.end;
347
+ }
348
+ return false;
349
+ }
261
350
  /**
262
351
  * Whether position at of a source text lies in a part of a URL that maskHref hides: user information, a query
263
352
  * value or the fragment. GFM links a bare address it finds inside another URL on its own: the part after the
@@ -268,6 +357,8 @@ const HIDDEN_SCAN = 4096;
268
357
  * on the side of masking.
269
358
  */
270
359
  export function insideHiddenUrlPart(text, at) {
360
+ if (insideParenUserinfo(text, at))
361
+ return true;
271
362
  const isEdge = (i) => {
272
363
  const ch = text[i];
273
364
  return ch === '<' || ch === '>' || /\s/u.test(ch);
@@ -302,16 +393,24 @@ export function insideHiddenUrlPart(text, at) {
302
393
  }
303
394
  return false;
304
395
  }
305
- /** Masks user information, query values and fragments of every URL-like run in a piece of report text. */
396
+ /** Masks user information, query values and fragments of every URL-like run in a piece of report text.
397
+ * maskParenUserinfo runs first for the parenthesized-userinfo shape RUN cannot see as one run, and
398
+ * stripControlChars runs last so a raw ANSI escape from a compared page or an argument cannot reach a plain
399
+ * --format text report (0.2.16, found by an outside review 2026-09-28). */
306
400
  export function redactText(text) {
307
- return rewriteUrlRuns(text, maskHref);
401
+ return stripControlChars(rewriteUrlRuns(maskParenUserinfo(text), maskHref));
308
402
  }
309
403
  /**
310
404
  * The text with the parts that maskHref hides taken out of every URL-like run: user information, query values
311
405
  * and the fragment. Nothing else moves, and nothing is normalized, so every other number stays as it was.
312
406
  */
313
407
  export function hideUrlSecrets(text) {
314
- return rewriteUrlRuns(text, withoutUrlSecrets);
408
+ // maskParenUserinfo runs first, the same order redactText uses, so a numeric password in the
409
+ // parenthesized-userinfo shape cannot reach extractNumbers as plain text (P-N1, found by an outside
410
+ // review 2026-09-28): up to here only redactText applied it, so visibleNumbers below still read a
411
+ // number straight out of an unmasked "(name):secret@" that the general run-based scan cannot see as
412
+ // one run (see the comment on PAREN_USERINFO_START above).
413
+ return rewriteUrlRuns(maskParenUserinfo(text), withoutUrlSecrets);
315
414
  }
316
415
  /**
317
416
  * The numeric tokens a report may show. extractNumbers reads the whole text, so a numeric query value, such as
@@ -54,7 +54,9 @@ export function renderText(input) {
54
54
  const s = report.summary;
55
55
  out.push(`${TOOL_NAME} ${report.toolVersion} (${report.mode} mode${s.strict ? ', strict' : ''})`);
56
56
  if (s.result === 'error') {
57
- out.push(`Result: ERROR. ${s.error ?? 'The comparison could not be completed.'}`);
57
+ // errorValue (V10-P3-01) is the specific input value the message names, already capped where it was
58
+ // built; shown as its own labelled part rather than folded back into the sentence.
59
+ out.push(`Result: ERROR. ${s.error ?? 'The comparison could not be completed.'}${s.errorValue !== undefined ? ` (value: "${s.errorValue}")` : ''}`);
58
60
  }
59
61
  else {
60
62
  out.push(`Result: ${s.result.toUpperCase()} (${s.errors} error(s), ${s.warnings} warning(s), ${s.infos} info)`);
package/dist/src/run.d.ts CHANGED
@@ -69,16 +69,22 @@ export interface Report {
69
69
  exitCode: 0 | 1 | 2;
70
70
  /** Present when the comparison could not be completed reliably. */
71
71
  error?: string;
72
+ /** The specific input value error names, capped and reported in its own field rather than only inside
73
+ * the message sentence (V10-P3-01, the same split worker.js's own diagnostics already use). */
74
+ errorValue?: string;
72
75
  };
73
76
  findings: Finding[];
74
77
  limitations: string[];
75
78
  }
76
79
  export declare class RunError extends Error {
77
- constructor(message: string);
80
+ /** Carries HtmlExtractError's own capped, separately-fielded reflected value (V10-P3-01) through to the
81
+ * report, instead of only the sentence that already names it. */
82
+ value?: string;
83
+ constructor(message: string, value?: string);
78
84
  }
79
85
  export declare const LIMITATIONS: string[];
80
86
  /** Findings about how the Markdown was delivered, produced by the URL mode before extraction. */
81
87
  export declare function deliveryFindings(md: SourceMeta, body: string): Finding[];
82
88
  export declare function run(html: SourceInput, markdown: SourceInput, options: RunOptions): Report;
83
- export declare function errorReport(options: RunOptions, html: SourceMeta | null, markdown: SourceMeta | null, message: string): Report;
89
+ export declare function errorReport(options: RunOptions, html: SourceMeta | null, markdown: SourceMeta | null, message: string, value?: string): Report;
84
90
  export { maskUrl };
package/dist/src/run.js CHANGED
@@ -9,16 +9,22 @@ import { TOOL_VERSION } from './version.js';
9
9
  export { MAX_NESTING_DEPTH };
10
10
  /** Parser stack exhaustion on hostile nesting is reported as a comparison error, never as a crash. */
11
11
  function extractionError(side, err) {
12
- if (err instanceof HtmlExtractError || err instanceof MarkdownExtractError)
12
+ if (err instanceof HtmlExtractError)
13
+ return new RunError(err.message, err.value);
14
+ if (err instanceof MarkdownExtractError)
13
15
  return new RunError(err.message);
14
16
  if (err instanceof RangeError)
15
17
  return new RunError(`The ${side} could not be parsed within the call stack (${err.message}); it is nested too deeply to compare.`);
16
18
  return null;
17
19
  }
18
20
  export class RunError extends Error {
19
- constructor(message) {
21
+ /** Carries HtmlExtractError's own capped, separately-fielded reflected value (V10-P3-01) through to the
22
+ * report, instead of only the sentence that already names it. */
23
+ value;
24
+ constructor(message, value) {
20
25
  super(message);
21
26
  this.name = 'RunError';
27
+ this.value = value;
22
28
  }
23
29
  }
24
30
  export const LIMITATIONS = [
@@ -129,10 +135,12 @@ export function run(html, markdown, options) {
129
135
  report.summary = { result: failing ? 'fail' : 'pass', strict: options.strict, ...c, coverage: result.coverage, exitCode: failing ? 1 : 0 };
130
136
  return report;
131
137
  }
132
- export function errorReport(options, html, markdown, message) {
138
+ export function errorReport(options, html, markdown, message, value) {
133
139
  const empty = { kind: options.mode === 'url' ? 'url' : 'file', bytes: 0 };
134
140
  const r = baseReport(options, html ?? empty, markdown ?? empty);
135
141
  r.summary.error = message;
142
+ if (value !== undefined)
143
+ r.summary.errorValue = value;
136
144
  return r;
137
145
  }
138
146
  export { maskUrl };
@@ -1,2 +1,2 @@
1
1
  export declare const TOOL_NAME = "markdown-parity-check";
2
- export declare const TOOL_VERSION = "0.2.15";
2
+ export declare const TOOL_VERSION = "0.2.17";
@@ -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.15';
5
+ export const TOOL_VERSION = '0.2.17';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown-parity-check",
3
- "version": "0.2.15",
3
+ "version": "0.2.17",
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",