markdown-parity-check 0.2.29 → 0.2.30

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
@@ -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.29 on 2026-10-23. 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.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:
82
82
 
83
83
  ```text
84
- markdown-parity-check 0.2.29 (offline mode)
84
+ markdown-parity-check 0.2.30 (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)
@@ -110,7 +110,7 @@ Front matter is kept by default and compared as content. If the HTML does not ca
110
110
 
111
111
  ### Blocks and severities
112
112
 
113
- Headings, paragraphs, list items, tables, code blocks and links are compared block by block. Content marked `hidden` or `aria-hidden="true"` is left out on both sides, also when a raw HTML wrapper such as `<div hidden>` is opened in one Markdown block and closed in a later one. A table caption counts as a paragraph before the table.
113
+ Headings, paragraphs, list items, tables, code blocks and links are compared block by block. A link that wraps block elements, such as a linked card with a heading and a paragraph, is compared as those blocks: each keeps its own type and heading level and carries the link, and the Markdown side is read the same way, so `## [Title](url)` is a heading with a link. In a table cell the link is read as part of the cell text. Content marked `hidden` or `aria-hidden="true"` is left out on both sides, also when a raw HTML wrapper such as `<div hidden>` is opened in one Markdown block and closed in a later one. A table caption counts as a paragraph before the table.
114
114
 
115
115
  - Errors: missing and added blocks, a change in text or numbers, a changed table or link, and a list item that shows another number or a different checked or unchecked state.
116
116
  - Warnings: a checkbox that is present on one side only, a difference in order, which is also reported for a block that moved and changed only in case, punctuation or typographic characters, and a difference in heading level, case, punctuation, list kind or nesting level. Each footnote in the Markdown is a warning, because footnotes are not compared. These are the main cases, and the `code` of each finding names the exact rule. A missing or extra copy of a repeated block is reported as a missing or added block, which is an error.
@@ -148,7 +148,7 @@ Both use the comparison core of this package. They differ in which pages they re
148
148
  | Topic | Command-line tool | Hosted page |
149
149
  | --- | --- | --- |
150
150
  | Pages | Any public HTTP or HTTPS address, or two local files. | Published turva.dev pages only, except the two tool pages, this one and the llms.txt validator. |
151
- | Fetching | Network requests from your machine. Non-public addresses are refused, also behind DNS and redirects. | The turva.dev Worker renders both versions itself, so a check sends no request over the network. |
151
+ | Fetching | Network requests from your machine. Non-public addresses are refused, also behind DNS and redirects. The tool connects directly to the validated address and does not use `HTTP_PROXY` or `HTTPS_PROXY`, so behind a mandatory proxy use the file mode. | The turva.dev Worker renders both versions itself, so a check sends no request over the network. |
152
152
  | Response size | 5 MiB per response by default, adjustable with `--max-bytes`. | HTML up to 512 KiB. Markdown up to 128 KiB. |
153
153
  | Comparison size | Up to 4 000 000 block pairs. | Up to 250 000 block pairs. |
154
154
  | Rate | Not limited by the tool. | About 10 checks per minute from one IP address at each Cloudflare location. |
@@ -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.29 --ignore-scripts && npm audit signatures
248
+ mkdir verify-mpc && cd verify-mpc && npm init -y && npm install markdown-parity-check@0.2.30 --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.29` must point at that same commit, and `gh api repos/erekola/markdown-parity-check/commits/v0.2.29 --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.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.
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.29\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.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";
4
4
  export declare class CliError extends Error {
5
5
  }
