markdown-parity-check 0.2.13 → 0.2.15

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/SECURITY.md CHANGED
@@ -22,4 +22,4 @@ Offline mode reads the two files supplied by the caller. The output option write
22
22
 
23
23
  The tool uses runtime dependencies to parse and compare content. Dependency versions and integrity hashes are recorded in package-lock.json. GitHub Actions installs locked dependencies with install scripts disabled and runs type checks and tests on Windows and Ubuntu.
24
24
 
25
- The package is published on npm as `markdown-parity-check`. Each version has a matching GitHub release. The attached tarball is the registry copy after its integrity hash and content were checked against the freshly packed file. The first npm release was published from a maintainer machine and has no provenance attestation. Later versions may be published from GitHub Actions with trusted publishing. Check the version page on npmjs.com before relying on provenance for a given version.
25
+ The package is published on npm as `markdown-parity-check`. Each version has a matching GitHub release. The attached tarball is the registry copy after its integrity hash and content were checked against the freshly packed file. The first npm release was published from a maintainer machine and has no provenance attestation. Its npm metadata names commit 7e8fad9 as its source, while the tag of that release points at 3f3a599, the release commit that follows it and adds the license, this policy, the release workflow and the package manifest without changing src/ or test/. The tag stays where it is. Later versions may be published from GitHub Actions with trusted publishing. Check the version page on npmjs.com before relying on provenance for a given version.
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.13\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.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";
4
4
  export declare class CliError extends Error {
5
5
  }
6
6
  export interface CliArgs {
package/dist/src/cli.js CHANGED
@@ -51,6 +51,24 @@ semantic equivalence.
51
51
  `;
52
52
  export class CliError extends Error {
53
53
  }
54
+ /**
55
+ * Whether the raw argv asks for JSON output, read directly because an argument error can be
56
+ * thrown before parseCliArgs has produced a validated CliArgs (M-01, outside audit 2026-09-26).
57
+ * Accepts both --format json and --format=json; the last occurrence wins, matching parseArgs.
58
+ */
59
+ function rawWantsJson(argv) {
60
+ let wants = false;
61
+ for (let i = 0; i < argv.length; i++) {
62
+ const a = argv[i];
63
+ if (a === undefined)
64
+ continue;
65
+ if (a === '--format')
66
+ wants = argv[i + 1] === 'json';
67
+ else if (a.startsWith('--format='))
68
+ wants = a.slice('--format='.length) === 'json';
69
+ }
70
+ return wants;
71
+ }
54
72
  function positiveInt(name, raw, fallback) {
55
73
  if (raw === undefined)
56
74
  return fallback;
@@ -243,7 +261,17 @@ export async function main(argv, io = { stdout: (s) => process.stdout.write(s),
243
261
  args = parseCliArgs(argv);
244
262
  }
245
263
  catch (err) {
246
- io.stderr(`Error: ${err.message}\n`);
264
+ const message = err.message;
265
+ // Argument validation fails before args.format is known, so a request for JSON is read from
266
+ // the raw argv instead (M-01). The error report shape and exit code match a runtime failure;
267
+ // stdout carries the report on top of, not instead of, the plain-text stderr line every
268
+ // argument error writes, since --output cannot be trusted without validated args and callers
269
+ // already rely on the stderr line regardless of format (test/review-0212.test.ts, test/secrets.test.ts).
270
+ if (rawWantsJson(argv)) {
271
+ const report = errorReport({ strict: false, mode: 'offline' }, null, null, message);
272
+ io.stdout(renderJson(report));
273
+ }
274
+ io.stderr(`Error: ${message}\n`);
247
275
  return 2;
248
276
  }
249
277
  if (args.help) {
@@ -1,2 +1,2 @@
1
1
  export declare const TOOL_NAME = "markdown-parity-check";
2
- export declare const TOOL_VERSION = "0.2.13";
2
+ export declare const TOOL_VERSION = "0.2.15";
@@ -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.13';
5
+ export const TOOL_VERSION = '0.2.15';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown-parity-check",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
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",
@@ -50,7 +50,7 @@
50
50
  "dependencies": {
51
51
  "css-select": "^7.0.0",
52
52
  "domhandler": "^6.0.1",
53
- "domutils": "^3.2.2",
53
+ "domutils": "^4.0.2",
54
54
  "htmlparser2": "^12.0.0",
55
55
  "mdast-util-from-markdown": "^2.0.2",
56
56
  "mdast-util-gfm": "^3.1.0",
@@ -59,6 +59,6 @@
59
59
  "devDependencies": {
60
60
  "@types/mdast": "^4.0.4",
61
61
  "@types/node": "^22.0.0",
62
- "typescript": "^5.9.0"
62
+ "typescript": "^7.0.2"
63
63
  }
64
64
  }