markdown-parity-check 0.2.18 → 0.2.19
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 +5 -1
- package/dist/src/cli.d.ts +1 -1
- package/dist/src/html.js +3 -2
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,7 +64,9 @@ Exit code 0 means the implemented checks found nothing to reject. It does not pr
|
|
|
64
64
|
|
|
65
65
|
Without `--selector`, the HTML content comes from the first visible `main`, `article` or `[role=main]`. If none of them exists, the page body is used and the report warns that page chrome may leak in. Two visible elements of the same kind that do not contain one another also give a warning, because only the first is compared. Front matter is kept by default and compared as content. If the HTML does not carry the same text, that alone fails the comparison. The tool also warns when the Markdown starts with a block that looks like YAML front matter, and `--front-matter strip` removes it.
|
|
66
66
|
|
|
67
|
-
Headings, paragraphs, list items, tables, code blocks and links are compared block by block. Content marked `hidden` or `aria-hidden` is left out on both sides, and a table caption counts as a paragraph before the table. Missing and added blocks are errors. A change in text or numbers is an error too, as is a changed table or link, and a list item that shows another number or task state. A difference in order, heading level, case, punctuation, list kind or nesting level is a warning. Footnotes in the Markdown are not compared. Each one is reported as a warning, and repeated blocks are reported too. The
|
|
67
|
+
Headings, paragraphs, list items, tables, code blocks and links are compared block by block. Content marked `hidden` or `aria-hidden` is left out on both sides, and a table caption counts as a paragraph before the table. Missing and added blocks are errors. A change in text or numbers is an error too, as is a changed table or link, and a list item that shows another number or task state. A difference in order, heading level, case, punctuation, list kind or nesting level is a warning. Footnotes in the Markdown are not compared. Each one is reported as a warning, and repeated blocks are reported too. The cell-by-cell comparison of a table is skipped when one of its cells has a rowspan or colspan above 1, a rowspan of 0, or a value that is empty or does not begin with a number; the number is read from the value's leading digits, so `2abc` counts as 2. A colspan of 0 and a rowspan or colspan of 1 do not trigger it. The links and the caption of such a table are still compared. The numbering of a reversed list is not compared either. Each skip is reported as an information finding, which does not fail a check, not even with `--strict`.
|
|
68
|
+
|
|
69
|
+
Some content is left out even when it sits inside the main content: the subtrees of `form`, `button`, `input`, `select`, `textarea`, `dialog`, `iframe`, `svg`, `canvas`, `object`, `embed` and `map`, of `nav`, `script`, `style`, `noscript` and `template`, and of any element with the role `navigation`, `banner`, `contentinfo`, `complementary`, `search`, `menu`, `menubar` or `dialog`. The `starlight` profile keeps an iframe that has a source and a title, as a link. An image is compared by its alt text only, not by its address, so two different images with the same alt text compare equal.
|
|
68
70
|
|
|
69
71
|
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.
|
|
70
72
|
|
|
@@ -84,6 +86,8 @@ Both use the comparison core of this package. They differ in which pages they re
|
|
|
84
86
|
|
|
85
87
|
The hosted page also answers a JSON POST, described on the page. It runs the release of this package pinned in [turva-worker](https://github.com/erekola/turva-worker), which can be older than the latest npm release. The report's `toolVersion` field shows which release produced it.
|
|
86
88
|
|
|
89
|
+
Some limits are not in the table. The command-line tool follows at most 5 redirects. The extraction stops with exit code 2 when elements are nested more than 1024 levels deep, and the matching stops the same way when more than 1 000 000 similar block pairs would have to be considered; the library `limits` default to the same values.
|
|
90
|
+
|
|
87
91
|
A hosted check can fail on turva.dev's own pages as well. On 2026-09-11 the check of https://turva.dev/tools returned `fail` with five errors. The Markdown carries a Related heading and four links that the HTML page does not repeat as a list, and the report listed each of them. The same four targets are links inside that page's tool cards, so the report found a missing structure and not missing content. [HTML and Markdown can disagree](https://turva.dev/blog/html-and-markdown-can-disagree) reads that result in full.
|
|
88
92
|
|
|
89
93
|
## Library use
|
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.19\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/html.js
CHANGED
|
@@ -544,8 +544,9 @@ function handleStarlightTabs(ctx, component) {
|
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
546
|
/** Whether a table cell carries a rowspan or colspan that actually spans more than one row or column; an
|
|
547
|
-
* absent
|
|
548
|
-
* because a plain grid reading cannot tell what it means either.
|
|
547
|
+
* absent or "1" value is the default and is not a span. An empty or unparseable value is treated as a span,
|
|
548
|
+
* because a plain grid reading cannot tell what it means either (Number.parseInt gives NaN for both). A
|
|
549
|
+
* rowspan of 0 is a span, a colspan of 0 is not (see the comment inside). */
|
|
549
550
|
function hasSpan(el) {
|
|
550
551
|
// rowspan="0" is a distinct HTML value: the cell extends through every remaining row of its row group, so
|
|
551
552
|
// it moves a following row's cell into a different column just as rowspan="2" does, but it was read as
|
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.19";
|
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.19';
|
package/package.json
CHANGED