6
6
  export interface CliArgs {
package/dist/src/html.js CHANGED
@@ -237,8 +237,43 @@ function flushRun(ctx, run, container, type = 'paragraph', list) {
237
237
  const node = run.firstNode ?? container;
238
238
  pushBlock(ctx, { type, text, links: run.links, ...(type === 'listItem' && list ? { list } : {}) }, node, container);
239
239
  }
240
- function hasBlockChild(el) {
241
- return el.children.some((c) => c instanceof Element && BLOCK_TAGS.has(c.name) && !SKIP_TAGS.has(c.name));
240
+ /**
241
+ * A link whose children hold a block element, such as a linked card (<a href><h2>..</h2><p>..</p></a>). Up to 0.2.29
242
+ * inlineText flattened it into one run of text, so the card's heading stopped being a heading: a faithful Markdown
243
+ * card (## [title](url)) failed with four errors, while a Markdown copy that wrote the title as a plain linked
244
+ * paragraph passed, also under --strict (found on real sites, 2026-11-02). Such an anchor is now a container in the
245
+ * walk (walkBlockAnchor). An anchor without href, or one with inline content only, is still inline text, and so is
246
+ * one whose block children are all skipped.
247
+ */
248
+ function isBlockAnchor(ctx, el) {
249
+ if (el.name !== 'a' || el.attribs['href'] === undefined)
250
+ return false;
251
+ if (isSkipped(el, ctx.root, ctx.profile))
252
+ return false;
253
+ return el.children.some((c) => c instanceof Element && BLOCK_TAGS.has(c.name) && !SKIP_TAGS.has(c.name) && !isSkipped(c, ctx.root, ctx.profile));
254
+ }
255
+ function hasBlockChild(ctx, el) {
256
+ return el.children.some((c) => c instanceof Element && ((BLOCK_TAGS.has(c.name) && !SKIP_TAGS.has(c.name)) || isBlockAnchor(ctx, c)));
257
+ }
258
+ /** Walks the children of a block anchor as blocks, then records the anchor's link on every block that came out of
259
+ * it, with that block's own text as the link text, so a heading stays a heading of its depth and a paragraph a
260
+ * paragraph. Markdown reads `## [t](u)` as a heading with the link t, which this matches exactly. */
261
+ function walkBlockAnchor(ctx, a) {
262
+ const start = ctx.blocks.length;
263
+ walk(ctx, a);
264
+ const rawHref = a.attribs['href'] ?? '';
265
+ const resolved = resolveHref(rawHref, ctx.base);
266
+ for (let i = start; i < ctx.blocks.length; i++) {
267
+ const block = ctx.blocks[i];
268
+ block.links.unshift({ text: strictNormalize(block.text), rawHref, resolved });
269
+ }
270
+ }
271
+ /** In a list item, a link whose only content is one plain paragraph is the item's own text, as before: the item
272
+ * stays a listItem and the link text is the paragraph text. Any other block anchor is a block child of the item. */
273
+ function isParagraphOnlyAnchor(ctx, a) {
274
+ const meaningful = a.children.filter((c) => !(c instanceof Text && c.data.trim() === '') && !(c instanceof Element && isSkipped(c, ctx.root, ctx.profile)));
275
+ const only = meaningful.length === 1 ? meaningful[0] : null;
276
+ return only instanceof Element && only.name === 'p' && !hasBlockChild(ctx, only);
242
277
  }
243
278
  function walk(ctx, el) {
244
279
  // A container: inline runs between block children become paragraphs; block children recurse.
@@ -246,7 +281,7 @@ function walk(ctx, el) {
246
281
  for (const child of el.children) {
247
282
  if (child instanceof Element && isSkipped(child, ctx.root, ctx.profile))
248
283
  continue;
249
- if (child instanceof Element && (BLOCK_TAGS.has(child.name) || (ctx.profile === 'starlight' && child.name === 'starlight-tabs'))) {
284
+ if (child instanceof Element && (BLOCK_TAGS.has(child.name) || isBlockAnchor(ctx, child) || (ctx.profile === 'starlight' && child.name === 'starlight-tabs'))) {
250
285
  flushRun(ctx, run, el);
251
286
  run = newRun();
252
287
  handleBlock(ctx, child);
@@ -258,6 +293,10 @@ function walk(ctx, el) {
258
293
  flushRun(ctx, run, el);
259
294
  }
260
295
  function handleBlock(ctx, el) {
296
+ if (el.name === 'a') {
297
+ walkBlockAnchor(ctx, el);
298
+ return;
299
+ }
261
300
  if (ctx.profile === 'starlight' && el.name === 'starlight-tabs') {
262
301
  handleStarlightTabs(ctx, el);
263
302
  return;
@@ -273,7 +312,7 @@ function handleBlock(ctx, el) {
273
312
  return;
274
313
  }
275
314
  if (el.name === 'p' || el.name === 'dt' || el.name === 'dd' || el.name === 'figcaption' || el.name === 'summary' || el.name === 'caption' || el.name === 'address') {
276
- if (hasBlockChild(el)) {
315
+ if (hasBlockChild(ctx, el)) {
277
316
  walk(ctx, el);
278
317
  return;
279
318
  }
@@ -412,8 +451,9 @@ function handleListItem(ctx, li) {
412
451
  for (const child of li.children) {
413
452
  if (child instanceof Element && isSkipped(child, ctx.root, ctx.profile))
414
453
  continue;
415
- if (child instanceof Element && (BLOCK_TAGS.has(child.name) || (ctx.profile === 'starlight' && child.name === 'starlight-tabs'))) {
416
- if (!ownFlushed && child.name === 'p' && !hasBlockChild(child) && strictNormalize(run.text) === '') {
454
+ const blockAnchor = child instanceof Element && isBlockAnchor(ctx, child) && !isParagraphOnlyAnchor(ctx, child);
455
+ if (child instanceof Element && (BLOCK_TAGS.has(child.name) || blockAnchor || (ctx.profile === 'starlight' && child.name === 'starlight-tabs'))) {
456
+ if (!ownFlushed && child.name === 'p' && !hasBlockChild(ctx, child) && strictNormalize(run.text) === '') {
417
457
  for (const c of child.children)
418
458
  inlineText(ctx, c, run);
419
459
  if (run.firstNode === null)
@@ -1,2 +1,2 @@
1
1
  export declare const TOOL_NAME = "markdown-parity-check";
2
- export declare const TOOL_VERSION = "0.2.29";
2
+ export declare const TOOL_VERSION = "0.2.30";
@@ -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.29';
5
+ export const TOOL_VERSION = '0.2.30';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown-parity-check",
3
- "version": "0.2.29",
3
+ "version": "0.2.30",
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",