markdown-parity-check 0.2.35 → 0.2.36
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 +7 -5
- package/dist/src/cli.d.ts +1 -1
- package/dist/src/cli.js +22 -1
- package/dist/src/normalize.js +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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.
|
|
81
|
+
This is the text report for the matching fixture pair in this repository, run with version 0.2.36 on 2026-11-10. 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.
|
|
84
|
+
markdown-parity-check 0.2.36 (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)
|
|
@@ -137,7 +137,7 @@ A `<br>` in a code block is a line break. A code block that differs only in whit
|
|
|
137
137
|
|
|
138
138
|
In URL mode the Markdown response is checked first. An HTTP error or an HTML page in place of Markdown fails the check, and nothing is compared. A Markdown response labelled `text/plain` is a warning, and any other content type than `text/markdown` or `text/x-markdown` is an error. A comment, an XML declaration or another declaration before the doctype does not hide an HTML page from this check. If the HTML request itself returns an HTTP error, the run ends with exit code 2.
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
A response whose Content-Type header names `text/html` or `application/xhtml+xml` is decoded by its byte order mark first, then by the charset of that header, then by a meta charset declaration in its first 1024 bytes, and as UTF-8 when none of them names a known encoding. The choice follows the type of the response, not the request: any other response, including an HTML page sent with another type or with no Content-Type header, is decoded by the charset of its header or as UTF-8, and its byte order mark and meta declaration do not choose the encoding. A Markdown response is decoded that way too.
|
|
141
141
|
|
|
142
142
|
### Limits of the method
|
|
143
143
|
|
|
@@ -222,6 +222,8 @@ The JSON report is the `Report` type. Its top-level fields are:
|
|
|
222
222
|
| `findings` | A list of `Finding` objects, each with `code`, `severity`, `direction` and `message`, and where they apply the `html` and `markdown` locations and the `before` and `after` text. |
|
|
223
223
|
| `limitations` | The fixed list of what the check does not cover. |
|
|
224
224
|
|
|
225
|
+
An error report for an argument error is built before the arguments are validated, so the command takes `mode` from the presence of `--url` and `summary.strict` from the presence of `--strict` in the command line. A command line with neither is recorded as `offline` and not strict, and so is one that gives `--markdown-url` without `--url`.
|
|
226
|
+
|
|
225
227
|
## Development
|
|
226
228
|
|
|
227
229
|
The sources are TypeScript under `src/`, compiled with `tsc` to `dist/`. Clone the repository, build it and run the bundled example:
|
|
@@ -249,10 +251,10 @@ Only after that check does it create the GitHub release with the verified tarbal
|
|
|
249
251
|
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.
|
|
250
252
|
|
|
251
253
|
```sh
|
|
252
|
-
mkdir verify-mpc && cd verify-mpc && npm init -y && npm install markdown-parity-check@0.2.
|
|
254
|
+
mkdir verify-mpc && cd verify-mpc && npm init -y && npm install markdown-parity-check@0.2.36 --ignore-scripts && npm audit signatures
|
|
253
255
|
```
|
|
254
256
|
|
|
255
|
-
`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.
|
|
257
|
+
`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.36` must point at that same commit, and `gh api repos/erekola/markdown-parity-check/commits/v0.2.36 --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.
|
|
256
258
|
|
|
257
259
|
## Security
|
|
258
260
|
|
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.36\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 {
|
package/dist/src/cli.js
CHANGED
|
@@ -71,6 +71,26 @@ function rawWantsJson(argv) {
|
|
|
71
71
|
}
|
|
72
72
|
return wants;
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* What the invocation asked for, read from the raw argv for the same reason as rawWantsJson: an argument error is
|
|
76
|
+
* thrown before parseCliArgs has produced a validated CliArgs. URL mode is the presence of --url, as in the normal
|
|
77
|
+
* path (`args.url !== undefined`), and strict is the presence of --strict. Both are read until a bare `--`, after
|
|
78
|
+
* which every token is a positional argument. An invocation that gives neither stays offline and not strict, which
|
|
79
|
+
* is the only answer the arguments leave open (for example --markdown-url without --url).
|
|
80
|
+
*/
|
|
81
|
+
function rawInvocation(argv) {
|
|
82
|
+
let mode = 'offline';
|
|
83
|
+
let strict = false;
|
|
84
|
+
for (const a of argv) {
|
|
85
|
+
if (a === '--')
|
|
86
|
+
break;
|
|
87
|
+
if (a === '--url' || a.startsWith('--url='))
|
|
88
|
+
mode = 'url';
|
|
89
|
+
else if (a === '--strict')
|
|
90
|
+
strict = true;
|
|
91
|
+
}
|
|
92
|
+
return { mode, strict };
|
|
93
|
+
}
|
|
74
94
|
// The largest delay Node's own timer accepts (2^31 - 1 ms, about 24.8 days). A larger value is not
|
|
75
95
|
// rejected by Node: it becomes a roughly 1 ms timeout instead, with a TimeoutOverflowWarning, so an
|
|
76
96
|
// error built from the value the caller gave would misreport what is actually going to happen
|
|
@@ -315,8 +335,9 @@ export async function main(argv, io = { stdout: (s) => process.stdout.write(s),
|
|
|
315
335
|
// stdout carries the report on top of, not instead of, the plain-text stderr line every
|
|
316
336
|
// argument error writes, since --output cannot be trusted without validated args and callers
|
|
317
337
|
// already rely on the stderr line regardless of format (test/review-0212.test.ts, test/secrets.test.ts).
|
|
338
|
+
// The report records the mode and strictness the arguments asked for where they say so (rawInvocation).
|
|
318
339
|
if (rawWantsJson(argv)) {
|
|
319
|
-
const report = errorReport(
|
|
340
|
+
const report = errorReport(rawInvocation(argv), null, null, message);
|
|
320
341
|
io.stdout(renderJson(report));
|
|
321
342
|
}
|
|
322
343
|
io.stderr(`Error: ${message}\n`);
|
package/dist/src/normalize.js
CHANGED
|
@@ -515,7 +515,7 @@ export function maskHref(href) {
|
|
|
515
515
|
const u = new URL(href);
|
|
516
516
|
u.username = '';
|
|
517
517
|
u.password = '';
|
|
518
|
-
// One pass
|
|
518
|
+
// One pass: a Set keeps the first-seen key order and merges duplicates, and the
|
|
519
519
|
// masked query is built once with append. Calling searchParams.set for each key re-serializes the whole query
|
|
520
520
|
// every time, which is quadratic in the number of keys (5 000 keys took 2.1 s, 20 000 took 35 s). An empty
|
|
521
521
|
// query is left as it is, so "?" stays "?".
|
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.36";
|
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.36';
|
package/package.json
CHANGED