@scalar/code-highlight 0.4.14 → 0.4.16

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.
@@ -1,5 +1,5 @@
1
- import { i as convert, t as visit } from "./lib.js";
2
- //#region \0rolldown/runtime.js
1
+ import { t as visit } from "./lib.js";
2
+ // \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -30,11 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  value: mod,
31
31
  enumerable: true
32
32
  }) : target, mod));
33
- //#endregion
34
- //#region ../../node_modules/.pnpm/devlop@1.1.0/node_modules/devlop/lib/default.js
33
+ // ../../node_modules/.pnpm/devlop@1.1.0/node_modules/devlop/lib/default.js
35
34
  function ok() {}
36
- //#endregion
37
- //#region src/constants.ts
35
+ // src/constants.ts
38
36
  /** Map common markdown language shortcuts to lowlight languages */
39
37
  var lowlightLanguageMappings = {
40
38
  "ts": "typescript",
@@ -45,337 +43,72 @@ var lowlightLanguageMappings = {
45
43
  "c++": "cpp",
46
44
  "node": "javascript"
47
45
  };
48
- //#endregion
49
- //#region ../../node_modules/.pnpm/unist-util-find-after@5.0.0/node_modules/unist-util-find-after/lib/index.js
46
+ // ../../node_modules/.pnpm/hast-util-to-text@4.0.3/node_modules/hast-util-to-text/lib/index.js
50
47
  /**
51
- * @typedef {import('unist').Node} UnistNode
52
- * @typedef {import('unist').Parent} UnistParent
48
+ * @import {Comment, Element, Nodes, Parents, Text} from 'hast'
53
49
  */
54
50
  /**
55
- * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test
56
- * Test from `unist-util-is`.
57
- *
58
- * Note: we have remove and add `undefined`, because otherwise when generating
59
- * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,
60
- * which doesn’t work when publishing on npm.
61
- */
62
- /**
63
- * @typedef {(
64
- * Fn extends (value: any) => value is infer Thing
65
- * ? Thing
66
- * : Fallback
67
- * )} Predicate
68
- * Get the value of a type guard `Fn`.
69
- * @template Fn
70
- * Value; typically function that is a type guard (such as `(x): x is Y`).
71
- * @template Fallback
72
- * Value to yield if `Fn` is not a type guard.
73
- */
74
- /**
75
- * @typedef {(
76
- * Check extends null | undefined // No test.
77
- * ? Value
78
- * : Value extends {type: Check} // String (type) test.
79
- * ? Value
80
- * : Value extends Check // Partial test.
81
- * ? Value
82
- * : Check extends Function // Function test.
83
- * ? Predicate<Check, Value> extends Value
84
- * ? Predicate<Check, Value>
85
- * : never
86
- * : never // Some other test?
87
- * )} MatchesOne
88
- * Check whether a node matches a primitive check in the type system.
89
- * @template Value
90
- * Value; typically unist `Node`.
91
- * @template Check
92
- * Value; typically `unist-util-is`-compatible test, but not arrays.
93
- */
94
- /**
95
- * @typedef {(
96
- * Check extends Array<any>
97
- * ? MatchesOne<Value, Check[keyof Check]>
98
- * : MatchesOne<Value, Check>
99
- * )} Matches
100
- * Check whether a node matches a check in the type system.
101
- * @template Value
102
- * Value; typically unist `Node`.
103
- * @template Check
104
- * Value; typically `unist-util-is`-compatible test.
105
- */
106
- /**
107
- * @typedef {(
108
- * Kind extends {children: Array<infer Child>}
109
- * ? Child
110
- * : never
111
- * )} Child
112
- * Collect nodes that can be parents of `Child`.
113
- * @template {UnistNode} Kind
114
- * All node types.
115
- */
116
- /**
117
- * Find the first node in `parent` after another `node` or after an index,
118
- * that passes `test`.
119
- *
120
- * @param parent
121
- * Parent node.
122
- * @param index
123
- * Child node or index.
124
- * @param [test=undefined]
125
- * Test for child to look for (optional).
126
- * @returns
127
- * A child (matching `test`, if given) or `undefined`.
128
- */
129
- var findAfter = (
130
- /**
131
- * @param {UnistParent} parent
132
- * @param {UnistNode | number} index
133
- * @param {Test} [test]
134
- * @returns {UnistNode | undefined}
135
- */
136
- function(parent, index, test) {
137
- const is = convert(test);
138
- if (!parent || !parent.type || !parent.children) throw new Error("Expected parent node");
139
- if (typeof index === "number") {
140
- if (index < 0 || index === Number.POSITIVE_INFINITY) throw new Error("Expected positive finite number as index");
141
- } else {
142
- index = parent.children.indexOf(index);
143
- if (index < 0) throw new Error("Expected child node or index");
144
- }
145
- while (++index < parent.children.length) if (is(parent.children[index], index, parent)) return parent.children[index];
146
- });
147
- //#endregion
148
- //#region ../../node_modules/.pnpm/hast-util-is-element@3.0.0/node_modules/hast-util-is-element/lib/index.js
149
- /**
150
- * @typedef {import('hast').Element} Element
151
- * @typedef {import('hast').Parents} Parents
152
- */
153
- /**
154
- * @template Fn
155
- * @template Fallback
156
- * @typedef {Fn extends (value: any) => value is infer Thing ? Thing : Fallback} Predicate
157
- */
158
- /**
159
- * @callback Check
160
- * Check that an arbitrary value is an element.
161
- * @param {unknown} this
162
- * Context object (`this`) to call `test` with
163
- * @param {unknown} [element]
164
- * Anything (typically a node).
165
- * @param {number | null | undefined} [index]
166
- * Position of `element` in its parent.
167
- * @param {Parents | null | undefined} [parent]
168
- * Parent of `element`.
169
- * @returns {boolean}
170
- * Whether this is an element and passes a test.
171
- *
172
- * @typedef {Array<TestFunction | string> | TestFunction | string | null | undefined} Test
173
- * Check for an arbitrary element.
174
- *
175
- * * when `string`, checks that the element has that tag name
176
- * * when `function`, see `TestFunction`
177
- * * when `Array`, checks if one of the subtests pass
178
- *
179
- * @callback TestFunction
180
- * Check if an element passes a test.
181
- * @param {unknown} this
182
- * The given context.
183
- * @param {Element} element
184
- * An element.
185
- * @param {number | undefined} [index]
186
- * Position of `element` in its parent.
187
- * @param {Parents | undefined} [parent]
188
- * Parent of `element`.
189
- * @returns {boolean | undefined | void}
190
- * Whether this element passes the test.
191
- *
192
- * Note: `void` is included until TS sees no return as `undefined`.
193
- */
194
- /**
195
- * Check if `element` is an `Element` and whether it passes the given test.
196
- *
197
- * @param element
198
- * Thing to check, typically `element`.
199
- * @param test
200
- * Check for a specific element.
201
- * @param index
202
- * Position of `element` in its parent.
203
- * @param parent
204
- * Parent of `element`.
205
- * @param context
206
- * Context object (`this`) to call `test` with.
207
- * @returns
208
- * Whether `element` is an `Element` and passes a test.
209
- * @throws
210
- * When an incorrect `test`, `index`, or `parent` is given; there is no error
211
- * thrown when `element` is not a node or not an element.
212
- */
213
- var isElement = (
214
- /**
215
- * @param {unknown} [element]
216
- * @param {Test | undefined} [test]
217
- * @param {number | null | undefined} [index]
218
- * @param {Parents | null | undefined} [parent]
219
- * @param {unknown} [context]
220
- * @returns {boolean}
221
- */
222
- function(element, test, index, parent, context) {
223
- const check = convertElement(test);
224
- if (index !== null && index !== void 0 && (typeof index !== "number" || index < 0 || index === Number.POSITIVE_INFINITY)) throw new Error("Expected positive finite `index`");
225
- if (parent !== null && parent !== void 0 && (!parent.type || !parent.children)) throw new Error("Expected valid `parent`");
226
- if ((index === null || index === void 0) !== (parent === null || parent === void 0)) throw new Error("Expected both `index` and `parent`");
227
- return looksLikeAnElement(element) ? check.call(context, element, index, parent) : false;
228
- });
229
- /**
230
- * Generate a check from a test.
231
- *
232
- * Useful if you’re going to test many nodes, for example when creating a
233
- * utility where something else passes a compatible test.
234
- *
235
- * The created function is a bit faster because it expects valid input only:
236
- * an `element`, `index`, and `parent`.
237
- *
238
- * @param test
239
- * A test for a specific element.
240
- * @returns
241
- * A check.
242
- */
243
- var convertElement = (
244
- /**
245
- * @param {Test | null | undefined} [test]
246
- * @returns {Check}
247
- */
248
- function(test) {
249
- if (test === null || test === void 0) return element;
250
- if (typeof test === "string") return tagNameFactory(test);
251
- if (typeof test === "object") return anyFactory(test);
252
- if (typeof test === "function") return castFactory(test);
253
- throw new Error("Expected function, string, or array as `test`");
254
- });
255
- /**
256
- * Handle multiple tests.
257
- *
258
- * @param {Array<TestFunction | string>} tests
259
- * @returns {Check}
260
- */
261
- function anyFactory(tests) {
262
- /** @type {Array<Check>} */
263
- const checks = [];
264
- let index = -1;
265
- while (++index < tests.length) checks[index] = convertElement(tests[index]);
266
- return castFactory(any);
267
- /**
268
- * @this {unknown}
269
- * @type {TestFunction}
270
- */
271
- function any(...parameters) {
272
- let index = -1;
273
- while (++index < checks.length) if (checks[index].apply(this, parameters)) return true;
274
- return false;
275
- }
276
- }
277
- /**
278
- * Turn a string into a test for an element with a certain type.
279
- *
280
- * @param {string} check
281
- * @returns {Check}
282
- */
283
- function tagNameFactory(check) {
284
- return castFactory(tagName);
285
- /**
286
- * @param {Element} element
287
- * @returns {boolean}
288
- */
289
- function tagName(element) {
290
- return element.tagName === check;
291
- }
292
- }
293
- /**
294
- * Turn a custom test into a test for an element that passes that test.
295
- *
296
- * @param {TestFunction} testFunction
297
- * @returns {Check}
298
- */
299
- function castFactory(testFunction) {
300
- return check;
301
- /**
302
- * @this {unknown}
303
- * @type {Check}
304
- */
305
- function check(value, index, parent) {
306
- return Boolean(looksLikeAnElement(value) && testFunction.call(this, value, typeof index === "number" ? index : void 0, parent || void 0));
307
- }
308
- }
309
- /**
310
- * Make sure something is an element.
311
- *
312
- * @param {unknown} element
313
- * @returns {element is Element}
51
+ * @typedef {BreakForce | BreakNumber | BreakValue | undefined} BreakAfter
52
+ * Any value for a break after.
314
53
  */
315
- function element(element) {
316
- return Boolean(element && typeof element === "object" && "type" in element && element.type === "element" && "tagName" in element && typeof element.tagName === "string");
317
- }
318
54
  /**
319
- * @param {unknown} value
320
- * @returns {value is Element}
55
+ * @typedef {BreakNumber | BreakValue | undefined} BreakBefore
56
+ * Any value for a break before.
321
57
  */
322
- function looksLikeAnElement(value) {
323
- return value !== null && typeof value === "object" && "type" in value && "tagName" in value;
324
- }
325
- //#endregion
326
- //#region ../../node_modules/.pnpm/hast-util-to-text@4.0.2/node_modules/hast-util-to-text/lib/index.js
327
58
  /**
328
- * @typedef {import('hast').Comment} Comment
329
- * @typedef {import('hast').Element} Element
330
- * @typedef {import('hast').Nodes} Nodes
331
- * @typedef {import('hast').Parents} Parents
332
- * @typedef {import('hast').Text} Text
333
- * @typedef {import('hast-util-is-element').TestFunction} TestFunction
59
+ * @typedef {'\n'} BreakForce
60
+ * Forced break.
334
61
  */
335
62
  /**
336
- * @typedef {'normal' | 'nowrap' | 'pre' | 'pre-wrap'} Whitespace
337
- * Valid and useful whitespace values (from CSS).
338
- *
339
63
  * @typedef {0 | 1 | 2} BreakNumber
340
64
  * Specific break:
341
65
  *
342
66
  * * `0` — space
343
67
  * * `1` — line ending
344
68
  * * `2` — blank line
345
- *
346
- * @typedef {'\n'} BreakForce
347
- * Forced break.
348
- *
69
+ */
70
+ /**
349
71
  * @typedef {boolean} BreakValue
350
72
  * Whether there was a break.
351
- *
352
- * @typedef {BreakNumber | BreakValue | undefined} BreakBefore
353
- * Any value for a break before.
354
- *
355
- * @typedef {BreakForce | BreakNumber | BreakValue | undefined} BreakAfter
356
- * Any value for a break after.
357
- *
73
+ */
74
+ /**
358
75
  * @typedef CollectionInfo
359
76
  * Info on current collection.
360
77
  * @property {BreakAfter} breakAfter
361
78
  * Whether there was a break after.
362
79
  * @property {BreakBefore} breakBefore
363
80
  * Whether there was a break before.
81
+ * @property {boolean | undefined} [rowAfter]
82
+ * Whether a row comes later in the nearest table, after the current node or
83
+ * after the row group it is in.
364
84
  * @property {Whitespace} whitespace
365
85
  * Current whitespace setting.
366
- *
86
+ */
87
+ /**
367
88
  * @typedef Options
368
89
  * Configuration.
369
90
  * @property {Whitespace | null | undefined} [whitespace='normal']
370
91
  * Initial CSS whitespace setting to use (default: `'normal'`).
371
92
  */
93
+ /**
94
+ * @typedef {'normal' | 'nowrap' | 'pre' | 'pre-wrap'} Whitespace
95
+ * Valid and useful whitespace values (from CSS).
96
+ */
372
97
  var searchLineFeeds = /\n/g;
373
98
  var searchTabOrSpaces = /[\t ]+/g;
374
- var br = convertElement("br");
375
- var cell = convertElement(isCell);
376
- var p = convertElement("p");
377
- var row = convertElement("tr");
378
- var notRendered = convertElement([
99
+ var whitespaceOnly = /^[\t\n\f\r ]+$/;
100
+ var tablePartNames = /* @__PURE__ */ new Set([
101
+ "caption",
102
+ "col",
103
+ "colgroup",
104
+ "tbody",
105
+ "td",
106
+ "tfoot",
107
+ "th",
108
+ "thead",
109
+ "tr"
110
+ ]);
111
+ var notRenderedNames = /* @__PURE__ */ new Set([
379
112
  "datalist",
380
113
  "head",
381
114
  "noembed",
@@ -385,11 +118,9 @@ var notRendered = convertElement([
385
118
  "script",
386
119
  "style",
387
120
  "template",
388
- "title",
389
- hidden,
390
- closedDialog
121
+ "title"
391
122
  ]);
392
- var blockOrCaption = convertElement([
123
+ var blockOrCaptionNames = /* @__PURE__ */ new Set([
393
124
  "address",
394
125
  "article",
395
126
  "aside",
@@ -406,7 +137,7 @@ var blockOrCaption = convertElement([
406
137
  "figure",
407
138
  "figcaption",
408
139
  "footer",
409
- "form,",
140
+ "form",
410
141
  "h1",
411
142
  "h2",
412
143
  "h3",
@@ -467,25 +198,36 @@ var blockOrCaption = convertElement([
467
198
  function toText(tree, options) {
468
199
  const options_ = options || {};
469
200
  const children = "children" in tree ? tree.children : [];
470
- const block = blockOrCaption(tree);
201
+ let block = false;
202
+ let inTable = false;
203
+ if (tree.type === "element") {
204
+ block = blockOrCaptionNames.has(tree.tagName);
205
+ inTable = tree.tagName === "table" || rowGroup(tree);
206
+ }
471
207
  const whitespace = inferWhitespace(tree, {
472
- whitespace: options_.whitespace || "normal",
208
+ breakAfter: false,
473
209
  breakBefore: false,
474
- breakAfter: false
210
+ whitespace: options_.whitespace || "normal"
475
211
  });
476
212
  /** @type {Array<BreakNumber | string>} */
477
213
  const results = [];
478
- if (tree.type === "text" || tree.type === "comment") results.push(...collectText(tree, {
479
- whitespace,
214
+ if (tree.type === "text" || tree.type === "comment") append(results, collectText(tree, {
215
+ breakAfter: true,
480
216
  breakBefore: true,
481
- breakAfter: true
217
+ whitespace
482
218
  }));
483
219
  let index = -1;
484
- while (++index < children.length) results.push(...renderedTextCollection(children[index], tree, {
485
- whitespace,
486
- breakBefore: index ? void 0 : block,
487
- breakAfter: index < children.length - 1 ? br(children[index + 1]) : block
488
- }));
220
+ while (++index < children.length) {
221
+ const next = children[index + 1];
222
+ const breakAfter = next ? next.type === "element" && next.tagName === "br" : block;
223
+ const breakBefore = index ? void 0 : block;
224
+ append(results, renderedTextCollection(children[index], index, tree, {
225
+ breakAfter,
226
+ breakBefore,
227
+ rowAfter: inTable ? inferRowAfter(tree, index, void 0) : void 0,
228
+ whitespace
229
+ }));
230
+ }
489
231
  /** @type {Array<string>} */
490
232
  const result = [];
491
233
  /** @type {number | undefined} */
@@ -507,13 +249,26 @@ function toText(tree, options) {
507
249
  * <https://html.spec.whatwg.org/multipage/dom.html#rendered-text-collection-steps>
508
250
  *
509
251
  * @param {Nodes} node
252
+ * Node.
253
+ * @param {number} index
254
+ * Index of `node` in `parent`.
510
255
  * @param {Parents} parent
256
+ * Parent of `node`.
511
257
  * @param {CollectionInfo} info
258
+ * Info on current collection.
512
259
  * @returns {Array<BreakNumber | string>}
260
+ * Items.
513
261
  */
514
- function renderedTextCollection(node, parent, info) {
515
- if (node.type === "element") return collectElement(node, parent, info);
516
- if (node.type === "text") return info.whitespace === "normal" ? collectText(node, info) : collectPreText(node);
262
+ function renderedTextCollection(node, index, parent, info) {
263
+ if (node.type === "element") return collectElement(node, index, parent, info);
264
+ if (node.type === "text") {
265
+ if (whitespaceOnly.test(node.value) && parent.type === "element" && (parent.tagName === "table" || parent.tagName === "tr" || rowGroup(parent))) {
266
+ const before = parent.children[index - 1];
267
+ const after = parent.children[index + 1];
268
+ if ((!before || before.type === "element" && tablePartNames.has(before.tagName)) && (!after || after.type === "element" && tablePartNames.has(after.tagName))) return [];
269
+ }
270
+ return info.whitespace === "normal" ? collectText(node, info) : collectPreText(node);
271
+ }
517
272
  return [];
518
273
  }
519
274
  /**
@@ -521,37 +276,48 @@ function renderedTextCollection(node, parent, info) {
521
276
  *
522
277
  * @param {Element} node
523
278
  * Element node.
279
+ * @param {number} position
280
+ * Index of `node` in `parent`.
524
281
  * @param {Parents} parent
282
+ * Parent of `node`.
525
283
  * @param {CollectionInfo} info
526
284
  * Info on current collection.
527
285
  * @returns {Array<BreakNumber | string>}
286
+ * Items.
528
287
  */
529
- function collectElement(node, parent, info) {
288
+ function collectElement(node, position, parent, info) {
530
289
  const whitespace = inferWhitespace(node, info);
531
290
  const children = node.children || [];
291
+ const inTable = node.tagName === "table" || rowGroup(node);
532
292
  let index = -1;
533
293
  /** @type {Array<BreakNumber | string>} */
534
- let items = [];
535
- if (notRendered(node)) return items;
294
+ const items = [];
295
+ if (notRenderedNames.has(node.tagName) || node.properties?.hidden || node.tagName === "dialog" && !node.properties?.open) return items;
536
296
  /** @type {BreakNumber | undefined} */
537
297
  let prefix;
538
298
  /** @type {BreakForce | BreakNumber | undefined} */
539
299
  let suffix;
540
- if (br(node)) suffix = "\n";
541
- else if (row(node) && findAfter(parent, node, row)) suffix = "\n";
542
- else if (p(node)) {
300
+ if (node.tagName === "br") suffix = "\n";
301
+ else if (row(node) && (info.rowAfter || after(parent, position, row))) suffix = "\n";
302
+ else if (node.tagName === "p") {
543
303
  prefix = 2;
544
304
  suffix = 2;
545
- } else if (blockOrCaption(node)) {
305
+ } else if (blockOrCaptionNames.has(node.tagName)) {
546
306
  prefix = 1;
547
307
  suffix = 1;
548
308
  }
549
- while (++index < children.length) items = items.concat(renderedTextCollection(children[index], node, {
550
- whitespace,
551
- breakBefore: index ? void 0 : prefix,
552
- breakAfter: index < children.length - 1 ? br(children[index + 1]) : suffix
553
- }));
554
- if (cell(node) && findAfter(parent, node, cell)) items.push(" ");
309
+ while (++index < children.length) {
310
+ const next = children[index + 1];
311
+ const breakAfter = next ? next.type === "element" && next.tagName === "br" : suffix;
312
+ const breakBefore = index ? void 0 : prefix;
313
+ append(items, renderedTextCollection(children[index], index, node, {
314
+ breakAfter,
315
+ breakBefore,
316
+ rowAfter: inTable ? inferRowAfter(node, index, info.rowAfter) : void 0,
317
+ whitespace
318
+ }));
319
+ }
320
+ if (cell(node) && after(parent, position, cell)) items.push(" ");
555
321
  if (prefix) items.unshift(prefix);
556
322
  if (suffix) items.push(suffix);
557
323
  return items;
@@ -665,42 +431,119 @@ function trimAndCollapseSpacesAndTabs(value, breakBefore, breakAfter) {
665
431
  * Applied whitespace.
666
432
  */
667
433
  function inferWhitespace(node, info) {
668
- if (node.type === "element") {
669
- const properties = node.properties || {};
670
- switch (node.tagName) {
671
- case "listing":
672
- case "plaintext":
673
- case "xmp": return "pre";
674
- case "nobr": return "nowrap";
675
- case "pre": return properties.wrap ? "pre-wrap" : "pre";
676
- case "td":
677
- case "th": return properties.noWrap ? "nowrap" : info.whitespace;
678
- case "textarea": return "pre-wrap";
679
- }
434
+ if (node.type === "element") switch (node.tagName) {
435
+ case "listing":
436
+ case "plaintext":
437
+ case "xmp": return "pre";
438
+ case "nobr": return "nowrap";
439
+ case "pre": return node.properties?.wrap ? "pre-wrap" : "pre";
440
+ case "td":
441
+ case "th": return node.properties?.noWrap ? "nowrap" : info.whitespace;
442
+ case "textarea": return "pre-wrap";
680
443
  }
681
444
  return info.whitespace;
682
445
  }
683
446
  /**
684
- * @type {TestFunction}
685
- * @param {Element} node
686
- * @returns {node is {properties: {hidden: true}}}
447
+ * Check if a row comes later in a table.
448
+ *
449
+ * @param {Nodes} parent
450
+ * Table or row group.
451
+ * @param {number} index
452
+ * Index of child in `parent`.
453
+ * @param {boolean | undefined} rowAfter
454
+ * Whether a row comes after `parent`, if it is a row group.
455
+ * @returns {boolean | undefined}
456
+ * Whether a row comes after the child in the nearest table.
457
+ */
458
+ function inferRowAfter(parent, index, rowAfter) {
459
+ return parent.type === "element" && parent.tagName === "table" ? after(parent, index, rowOrRowGroupWithRow) : rowAfter;
460
+ }
461
+ /**
462
+ * Check if an element after `index` in `parent` passes `test`.
463
+ *
464
+ * @param {Parents} parent
465
+ * Parent.
466
+ * @param {number} index
467
+ * Index of a child in `parent`; elements after it are checked.
468
+ * @param {(node: Element) => boolean} test
469
+ * Check.
470
+ * @returns {boolean}
471
+ * Whether an element after `index` passes `test`.
687
472
  */
688
- function hidden(node) {
689
- return Boolean((node.properties || {}).hidden);
473
+ function after(parent, index, test) {
474
+ while (++index < parent.children.length) {
475
+ const child = parent.children[index];
476
+ if (child.type === "element" && test(child)) return true;
477
+ }
478
+ return false;
690
479
  }
691
480
  /**
692
- * @type {TestFunction}
481
+ * Append items to a list; without `...spread` which overflows.
482
+ *
483
+ * @template Kind
484
+ * Item.
485
+ * @param {Array<Kind>} list
486
+ * List to append to.
487
+ * @param {Array<Kind>} items
488
+ * Items to append.
489
+ * @returns {undefined}
490
+ * Nothing.
491
+ */
492
+ function append(list, items) {
493
+ let index = -1;
494
+ while (++index < items.length) list.push(items[index]);
495
+ }
496
+ /**
497
+ * Check if an element is a cell.
498
+ *
693
499
  * @param {Element} node
694
- * @returns {node is {tagName: 'td' | 'th'}}
500
+ * Element.
501
+ * @returns {boolean}
502
+ * Whether `node` is a cell.
695
503
  */
696
- function isCell(node) {
504
+ function cell(node) {
697
505
  return node.tagName === "td" || node.tagName === "th";
698
506
  }
699
507
  /**
700
- * @type {TestFunction}
508
+ * Check if an element is a row group; hot path so a basic regular function.
509
+ *
510
+ * @param {Element} node
511
+ * Element.
512
+ * @returns {boolean}
513
+ * Whether `node` is a row group.
514
+ */
515
+ function rowGroup(node) {
516
+ return node.tagName === "tbody" || node.tagName === "tfoot" || node.tagName === "thead";
517
+ }
518
+ /**
519
+ * Check if an element is a row, or a row group with a row.
520
+ *
521
+ * @param {Element} node
522
+ * Element.
523
+ * @returns {boolean}
524
+ * Whether `node` is a row or a row group with a row.
525
+ */
526
+ function rowOrRowGroupWithRow(node) {
527
+ if (row(node)) return true;
528
+ if (rowGroup(node)) {
529
+ let index = -1;
530
+ while (++index < node.children.length) {
531
+ const child = node.children[index];
532
+ if (child.type === "element" && row(child)) return true;
533
+ }
534
+ }
535
+ return false;
536
+ }
537
+ /**
538
+ * Check if an element is a row.
539
+ *
540
+ * @param {Element} node
541
+ * Element.
542
+ * @returns {boolean}
543
+ * Whether `node` is a row.
701
544
  */
702
- function closedDialog(node) {
703
- return node.tagName === "dialog" && !(node.properties || {}).open;
545
+ function row(node) {
546
+ return node.tagName === "tr";
704
547
  }
705
548
  var core_default = (/* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
706
549
  function deepFreeze(obj) {
@@ -2534,8 +2377,7 @@ var core_default = (/* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
2534
2377
  highlight.HighlightJS = highlight;
2535
2378
  highlight.default = highlight;
2536
2379
  })))())).default;
2537
- //#endregion
2538
- //#region ../../node_modules/.pnpm/lowlight@3.3.0/node_modules/lowlight/lib/index.js
2380
+ // ../../node_modules/.pnpm/lowlight@3.3.0/node_modules/lowlight/lib/index.js
2539
2381
  /**
2540
2382
  * @import {ElementContent, Element, RootData, Root} from 'hast'
2541
2383
  * @import {Emitter, HLJSOptions as HljsOptions, HighlightResult, LanguageFn} from 'highlight.js'
@@ -2936,8 +2778,7 @@ var HastEmitter = class {
2936
2778
  return "";
2937
2779
  }
2938
2780
  };
2939
- //#endregion
2940
- //#region src/rehype-highlight/rehype-highlight.ts
2781
+ // src/rehype-highlight/rehype-highlight.ts
2941
2782
  var emptyOptions = {};
2942
2783
  /**
2943
2784
  * Lowlight syntax highlighting plugin for rehype pipelines
@@ -3015,7 +2856,6 @@ function language(node) {
3015
2856
  }, "");
3016
2857
  return lowlightLanguageMappings[name || ""] || name;
3017
2858
  }
3018
- //#endregion
3019
- export { lowlightLanguageMappings as a, __exportAll as c, isElement as i, __toESM as l, createLowlight as n, ok as o, convertElement as r, __commonJSMin as s, rehypeHighlight as t };
2859
+ export { __commonJSMin as a, ok as i, createLowlight as n, __exportAll as o, lowlightLanguageMappings as r, __toESM as s, rehypeHighlight as t };
3020
2860
 
3021
2861
  //# sourceMappingURL=rehype-highlight.js.map