@duskmoon-dev/el-markdown-input 1.10.2 → 1.10.3

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.
@@ -2196,7 +2196,7 @@ function parse2(value) {
2196
2196
  return input ? input.split(/[ \t\n\r\f]+/g) : [];
2197
2197
  }
2198
2198
 
2199
- // ../../node_modules/.bun/hastscript@9.0.1/node_modules/hastscript/lib/create-h.js
2199
+ // ../../node_modules/.bun/hastscript@9.0.3/node_modules/hastscript/lib/create-h.js
2200
2200
  function createH(schema, defaultTagName, caseSensitive) {
2201
2201
  const adjust = caseSensitive ? createAdjustMap(caseSensitive) : undefined;
2202
2202
  function h(selector, properties, ...children) {
@@ -2221,7 +2221,7 @@ function createH(schema, defaultTagName, caseSensitive) {
2221
2221
  for (const child of children) {
2222
2222
  addChild(node.children, child);
2223
2223
  }
2224
- if (node.type === "element" && node.tagName === "template") {
2224
+ if (node.type === "element" && node.tagName === "template" && schema.space === "html") {
2225
2225
  node.content = { type: "root", children: node.children };
2226
2226
  node.children = [];
2227
2227
  }
@@ -2256,10 +2256,10 @@ function isChild(value) {
2256
2256
  return false;
2257
2257
  }
2258
2258
  function addProperty(schema, properties, key, value) {
2259
- const info = find(schema, key);
2260
- let result;
2261
2259
  if (value === null || value === undefined)
2262
2260
  return;
2261
+ const info = find(schema, key);
2262
+ let result;
2263
2263
  if (typeof value === "number") {
2264
2264
  if (Number.isNaN(value))
2265
2265
  return;
@@ -2289,7 +2289,8 @@ function addProperty(schema, properties, key, value) {
2289
2289
  result = finalResult;
2290
2290
  }
2291
2291
  if (info.property === "className" && Array.isArray(properties.className)) {
2292
- result = properties.className.concat(result);
2292
+ const add = result;
2293
+ result = [...properties.className, ...Array.isArray(add) ? add : [add]];
2293
2294
  }
2294
2295
  properties[info.property] = result;
2295
2296
  }
@@ -2340,7 +2341,7 @@ var init_create_h = __esm(() => {
2340
2341
  init_property_information();
2341
2342
  });
2342
2343
 
2343
- // ../../node_modules/.bun/hastscript@9.0.1/node_modules/hastscript/lib/svg-case-sensitive-tag-names.js
2344
+ // ../../node_modules/.bun/hastscript@9.0.3/node_modules/hastscript/lib/svg-case-sensitive-tag-names.js
2344
2345
  var svgCaseSensitiveTagNames;
2345
2346
  var init_svg_case_sensitive_tag_names = __esm(() => {
2346
2347
  svgCaseSensitiveTagNames = [
@@ -2386,7 +2387,7 @@ var init_svg_case_sensitive_tag_names = __esm(() => {
2386
2387
  ];
2387
2388
  });
2388
2389
 
2389
- // ../../node_modules/.bun/hastscript@9.0.1/node_modules/hastscript/lib/index.js
2390
+ // ../../node_modules/.bun/hastscript@9.0.3/node_modules/hastscript/lib/index.js
2390
2391
  var h, s;
2391
2392
  var init_lib4 = __esm(() => {
2392
2393
  init_property_information();
@@ -2396,7 +2397,7 @@ var init_lib4 = __esm(() => {
2396
2397
  s = createH(svg2, "g", svgCaseSensitiveTagNames);
2397
2398
  });
2398
2399
 
2399
- // ../../node_modules/.bun/hastscript@9.0.1/node_modules/hastscript/index.js
2400
+ // ../../node_modules/.bun/hastscript@9.0.3/node_modules/hastscript/index.js
2400
2401
  var init_hastscript = __esm(() => {
2401
2402
  init_lib4();
2402
2403
  });
@@ -2517,183 +2518,39 @@ var init_browser = __esm(() => {
2517
2518
  parser = new DOMParser;
2518
2519
  });
2519
2520
 
2520
- // ../../node_modules/.bun/unist-util-is@6.0.1/node_modules/unist-util-is/lib/index.js
2521
- function anyFactory(tests) {
2522
- const checks = [];
2523
- let index = -1;
2524
- while (++index < tests.length) {
2525
- checks[index] = convert(tests[index]);
2526
- }
2527
- return castFactory(any);
2528
- function any(...parameters) {
2529
- let index = -1;
2530
- while (++index < checks.length) {
2531
- if (checks[index].apply(this, parameters))
2532
- return true;
2533
- }
2534
- return false;
2535
- }
2536
- }
2537
- function propertiesFactory(check) {
2538
- const checkAsRecord = check;
2539
- return castFactory(all);
2540
- function all(node) {
2541
- const nodeAsRecord = node;
2542
- let key;
2543
- for (key in check) {
2544
- if (nodeAsRecord[key] !== checkAsRecord[key])
2545
- return false;
2546
- }
2547
- return true;
2548
- }
2549
- }
2550
- function typeFactory(check) {
2551
- return castFactory(type);
2552
- function type(node) {
2553
- return node && node.type === check;
2554
- }
2555
- }
2556
- function castFactory(testFunction) {
2557
- return check;
2558
- function check(value, index, parent) {
2559
- return Boolean(looksLikeANode(value) && testFunction.call(this, value, typeof index === "number" ? index : undefined, parent || undefined));
2560
- }
2561
- }
2562
- function ok2() {
2563
- return true;
2564
- }
2565
- function looksLikeANode(value) {
2566
- return value !== null && typeof value === "object" && "type" in value;
2567
- }
2568
- var convert = function(test) {
2569
- if (test === null || test === undefined) {
2570
- return ok2;
2571
- }
2572
- if (typeof test === "function") {
2573
- return castFactory(test);
2574
- }
2575
- if (typeof test === "object") {
2576
- return Array.isArray(test) ? anyFactory(test) : propertiesFactory(test);
2577
- }
2578
- if (typeof test === "string") {
2579
- return typeFactory(test);
2580
- }
2581
- throw new Error("Expected function, string, or object as test");
2582
- };
2583
-
2584
- // ../../node_modules/.bun/unist-util-is@6.0.1/node_modules/unist-util-is/index.js
2585
- var init_unist_util_is = () => {};
2586
-
2587
- // ../../node_modules/.bun/unist-util-find-after@5.0.0/node_modules/unist-util-find-after/lib/index.js
2588
- var findAfter = function(parent, index, test) {
2589
- const is = convert(test);
2590
- if (!parent || !parent.type || !parent.children) {
2591
- throw new Error("Expected parent node");
2592
- }
2593
- if (typeof index === "number") {
2594
- if (index < 0 || index === Number.POSITIVE_INFINITY) {
2595
- throw new Error("Expected positive finite number as index");
2596
- }
2597
- } else {
2598
- index = parent.children.indexOf(index);
2599
- if (index < 0) {
2600
- throw new Error("Expected child node or index");
2601
- }
2602
- }
2603
- while (++index < parent.children.length) {
2604
- if (is(parent.children[index], index, parent)) {
2605
- return parent.children[index];
2606
- }
2607
- }
2608
- return;
2609
- };
2610
- var init_lib6 = __esm(() => {
2611
- init_unist_util_is();
2612
- });
2613
-
2614
- // ../../node_modules/.bun/unist-util-find-after@5.0.0/node_modules/unist-util-find-after/index.js
2615
- var init_unist_util_find_after = __esm(() => {
2616
- init_lib6();
2617
- });
2618
-
2619
- // ../../node_modules/.bun/hast-util-is-element@3.0.0/node_modules/hast-util-is-element/lib/index.js
2620
- function anyFactory2(tests) {
2621
- const checks = [];
2622
- let index = -1;
2623
- while (++index < tests.length) {
2624
- checks[index] = convertElement(tests[index]);
2625
- }
2626
- return castFactory2(any);
2627
- function any(...parameters) {
2628
- let index = -1;
2629
- while (++index < checks.length) {
2630
- if (checks[index].apply(this, parameters))
2631
- return true;
2632
- }
2633
- return false;
2634
- }
2635
- }
2636
- function tagNameFactory(check) {
2637
- return castFactory2(tagName);
2638
- function tagName(element) {
2639
- return element.tagName === check;
2640
- }
2641
- }
2642
- function castFactory2(testFunction) {
2643
- return check;
2644
- function check(value, index, parent) {
2645
- return Boolean(looksLikeAnElement(value) && testFunction.call(this, value, typeof index === "number" ? index : undefined, parent || undefined));
2646
- }
2647
- }
2648
- function element2(element) {
2649
- return Boolean(element && typeof element === "object" && "type" in element && element.type === "element" && "tagName" in element && typeof element.tagName === "string");
2650
- }
2651
- function looksLikeAnElement(value) {
2652
- return value !== null && typeof value === "object" && "type" in value && "tagName" in value;
2653
- }
2654
- var convertElement = function(test) {
2655
- if (test === null || test === undefined) {
2656
- return element2;
2657
- }
2658
- if (typeof test === "string") {
2659
- return tagNameFactory(test);
2660
- }
2661
- if (typeof test === "object") {
2662
- return anyFactory2(test);
2663
- }
2664
- if (typeof test === "function") {
2665
- return castFactory2(test);
2666
- }
2667
- throw new Error("Expected function, string, or array as `test`");
2668
- };
2669
-
2670
- // ../../node_modules/.bun/hast-util-is-element@3.0.0/node_modules/hast-util-is-element/index.js
2671
- var init_hast_util_is_element = () => {};
2672
-
2673
- // ../../node_modules/.bun/hast-util-to-text@4.0.2/node_modules/hast-util-to-text/lib/index.js
2521
+ // ../../node_modules/.bun/hast-util-to-text@4.0.3/node_modules/hast-util-to-text/lib/index.js
2674
2522
  function toText(tree, options) {
2675
2523
  const options_ = options || {};
2676
2524
  const children = "children" in tree ? tree.children : [];
2677
- const block = blockOrCaption(tree);
2525
+ let block = false;
2526
+ let inTable = false;
2527
+ if (tree.type === "element") {
2528
+ block = blockOrCaptionNames.has(tree.tagName);
2529
+ inTable = tree.tagName === "table" || rowGroup(tree);
2530
+ }
2678
2531
  const whitespace = inferWhitespace(tree, {
2679
- whitespace: options_.whitespace || "normal",
2532
+ breakAfter: false,
2680
2533
  breakBefore: false,
2681
- breakAfter: false
2534
+ whitespace: options_.whitespace || "normal"
2682
2535
  });
2683
2536
  const results = [];
2684
2537
  if (tree.type === "text" || tree.type === "comment") {
2685
- results.push(...collectText(tree, {
2686
- whitespace,
2538
+ append(results, collectText(tree, {
2539
+ breakAfter: true,
2687
2540
  breakBefore: true,
2688
- breakAfter: true
2541
+ whitespace
2689
2542
  }));
2690
2543
  }
2691
2544
  let index = -1;
2692
2545
  while (++index < children.length) {
2693
- results.push(...renderedTextCollection(children[index], tree, {
2694
- whitespace,
2695
- breakBefore: index ? undefined : block,
2696
- breakAfter: index < children.length - 1 ? br(children[index + 1]) : block
2546
+ const next = children[index + 1];
2547
+ const breakAfter = next ? next.type === "element" && next.tagName === "br" : block;
2548
+ const breakBefore = index ? undefined : block;
2549
+ append(results, renderedTextCollection(children[index], index, tree, {
2550
+ breakAfter,
2551
+ breakBefore,
2552
+ rowAfter: inTable ? inferRowAfter(tree, index, undefined) : undefined,
2553
+ whitespace
2697
2554
  }));
2698
2555
  }
2699
2556
  const result = [];
@@ -2715,46 +2572,58 @@ function toText(tree, options) {
2715
2572
  }
2716
2573
  return result.join("");
2717
2574
  }
2718
- function renderedTextCollection(node, parent, info) {
2575
+ function renderedTextCollection(node, index, parent, info) {
2719
2576
  if (node.type === "element") {
2720
- return collectElement(node, parent, info);
2577
+ return collectElement(node, index, parent, info);
2721
2578
  }
2722
2579
  if (node.type === "text") {
2580
+ if (whitespaceOnly.test(node.value) && parent.type === "element" && (parent.tagName === "table" || parent.tagName === "tr" || rowGroup(parent))) {
2581
+ const before = parent.children[index - 1];
2582
+ const after = parent.children[index + 1];
2583
+ if ((!before || before.type === "element" && tablePartNames.has(before.tagName)) && (!after || after.type === "element" && tablePartNames.has(after.tagName))) {
2584
+ return [];
2585
+ }
2586
+ }
2723
2587
  return info.whitespace === "normal" ? collectText(node, info) : collectPreText(node);
2724
2588
  }
2725
2589
  return [];
2726
2590
  }
2727
- function collectElement(node, parent, info) {
2591
+ function collectElement(node, position, parent, info) {
2728
2592
  const whitespace = inferWhitespace(node, info);
2729
2593
  const children = node.children || [];
2594
+ const inTable = node.tagName === "table" || rowGroup(node);
2730
2595
  let index = -1;
2731
- let items = [];
2732
- if (notRendered(node)) {
2596
+ const items = [];
2597
+ if (notRenderedNames.has(node.tagName) || node.properties?.hidden || node.tagName === "dialog" && !node.properties?.open) {
2733
2598
  return items;
2734
2599
  }
2735
2600
  let prefix;
2736
2601
  let suffix;
2737
- if (br(node)) {
2602
+ if (node.tagName === "br") {
2738
2603
  suffix = `
2739
2604
  `;
2740
- } else if (row(node) && findAfter(parent, node, row)) {
2605
+ } else if (row(node) && (info.rowAfter || after(parent, position, row))) {
2741
2606
  suffix = `
2742
2607
  `;
2743
- } else if (p(node)) {
2608
+ } else if (node.tagName === "p") {
2744
2609
  prefix = 2;
2745
2610
  suffix = 2;
2746
- } else if (blockOrCaption(node)) {
2611
+ } else if (blockOrCaptionNames.has(node.tagName)) {
2747
2612
  prefix = 1;
2748
2613
  suffix = 1;
2749
2614
  }
2750
2615
  while (++index < children.length) {
2751
- items = items.concat(renderedTextCollection(children[index], node, {
2752
- whitespace,
2753
- breakBefore: index ? undefined : prefix,
2754
- breakAfter: index < children.length - 1 ? br(children[index + 1]) : suffix
2616
+ const next = children[index + 1];
2617
+ const breakAfter = next ? next.type === "element" && next.tagName === "br" : suffix;
2618
+ const breakBefore = index ? undefined : prefix;
2619
+ append(items, renderedTextCollection(children[index], index, node, {
2620
+ breakAfter,
2621
+ breakBefore,
2622
+ rowAfter: inTable ? inferRowAfter(node, index, info.rowAfter) : undefined,
2623
+ whitespace
2755
2624
  }));
2756
2625
  }
2757
- if (cell(node) && findAfter(parent, node, cell)) {
2626
+ if (cell(node) && after(parent, position, cell)) {
2758
2627
  items.push("\t");
2759
2628
  }
2760
2629
  if (prefix)
@@ -2818,7 +2687,6 @@ function trimAndCollapseSpacesAndTabs(value, breakBefore, breakAfter) {
2818
2687
  }
2819
2688
  function inferWhitespace(node, info) {
2820
2689
  if (node.type === "element") {
2821
- const properties = node.properties || {};
2822
2690
  switch (node.tagName) {
2823
2691
  case "listing":
2824
2692
  case "plaintext":
@@ -2829,11 +2697,11 @@ function inferWhitespace(node, info) {
2829
2697
  return "nowrap";
2830
2698
  }
2831
2699
  case "pre": {
2832
- return properties.wrap ? "pre-wrap" : "pre";
2700
+ return node.properties?.wrap ? "pre-wrap" : "pre";
2833
2701
  }
2834
2702
  case "td":
2835
2703
  case "th": {
2836
- return properties.noWrap ? "nowrap" : info.whitespace;
2704
+ return node.properties?.noWrap ? "nowrap" : info.whitespace;
2837
2705
  }
2838
2706
  case "textarea": {
2839
2707
  return "pre-wrap";
@@ -2843,26 +2711,62 @@ function inferWhitespace(node, info) {
2843
2711
  }
2844
2712
  return info.whitespace;
2845
2713
  }
2846
- function hidden(node) {
2847
- return Boolean((node.properties || {}).hidden);
2714
+ function inferRowAfter(parent, index, rowAfter) {
2715
+ return parent.type === "element" && parent.tagName === "table" ? after(parent, index, rowOrRowGroupWithRow) : rowAfter;
2848
2716
  }
2849
- function isCell(node) {
2717
+ function after(parent, index, test) {
2718
+ while (++index < parent.children.length) {
2719
+ const child = parent.children[index];
2720
+ if (child.type === "element" && test(child))
2721
+ return true;
2722
+ }
2723
+ return false;
2724
+ }
2725
+ function append(list, items) {
2726
+ let index = -1;
2727
+ while (++index < items.length) {
2728
+ list.push(items[index]);
2729
+ }
2730
+ }
2731
+ function cell(node) {
2850
2732
  return node.tagName === "td" || node.tagName === "th";
2851
2733
  }
2852
- function closedDialog(node) {
2853
- return node.tagName === "dialog" && !(node.properties || {}).open;
2734
+ function rowGroup(node) {
2735
+ return node.tagName === "tbody" || node.tagName === "tfoot" || node.tagName === "thead";
2854
2736
  }
2855
- var searchLineFeeds, searchTabOrSpaces, br, cell, p, row, notRendered, blockOrCaption;
2856
- var init_lib7 = __esm(() => {
2857
- init_unist_util_find_after();
2858
- init_hast_util_is_element();
2737
+ function rowOrRowGroupWithRow(node) {
2738
+ if (row(node))
2739
+ return true;
2740
+ if (rowGroup(node)) {
2741
+ let index = -1;
2742
+ while (++index < node.children.length) {
2743
+ const child = node.children[index];
2744
+ if (child.type === "element" && row(child))
2745
+ return true;
2746
+ }
2747
+ }
2748
+ return false;
2749
+ }
2750
+ function row(node) {
2751
+ return node.tagName === "tr";
2752
+ }
2753
+ var searchLineFeeds, searchTabOrSpaces, whitespaceOnly, tablePartNames, notRenderedNames, blockOrCaptionNames;
2754
+ var init_lib6 = __esm(() => {
2859
2755
  searchLineFeeds = /\n/g;
2860
2756
  searchTabOrSpaces = /[\t ]+/g;
2861
- br = convertElement("br");
2862
- cell = convertElement(isCell);
2863
- p = convertElement("p");
2864
- row = convertElement("tr");
2865
- notRendered = convertElement([
2757
+ whitespaceOnly = /^[\t\n\f\r ]+$/;
2758
+ tablePartNames = new Set([
2759
+ "caption",
2760
+ "col",
2761
+ "colgroup",
2762
+ "tbody",
2763
+ "td",
2764
+ "tfoot",
2765
+ "th",
2766
+ "thead",
2767
+ "tr"
2768
+ ]);
2769
+ notRenderedNames = new Set([
2866
2770
  "datalist",
2867
2771
  "head",
2868
2772
  "noembed",
@@ -2872,11 +2776,9 @@ var init_lib7 = __esm(() => {
2872
2776
  "script",
2873
2777
  "style",
2874
2778
  "template",
2875
- "title",
2876
- hidden,
2877
- closedDialog
2779
+ "title"
2878
2780
  ]);
2879
- blockOrCaption = convertElement([
2781
+ blockOrCaptionNames = new Set([
2880
2782
  "address",
2881
2783
  "article",
2882
2784
  "aside",
@@ -2893,7 +2795,7 @@ var init_lib7 = __esm(() => {
2893
2795
  "figure",
2894
2796
  "figcaption",
2895
2797
  "footer",
2896
- "form,",
2798
+ "form",
2897
2799
  "h1",
2898
2800
  "h2",
2899
2801
  "h3",
@@ -2920,27 +2822,121 @@ var init_lib7 = __esm(() => {
2920
2822
  ]);
2921
2823
  });
2922
2824
 
2923
- // ../../node_modules/.bun/hast-util-to-text@4.0.2/node_modules/hast-util-to-text/index.js
2825
+ // ../../node_modules/.bun/hast-util-to-text@4.0.3/node_modules/hast-util-to-text/index.js
2924
2826
  var init_hast_util_to_text = __esm(() => {
2925
- init_lib7();
2827
+ init_lib6();
2926
2828
  });
2927
2829
 
2928
- // ../../node_modules/.bun/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/color.js
2830
+ // ../../node_modules/.bun/unist-util-is@6.0.1/node_modules/unist-util-is/lib/index.js
2831
+ function anyFactory(tests) {
2832
+ const checks = [];
2833
+ let index = -1;
2834
+ while (++index < tests.length) {
2835
+ checks[index] = convert(tests[index]);
2836
+ }
2837
+ return castFactory(any);
2838
+ function any(...parameters) {
2839
+ let index = -1;
2840
+ while (++index < checks.length) {
2841
+ if (checks[index].apply(this, parameters))
2842
+ return true;
2843
+ }
2844
+ return false;
2845
+ }
2846
+ }
2847
+ function propertiesFactory(check) {
2848
+ const checkAsRecord = check;
2849
+ return castFactory(all);
2850
+ function all(node) {
2851
+ const nodeAsRecord = node;
2852
+ let key;
2853
+ for (key in check) {
2854
+ if (nodeAsRecord[key] !== checkAsRecord[key])
2855
+ return false;
2856
+ }
2857
+ return true;
2858
+ }
2859
+ }
2860
+ function typeFactory(check) {
2861
+ return castFactory(type);
2862
+ function type(node) {
2863
+ return node && node.type === check;
2864
+ }
2865
+ }
2866
+ function castFactory(testFunction) {
2867
+ return check;
2868
+ function check(value, index, parent) {
2869
+ return Boolean(looksLikeANode(value) && testFunction.call(this, value, typeof index === "number" ? index : undefined, parent || undefined));
2870
+ }
2871
+ }
2872
+ function ok2() {
2873
+ return true;
2874
+ }
2875
+ function looksLikeANode(value) {
2876
+ return value !== null && typeof value === "object" && "type" in value;
2877
+ }
2878
+ var convert = function(test) {
2879
+ if (test === null || test === undefined) {
2880
+ return ok2;
2881
+ }
2882
+ if (typeof test === "function") {
2883
+ return castFactory(test);
2884
+ }
2885
+ if (typeof test === "object") {
2886
+ return Array.isArray(test) ? anyFactory(test) : propertiesFactory(test);
2887
+ }
2888
+ if (typeof test === "string") {
2889
+ return typeFactory(test);
2890
+ }
2891
+ throw new Error("Expected function, string, or object as test");
2892
+ };
2893
+
2894
+ // ../../node_modules/.bun/unist-util-is@6.0.1/node_modules/unist-util-is/index.js
2895
+ var init_unist_util_is = () => {};
2896
+
2897
+ // ../../node_modules/.bun/unist-util-visit-parents@6.1.0/node_modules/unist-util-visit-parents/lib/color.js
2929
2898
  function color(d) {
2930
2899
  return d;
2931
2900
  }
2932
2901
 
2933
- // ../../node_modules/.bun/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/index.js
2934
- function visitParents(tree, test, visitor, reverse) {
2902
+ // ../../node_modules/.bun/unist-util-visit-parents@6.1.0/node_modules/unist-util-visit-parents/lib/index.js
2903
+ function visitParents(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, reverse) {
2904
+ if (!tree || typeof tree !== "object") {
2905
+ throw new Error("Unexpected value `" + tree + "` for `tree`, expected node");
2906
+ }
2907
+ let preorder = true;
2935
2908
  let check;
2936
- if (typeof test === "function" && typeof visitor !== "function") {
2937
- reverse = visitor;
2938
- visitor = test;
2909
+ let visitors;
2910
+ let enter;
2911
+ let exit;
2912
+ if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
2913
+ check = testOrEnterOrVisitors;
2914
+ visitors = enterOrVisitorsOrReverse;
2915
+ if (reverse)
2916
+ preorder = false;
2939
2917
  } else {
2940
- check = test;
2918
+ visitors = testOrEnterOrVisitors;
2919
+ if (enterOrVisitorsOrReverse)
2920
+ preorder = false;
2921
+ }
2922
+ if (typeof visitors === "function") {
2923
+ enter = visitors;
2924
+ } else if (visitors && typeof visitors === "object") {
2925
+ if (visitors.enter === null || visitors.enter === undefined) {} else if (typeof visitors.enter === "function") {
2926
+ enter = visitors.enter;
2927
+ } else {
2928
+ throw new Error("Unexpected value `" + visitors.enter + "` for `visitors.enter`, expected optional visitor");
2929
+ }
2930
+ if (typeof visitors.exit === "function") {
2931
+ exit = visitors.exit;
2932
+ } else {
2933
+ throw new Error("Unexpected value `" + visitors.exit + "` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)");
2934
+ }
2935
+ } else {
2936
+ throw new Error("Unexpected value `" + visitors + "` for `enter` or `visitors`, expected visitor or object with visitors");
2941
2937
  }
2942
2938
  const is = convert(check);
2943
- const step = reverse ? -1 : 1;
2939
+ const step = preorder ? 1 : -1;
2944
2940
  factory(tree, undefined, [])();
2945
2941
  function factory(node, index, parents) {
2946
2942
  const value = node && typeof node === "object" ? node : {};
@@ -2952,12 +2948,10 @@ function visitParents(tree, test, visitor, reverse) {
2952
2948
  }
2953
2949
  return visit;
2954
2950
  function visit() {
2951
+ const matches = !check || is(node, index, parents[parents.length - 1] || undefined);
2955
2952
  let result = empty;
2956
- let subresult;
2957
- let offset;
2958
- let grandparents;
2959
- if (!test || is(node, index, parents[parents.length - 1] || undefined)) {
2960
- result = toResult(visitor(node, parents));
2953
+ if (enter && matches) {
2954
+ result = toResult(enter(node, parents, index));
2961
2955
  if (result[0] === EXIT) {
2962
2956
  return result;
2963
2957
  }
@@ -2965,11 +2959,11 @@ function visitParents(tree, test, visitor, reverse) {
2965
2959
  if ("children" in node && node.children) {
2966
2960
  const nodeAsParent = node;
2967
2961
  if (nodeAsParent.children && result[0] !== SKIP) {
2968
- offset = (reverse ? nodeAsParent.children.length : -1) + step;
2969
- grandparents = parents.concat(nodeAsParent);
2962
+ let offset = (preorder ? -1 : nodeAsParent.children.length) + step;
2963
+ const grandparents = [...parents, nodeAsParent];
2970
2964
  while (offset > -1 && offset < nodeAsParent.children.length) {
2971
2965
  const child = nodeAsParent.children[offset];
2972
- subresult = factory(child, offset, grandparents)();
2966
+ const subresult = factory(child, offset, grandparents)();
2973
2967
  if (subresult[0] === EXIT) {
2974
2968
  return subresult;
2975
2969
  }
@@ -2977,6 +2971,15 @@ function visitParents(tree, test, visitor, reverse) {
2977
2971
  }
2978
2972
  }
2979
2973
  }
2974
+ if (exit && matches) {
2975
+ const exitResult = toResult(exit(node, parents, index));
2976
+ if (exitResult[0] === SKIP) {
2977
+ throw new Error("Unexpected value `" + exitResult[0] + "` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing");
2978
+ }
2979
+ if (exitResult[0] === EXIT || typeof exitResult[1] === "number") {
2980
+ return exitResult;
2981
+ }
2982
+ }
2980
2983
  return result;
2981
2984
  }
2982
2985
  }
@@ -2991,14 +2994,14 @@ function toResult(value) {
2991
2994
  return value === null || value === undefined ? empty : [value];
2992
2995
  }
2993
2996
  var empty, CONTINUE = true, EXIT = false, SKIP = "skip";
2994
- var init_lib8 = __esm(() => {
2997
+ var init_lib7 = __esm(() => {
2995
2998
  init_unist_util_is();
2996
2999
  empty = [];
2997
3000
  });
2998
3001
 
2999
- // ../../node_modules/.bun/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/index.js
3002
+ // ../../node_modules/.bun/unist-util-visit-parents@6.1.0/node_modules/unist-util-visit-parents/index.js
3000
3003
  var init_unist_util_visit_parents = __esm(() => {
3001
- init_lib8();
3004
+ init_lib7();
3002
3005
  });
3003
3006
 
3004
3007
  // ../../node_modules/.bun/rehype-katex@7.0.1/node_modules/rehype-katex/lib/index.js
@@ -3075,7 +3078,7 @@ function rehypeKatex(options) {
3075
3078
  };
3076
3079
  }
3077
3080
  var emptyOptions2, emptyClasses;
3078
- var init_lib9 = __esm(() => {
3081
+ var init_lib8 = __esm(() => {
3079
3082
  init_browser();
3080
3083
  init_hast_util_to_text();
3081
3084
  init_unist_util_visit_parents();
@@ -3089,7 +3092,7 @@ __export(exports_rehype_katex, {
3089
3092
  default: () => rehypeKatex
3090
3093
  });
3091
3094
  var init_rehype_katex = __esm(() => {
3092
- init_lib9();
3095
+ init_lib8();
3093
3096
  });
3094
3097
 
3095
3098
  // src/sanitize-schema.ts
@@ -3158,7 +3161,7 @@ var sanitizeSchema = deepMergeSchemas(defaultSchema, {
3158
3161
  var localMermaidSpecifier = "./mermaid.js";
3159
3162
  function loadMermaid() {
3160
3163
  const nativeRuntime = globalThis.process?.versions?.node;
3161
- const specifier = nativeRuntime ? localMermaidSpecifier : "https://cdn.jsdelivr.net/npm/@duskmoon-dev/el-markdown-input@1.10.2/dist/esm/mermaid.js";
3164
+ const specifier = nativeRuntime ? localMermaidSpecifier : "https://cdn.jsdelivr.net/npm/@duskmoon-dev/el-markdown-input@1.10.3/dist/esm/mermaid.js";
3162
3165
  return import(specifier);
3163
3166
  }
3164
3167
 
@@ -3301,5 +3304,5 @@ export {
3301
3304
  renderMermaidBlocks
3302
3305
  };
3303
3306
 
3304
- //# debugId=CBABCB35875A325564756E2164756E21
3307
+ //# debugId=0B71170244BB1EE464756E2164756E21
3305
3308
  //# sourceMappingURL=render.js.map