markdown-parity-check 0.2.7 → 0.2.9
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 +1 -0
- package/dist/src/cli.d.ts +2 -1
- package/dist/src/cli.js +8 -1
- package/dist/src/html.d.ts +2 -0
- package/dist/src/html.js +177 -11
- package/dist/src/run.d.ts +1 -0
- package/dist/src/run.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
|
@@ -51,6 +51,7 @@ Exit code 0 means the implemented checks found nothing to reject. It does not pr
|
|
|
51
51
|
| `--html-file PATH --markdown-file PATH` | Compare two local files instead. |
|
|
52
52
|
| `--base-url URL` | Resolve relative links in local files. Local-file mode only. |
|
|
53
53
|
| `--selector CSS` | Choose the HTML content container. |
|
|
54
|
+
| `--html-profile generic` or `--html-profile starlight` | Use the generic HTML rules, which is the default, or the Starlight rules, which also compare inactive tab panels and keep Expressive Code line breaks. |
|
|
54
55
|
| `--front-matter keep` or `--front-matter strip` | Keep Markdown front matter, which is the default, or remove it before the comparison. |
|
|
55
56
|
| `--format text` or `--format json` | Print a readable report, which is the default, or a structured one. |
|
|
56
57
|
| `--output PATH` | Write the report to a file. An input file is never overwritten. |
|
package/dist/src/cli.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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.9\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 {
|
|
7
|
+
htmlProfile: 'generic' | 'starlight';
|
|
7
8
|
url?: string;
|
|
8
9
|
markdownUrl?: string;
|
|
9
10
|
htmlFile?: string;
|
package/dist/src/cli.js
CHANGED
|
@@ -26,6 +26,8 @@ Modes:
|
|
|
26
26
|
--base-url <url> Offline: base for resolving relative links on both sides.
|
|
27
27
|
|
|
28
28
|
Options:
|
|
29
|
+
--html-profile generic|starlight
|
|
30
|
+
HTML extraction rules (default: generic). Starlight includes inactive tab panels.
|
|
29
31
|
--selector <css> CSS selector for the HTML main content (default: main, article, [role=main], then body).
|
|
30
32
|
--front-matter keep|strip
|
|
31
33
|
Markdown front matter. keep (default) removes nothing and warns when the document
|
|
@@ -64,6 +66,7 @@ export function parseCliArgs(argv) {
|
|
|
64
66
|
allowPositionals: false,
|
|
65
67
|
strict: true,
|
|
66
68
|
options: {
|
|
69
|
+
'html-profile': { type: 'string', default: 'generic' },
|
|
67
70
|
url: { type: 'string' },
|
|
68
71
|
'markdown-url': { type: 'string' },
|
|
69
72
|
'html-file': { type: 'string' },
|
|
@@ -85,6 +88,9 @@ export function parseCliArgs(argv) {
|
|
|
85
88
|
throw new CliError(err.message);
|
|
86
89
|
}
|
|
87
90
|
const v = parsed.values;
|
|
91
|
+
const htmlProfile = v['html-profile'];
|
|
92
|
+
if (htmlProfile !== 'generic' && htmlProfile !== 'starlight')
|
|
93
|
+
throw new CliError('--html-profile must be generic or starlight.');
|
|
88
94
|
const format = v.format;
|
|
89
95
|
if (format !== 'text' && format !== 'json')
|
|
90
96
|
throw new CliError(`--format must be text or json (got "${format}").`);
|
|
@@ -92,6 +98,7 @@ export function parseCliArgs(argv) {
|
|
|
92
98
|
if (frontMatter !== 'keep' && frontMatter !== 'strip')
|
|
93
99
|
throw new CliError(`--front-matter must be keep or strip (got "${frontMatter}").`);
|
|
94
100
|
const args = {
|
|
101
|
+
htmlProfile,
|
|
95
102
|
url: v.url,
|
|
96
103
|
markdownUrl: v['markdown-url'],
|
|
97
104
|
htmlFile: v['html-file'],
|
|
@@ -215,7 +222,7 @@ export async function main(argv, io = { stdout: (s) => process.stdout.write(s),
|
|
|
215
222
|
io.stdout(`${TOOL_VERSION}\n`);
|
|
216
223
|
return 0;
|
|
217
224
|
}
|
|
218
|
-
const options = { selector: args.selector, frontMatter: args.frontMatter, strict: args.strict, mode: args.url !== undefined ? 'url' : 'offline' };
|
|
225
|
+
const options = { htmlProfile: args.htmlProfile, selector: args.selector, frontMatter: args.frontMatter, strict: args.strict, mode: args.url !== undefined ? 'url' : 'offline' };
|
|
219
226
|
let html = null;
|
|
220
227
|
let markdown = null;
|
|
221
228
|
let report;
|
package/dist/src/html.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type ParentNode } from 'domhandler';
|
|
2
2
|
import type { Extraction } from './model.js';
|
|
3
3
|
export interface HtmlExtractOptions {
|
|
4
|
+
/** Opt-in component semantics. The default keeps generic HTML visibility rules. */
|
|
5
|
+
profile?: 'generic' | 'starlight';
|
|
4
6
|
/** User supplied CSS selector for the main content. */
|
|
5
7
|
selector?: string;
|
|
6
8
|
/** Base URL for resolving relative links; a <base href> in the document takes precedence. */
|
package/dist/src/html.js
CHANGED
|
@@ -74,13 +74,41 @@ function hasLaterSameNamedSibling(el) {
|
|
|
74
74
|
}
|
|
75
75
|
return false;
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
|
|
77
|
+
function hasClass(el, name) {
|
|
78
|
+
return (el.attribs.class ?? '').split(/\s+/).includes(name);
|
|
79
|
+
}
|
|
80
|
+
function ancestor(el, predicate) {
|
|
81
|
+
let parent = el.parent;
|
|
82
|
+
while (parent instanceof Element) {
|
|
83
|
+
if (predicate(parent))
|
|
84
|
+
return parent;
|
|
85
|
+
parent = parent.parent;
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
/** The link starlight-llms-txt writes for an iframe. hast-util-to-mdast keeps an iframe only when it has both a
|
|
90
|
+
* source and a title, as a link whose text is the title; any other iframe produces nothing. */
|
|
91
|
+
function iframeLink(el) {
|
|
92
|
+
const src = el.attribs['src'] ?? '';
|
|
93
|
+
const title = el.attribs['title'] ?? '';
|
|
94
|
+
return src && title ? { src, title } : null;
|
|
95
|
+
}
|
|
96
|
+
function isSkipped(el, root, profile = 'generic', ignoreHidden = false) {
|
|
97
|
+
if (SKIP_TAGS.has(el.name) && !(profile === 'starlight' && el.name === 'iframe' && iframeLink(el)))
|
|
79
98
|
return true;
|
|
80
99
|
const role = (el.attribs['role'] ?? '').toLowerCase();
|
|
81
100
|
if (SKIP_ROLES.has(role))
|
|
82
101
|
return true;
|
|
83
|
-
if (el.attribs['hidden'] !== undefined
|
|
102
|
+
if (el.attribs['hidden'] !== undefined && !ignoreHidden)
|
|
103
|
+
return true;
|
|
104
|
+
const asideTitle = profile === 'starlight' && el.name === 'p' && hasClass(el, 'starlight-aside__title')
|
|
105
|
+
&& el.parent instanceof Element && el.parent.name === 'aside' && hasClass(el.parent, 'starlight-aside');
|
|
106
|
+
if (el.attribs['aria-hidden'] === 'true' && !asideTitle)
|
|
107
|
+
return true;
|
|
108
|
+
// Expressive Code's terminal-frame label is UI text, not source code or a filename.
|
|
109
|
+
if (profile === 'starlight' && el.name === 'span' && hasClass(el, 'sr-only')
|
|
110
|
+
&& el.parent instanceof Element && el.parent.name === 'figcaption'
|
|
111
|
+
&& ancestor(el, (node) => hasClass(node, 'expressive-code')))
|
|
84
112
|
return true;
|
|
85
113
|
// header/footer are page chrome only when they sit directly under body (or the html root), not inside an
|
|
86
114
|
// article, where they usually carry metadata that belongs to the content.
|
|
@@ -102,7 +130,7 @@ function inlineText(ctx, node, run) {
|
|
|
102
130
|
}
|
|
103
131
|
if (!(node instanceof Element))
|
|
104
132
|
return;
|
|
105
|
-
if (isSkipped(node, ctx.root))
|
|
133
|
+
if (isSkipped(node, ctx.root, ctx.profile))
|
|
106
134
|
return;
|
|
107
135
|
if (run.firstNode === null)
|
|
108
136
|
run.firstNode = node;
|
|
@@ -116,6 +144,14 @@ function inlineText(ctx, node, run) {
|
|
|
116
144
|
run.text += ` ${alt} `;
|
|
117
145
|
return;
|
|
118
146
|
}
|
|
147
|
+
if (ctx.profile === 'starlight' && node.name === 'iframe') {
|
|
148
|
+
const link = iframeLink(node);
|
|
149
|
+
if (link) {
|
|
150
|
+
run.links.push({ text: strictNormalize(link.title), rawHref: link.src, resolved: resolveHref(link.src, ctx.base) });
|
|
151
|
+
run.text += link.title;
|
|
152
|
+
}
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
119
155
|
if (node.name === 'a' && node.attribs['href'] !== undefined) {
|
|
120
156
|
const inner = newRun();
|
|
121
157
|
for (const child of node.children)
|
|
@@ -156,9 +192,9 @@ function walk(ctx, el) {
|
|
|
156
192
|
// A container: inline runs between block children become paragraphs; block children recurse.
|
|
157
193
|
let run = newRun();
|
|
158
194
|
for (const child of el.children) {
|
|
159
|
-
if (child instanceof Element && isSkipped(child, ctx.root))
|
|
195
|
+
if (child instanceof Element && isSkipped(child, ctx.root, ctx.profile))
|
|
160
196
|
continue;
|
|
161
|
-
if (child instanceof Element && BLOCK_TAGS.has(child.name)) {
|
|
197
|
+
if (child instanceof Element && (BLOCK_TAGS.has(child.name) || (ctx.profile === 'starlight' && child.name === 'starlight-tabs'))) {
|
|
162
198
|
flushRun(ctx, run, el);
|
|
163
199
|
run = newRun();
|
|
164
200
|
handleBlock(ctx, child);
|
|
@@ -170,6 +206,10 @@ function walk(ctx, el) {
|
|
|
170
206
|
flushRun(ctx, run, el);
|
|
171
207
|
}
|
|
172
208
|
function handleBlock(ctx, el) {
|
|
209
|
+
if (ctx.profile === 'starlight' && el.name === 'starlight-tabs') {
|
|
210
|
+
handleStarlightTabs(ctx, el);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
173
213
|
const m = HEADING_RE.exec(el.name);
|
|
174
214
|
if (m) {
|
|
175
215
|
const run = newRun();
|
|
@@ -192,7 +232,7 @@ function handleBlock(ctx, el) {
|
|
|
192
232
|
return;
|
|
193
233
|
}
|
|
194
234
|
if (el.name === 'pre') {
|
|
195
|
-
const code = normalizeCode(textContent(el));
|
|
235
|
+
const code = normalizeCode(ctx.profile === 'starlight' ? starlightCode(el) : textContent(el));
|
|
196
236
|
if (code.trim() !== '')
|
|
197
237
|
pushBlock(ctx, { type: 'code', text: strictNormalize(code), code, links: [] }, el, el);
|
|
198
238
|
return;
|
|
@@ -225,9 +265,9 @@ function handleListItem(ctx, li) {
|
|
|
225
265
|
let run = newRun();
|
|
226
266
|
let ownFlushed = false;
|
|
227
267
|
for (const child of li.children) {
|
|
228
|
-
if (child instanceof Element && isSkipped(child, ctx.root))
|
|
268
|
+
if (child instanceof Element && isSkipped(child, ctx.root, ctx.profile))
|
|
229
269
|
continue;
|
|
230
|
-
if (child instanceof Element && BLOCK_TAGS.has(child.name)) {
|
|
270
|
+
if (child instanceof Element && (BLOCK_TAGS.has(child.name) || (ctx.profile === 'starlight' && child.name === 'starlight-tabs'))) {
|
|
231
271
|
if (!ownFlushed && child.name === 'p' && !hasBlockChild(child) && strictNormalize(run.text) === '') {
|
|
232
272
|
for (const c of child.children)
|
|
233
273
|
inlineText(ctx, c, run);
|
|
@@ -252,6 +292,127 @@ function handleListItem(ctx, li) {
|
|
|
252
292
|
}
|
|
253
293
|
flushRun(ctx, run, li, ownFlushed ? 'paragraph' : 'listItem');
|
|
254
294
|
}
|
|
295
|
+
/** Read only recognized direct line wrappers; never discard extra non-whitespace code children. */
|
|
296
|
+
function starlightCode(pre) {
|
|
297
|
+
if (!ancestor(pre, (node) => hasClass(node, 'expressive-code')))
|
|
298
|
+
return textContent(pre);
|
|
299
|
+
const meaningful = pre.children.filter((node) => !(node instanceof Text && !node.data.trim()));
|
|
300
|
+
const code = meaningful.length === 1 ? meaningful[0] : null;
|
|
301
|
+
if (!(code instanceof Element) || code.name !== 'code')
|
|
302
|
+
return textContent(pre);
|
|
303
|
+
const lines = code.children.filter((node) => !(node instanceof Text && !node.data.trim()));
|
|
304
|
+
if (lines.length === 0 || !lines.every((node) => node instanceof Element && node.name === 'div' && hasClass(node, 'ec-line')))
|
|
305
|
+
return textContent(pre);
|
|
306
|
+
// A gutter (line numbers from a plugin) sits beside the code as a direct child of the line; it is not code text.
|
|
307
|
+
const gutter = (node) => node instanceof Element && node.name === 'div' && hasClass(node, 'gutter');
|
|
308
|
+
// starlight-llms-txt prefixes + or - to ins and del lines when the block has a language other than diff. The page
|
|
309
|
+
// shows those lines only through styling, so the marker is in the export and not in the HTML text.
|
|
310
|
+
const language = pre.attribs['data-language'];
|
|
311
|
+
const diffMarkers = Boolean(language) && language !== 'diff'
|
|
312
|
+
&& lines.some((line) => line instanceof Element && (hasClass(line, 'ins') || hasClass(line, 'del')));
|
|
313
|
+
return lines.map((line) => starlightLineText(line.children.filter((node) => !gutter(node)), line, diffMarkers)).join('\n');
|
|
314
|
+
}
|
|
315
|
+
/** One Expressive Code line as starlight-llms-txt exports it. The marker goes before the first text of the first
|
|
316
|
+
* span that is not an indent span; a line whose first such span does not start with text gets no marker. */
|
|
317
|
+
function starlightLineText(children, line, diffMarkers) {
|
|
318
|
+
const inserted = hasClass(line, 'ins');
|
|
319
|
+
if (!diffMarkers || !(inserted || hasClass(line, 'del')))
|
|
320
|
+
return textContent(children);
|
|
321
|
+
const target = firstNonIndentSpan(children)?.children[0];
|
|
322
|
+
if (!(target instanceof Text))
|
|
323
|
+
return textContent(children);
|
|
324
|
+
let out = '';
|
|
325
|
+
const collect = (nodes) => {
|
|
326
|
+
for (const node of nodes) {
|
|
327
|
+
if (node instanceof Text)
|
|
328
|
+
out += (node === target ? (inserted ? '+' : '-') : '') + node.data;
|
|
329
|
+
else if (node instanceof Element)
|
|
330
|
+
collect(node.children);
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
collect(children);
|
|
334
|
+
return out;
|
|
335
|
+
}
|
|
336
|
+
/** The first span without the indent class in document order, the element hast-util-select finds for
|
|
337
|
+
* `span:not(.indent)` inside a line. */
|
|
338
|
+
function firstNonIndentSpan(nodes) {
|
|
339
|
+
for (const node of nodes) {
|
|
340
|
+
if (!(node instanceof Element))
|
|
341
|
+
continue;
|
|
342
|
+
if (node.name === 'span' && !hasClass(node, 'indent'))
|
|
343
|
+
return node;
|
|
344
|
+
const inner = firstNonIndentSpan(node.children);
|
|
345
|
+
if (inner)
|
|
346
|
+
return inner;
|
|
347
|
+
}
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
/** Starlight's Markdown exporter represents every tab as a labelled list item, including inactive panels. */
|
|
351
|
+
function handleStarlightTabs(ctx, component) {
|
|
352
|
+
// A tab counts only when nothing between it and the component hides it. A panel counts only as a direct child of
|
|
353
|
+
// the component, the structure Starlight itself queries (':scope > [role="tabpanel"]'). A tab or panel inside a
|
|
354
|
+
// hidden, aria-hidden or otherwise skipped wrapper stays hidden like any other content.
|
|
355
|
+
const shown = (node) => {
|
|
356
|
+
for (let cur = node; cur instanceof Element && cur !== component; cur = cur.parent) {
|
|
357
|
+
if (isSkipped(cur, ctx.root, ctx.profile))
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
return true;
|
|
361
|
+
};
|
|
362
|
+
const own = (node) => ancestor(node, (parent) => parent.name === 'starlight-tabs') === component;
|
|
363
|
+
const tabs = selectAll('[role="tab"]', component).filter((node) => own(node) && shown(node));
|
|
364
|
+
const panels = component.children.filter((node) => node instanceof Element && node.attribs.role === 'tabpanel'
|
|
365
|
+
&& !isSkipped(node, ctx.root, ctx.profile, true));
|
|
366
|
+
if (!tabs.length || tabs.length !== panels.length)
|
|
367
|
+
throw new HtmlExtractError('Starlight tabs need one panel per tab.');
|
|
368
|
+
const panelById = new Map();
|
|
369
|
+
for (const panel of panels) {
|
|
370
|
+
const id = panel.attribs.id;
|
|
371
|
+
if (!id || panelById.has(id))
|
|
372
|
+
throw new HtmlExtractError('Starlight panel identifiers are missing or ambiguous.');
|
|
373
|
+
panelById.set(id, panel);
|
|
374
|
+
}
|
|
375
|
+
const controlNodes = new Set([...tabs, ...panels]);
|
|
376
|
+
// Unknown content beside the tab controls/panels must not disappear from the comparison.
|
|
377
|
+
const validateWrapper = (node) => {
|
|
378
|
+
if (node instanceof Text) {
|
|
379
|
+
if (node.data.trim())
|
|
380
|
+
throw new HtmlExtractError('Unexpected text outside Starlight tab labels and panels.');
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (!(node instanceof Element) || controlNodes.has(node))
|
|
384
|
+
return;
|
|
385
|
+
if (isSkipped(node, ctx.root, ctx.profile))
|
|
386
|
+
return;
|
|
387
|
+
if (node.name === 'iframe')
|
|
388
|
+
throw new HtmlExtractError('Unexpected content outside Starlight tab labels and panels.');
|
|
389
|
+
for (const child of node.children)
|
|
390
|
+
validateWrapper(child);
|
|
391
|
+
};
|
|
392
|
+
for (const child of component.children)
|
|
393
|
+
validateWrapper(child);
|
|
394
|
+
const used = new Set();
|
|
395
|
+
const ids = new Set();
|
|
396
|
+
for (const tab of tabs) {
|
|
397
|
+
const id = tab.attribs.id;
|
|
398
|
+
const target = tab.attribs['aria-controls'] ?? (tab.attribs.href?.startsWith('#') ? tab.attribs.href.slice(1) : undefined);
|
|
399
|
+
if (!id || ids.has(id) || !target)
|
|
400
|
+
throw new HtmlExtractError('Starlight tab identifiers are missing or ambiguous.');
|
|
401
|
+
ids.add(id);
|
|
402
|
+
const panel = panelById.get(target);
|
|
403
|
+
if (!panel || panel.attribs['aria-labelledby'] !== id || used.has(panel))
|
|
404
|
+
throw new HtmlExtractError('Starlight tab/panel association is missing or ambiguous.');
|
|
405
|
+
used.add(panel);
|
|
406
|
+
// Only the associated panel's initial visibility is bypassed. Hidden descendants remain hidden.
|
|
407
|
+
const label = newRun();
|
|
408
|
+
for (const child of tab.children)
|
|
409
|
+
inlineText(ctx, child, label);
|
|
410
|
+
if (!strictNormalize(label.text))
|
|
411
|
+
throw new HtmlExtractError('Starlight tab label is empty.');
|
|
412
|
+
flushRun(ctx, label, tab, 'listItem');
|
|
413
|
+
walk(ctx, panel);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
255
416
|
function handleTable(ctx, table) {
|
|
256
417
|
const rows = selectAll('tr', table).filter((tr) => closestTable(tr) === table);
|
|
257
418
|
const cells = [];
|
|
@@ -315,6 +476,9 @@ function pickRoot(doc, selector, notes) {
|
|
|
315
476
|
throw new HtmlExtractError('Document has no <body> element.');
|
|
316
477
|
}
|
|
317
478
|
export function extractHtml(source, options = {}) {
|
|
479
|
+
const profile = options.profile ?? 'generic';
|
|
480
|
+
if (profile !== 'generic' && profile !== 'starlight')
|
|
481
|
+
throw new HtmlExtractError('Unknown HTML profile.');
|
|
318
482
|
const doc = parseDocument(source, { withStartIndices: true, withEndIndices: true, decodeEntities: true });
|
|
319
483
|
// Before any selector runs: the selector engine and the extraction below both recurse over the tree.
|
|
320
484
|
const maxDepth = options.maxDepth ?? MAX_NESTING_DEPTH;
|
|
@@ -334,7 +498,9 @@ export function extractHtml(source, options = {}) {
|
|
|
334
498
|
for (let i = 0; i < source.length; i++)
|
|
335
499
|
if (source.charCodeAt(i) === 10)
|
|
336
500
|
lineStarts.push(i + 1);
|
|
337
|
-
|
|
501
|
+
if (profile === 'starlight')
|
|
502
|
+
notes.push('Starlight profile: all associated tab panels are compared, including inactive panels; Expressive Code line boundaries and aside titles are retained.');
|
|
503
|
+
const ctx = { profile, base, source, lineStarts, blocks: [], notes, root };
|
|
338
504
|
walk(ctx, root);
|
|
339
|
-
return { blocks: ctx.blocks, strategy
|
|
505
|
+
return { blocks: ctx.blocks, strategy: profile === 'generic' ? strategy : `${strategy};profile:starlight`, confidence, notes, issues: [] };
|
|
340
506
|
}
|
package/dist/src/run.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export interface SourceInput {
|
|
|
24
24
|
base: string | null;
|
|
25
25
|
}
|
|
26
26
|
export interface RunOptions {
|
|
27
|
+
htmlProfile?: 'generic' | 'starlight';
|
|
27
28
|
selector?: string;
|
|
28
29
|
/** Markdown front matter handling; 'keep' by default (nothing removed). */
|
|
29
30
|
frontMatter?: 'keep' | 'strip';
|
package/dist/src/run.js
CHANGED
|
@@ -96,7 +96,7 @@ export function run(html, markdown, options) {
|
|
|
96
96
|
throw new TypeError(`Limit maxNestingDepth must be a positive number (got ${String(maxDepth)}).`);
|
|
97
97
|
let h;
|
|
98
98
|
try {
|
|
99
|
-
h = extractHtml(html.body, { selector: options.selector, baseUrl: html.base, maxDepth });
|
|
99
|
+
h = extractHtml(html.body, { profile: options.htmlProfile, selector: options.selector, baseUrl: html.base, maxDepth });
|
|
100
100
|
}
|
|
101
101
|
catch (err) {
|
|
102
102
|
throw extractionError('HTML', err) ?? err;
|
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.9";
|
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.9';
|
package/package.json
CHANGED