@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.
@@ -2245,7 +2245,7 @@ function parse2(value) {
2245
2245
  return input ? input.split(/[ \t\n\r\f]+/g) : [];
2246
2246
  }
2247
2247
 
2248
- // ../../node_modules/.bun/hastscript@9.0.1/node_modules/hastscript/lib/create-h.js
2248
+ // ../../node_modules/.bun/hastscript@9.0.3/node_modules/hastscript/lib/create-h.js
2249
2249
  function createH(schema, defaultTagName, caseSensitive) {
2250
2250
  const adjust = caseSensitive ? createAdjustMap(caseSensitive) : undefined;
2251
2251
  function h(selector, properties, ...children) {
@@ -2270,7 +2270,7 @@ function createH(schema, defaultTagName, caseSensitive) {
2270
2270
  for (const child of children) {
2271
2271
  addChild(node.children, child);
2272
2272
  }
2273
- if (node.type === "element" && node.tagName === "template") {
2273
+ if (node.type === "element" && node.tagName === "template" && schema.space === "html") {
2274
2274
  node.content = { type: "root", children: node.children };
2275
2275
  node.children = [];
2276
2276
  }
@@ -2305,10 +2305,10 @@ function isChild(value) {
2305
2305
  return false;
2306
2306
  }
2307
2307
  function addProperty(schema, properties, key, value) {
2308
- const info = find(schema, key);
2309
- let result;
2310
2308
  if (value === null || value === undefined)
2311
2309
  return;
2310
+ const info = find(schema, key);
2311
+ let result;
2312
2312
  if (typeof value === "number") {
2313
2313
  if (Number.isNaN(value))
2314
2314
  return;
@@ -2338,7 +2338,8 @@ function addProperty(schema, properties, key, value) {
2338
2338
  result = finalResult;
2339
2339
  }
2340
2340
  if (info.property === "className" && Array.isArray(properties.className)) {
2341
- result = properties.className.concat(result);
2341
+ const add = result;
2342
+ result = [...properties.className, ...Array.isArray(add) ? add : [add]];
2342
2343
  }
2343
2344
  properties[info.property] = result;
2344
2345
  }
@@ -2389,7 +2390,7 @@ var init_create_h = __esm(() => {
2389
2390
  init_property_information();
2390
2391
  });
2391
2392
 
2392
- // ../../node_modules/.bun/hastscript@9.0.1/node_modules/hastscript/lib/svg-case-sensitive-tag-names.js
2393
+ // ../../node_modules/.bun/hastscript@9.0.3/node_modules/hastscript/lib/svg-case-sensitive-tag-names.js
2393
2394
  var svgCaseSensitiveTagNames;
2394
2395
  var init_svg_case_sensitive_tag_names = __esm(() => {
2395
2396
  svgCaseSensitiveTagNames = [
@@ -2435,7 +2436,7 @@ var init_svg_case_sensitive_tag_names = __esm(() => {
2435
2436
  ];
2436
2437
  });
2437
2438
 
2438
- // ../../node_modules/.bun/hastscript@9.0.1/node_modules/hastscript/lib/index.js
2439
+ // ../../node_modules/.bun/hastscript@9.0.3/node_modules/hastscript/lib/index.js
2439
2440
  var h, s;
2440
2441
  var init_lib4 = __esm(() => {
2441
2442
  init_property_information();
@@ -2445,7 +2446,7 @@ var init_lib4 = __esm(() => {
2445
2446
  s = createH(svg2, "g", svgCaseSensitiveTagNames);
2446
2447
  });
2447
2448
 
2448
- // ../../node_modules/.bun/hastscript@9.0.1/node_modules/hastscript/index.js
2449
+ // ../../node_modules/.bun/hastscript@9.0.3/node_modules/hastscript/index.js
2449
2450
  var init_hastscript = __esm(() => {
2450
2451
  init_lib4();
2451
2452
  });
@@ -2566,183 +2567,39 @@ var init_browser = __esm(() => {
2566
2567
  parser = new DOMParser;
2567
2568
  });
2568
2569
 
2569
- // ../../node_modules/.bun/unist-util-is@6.0.1/node_modules/unist-util-is/lib/index.js
2570
- function anyFactory(tests) {
2571
- const checks = [];
2572
- let index = -1;
2573
- while (++index < tests.length) {
2574
- checks[index] = convert(tests[index]);
2575
- }
2576
- return castFactory(any);
2577
- function any(...parameters) {
2578
- let index = -1;
2579
- while (++index < checks.length) {
2580
- if (checks[index].apply(this, parameters))
2581
- return true;
2582
- }
2583
- return false;
2584
- }
2585
- }
2586
- function propertiesFactory(check) {
2587
- const checkAsRecord = check;
2588
- return castFactory(all);
2589
- function all(node) {
2590
- const nodeAsRecord = node;
2591
- let key;
2592
- for (key in check) {
2593
- if (nodeAsRecord[key] !== checkAsRecord[key])
2594
- return false;
2595
- }
2596
- return true;
2597
- }
2598
- }
2599
- function typeFactory(check) {
2600
- return castFactory(type);
2601
- function type(node) {
2602
- return node && node.type === check;
2603
- }
2604
- }
2605
- function castFactory(testFunction) {
2606
- return check;
2607
- function check(value, index, parent) {
2608
- return Boolean(looksLikeANode(value) && testFunction.call(this, value, typeof index === "number" ? index : undefined, parent || undefined));
2609
- }
2610
- }
2611
- function ok2() {
2612
- return true;
2613
- }
2614
- function looksLikeANode(value) {
2615
- return value !== null && typeof value === "object" && "type" in value;
2616
- }
2617
- var convert = function(test) {
2618
- if (test === null || test === undefined) {
2619
- return ok2;
2620
- }
2621
- if (typeof test === "function") {
2622
- return castFactory(test);
2623
- }
2624
- if (typeof test === "object") {
2625
- return Array.isArray(test) ? anyFactory(test) : propertiesFactory(test);
2626
- }
2627
- if (typeof test === "string") {
2628
- return typeFactory(test);
2629
- }
2630
- throw new Error("Expected function, string, or object as test");
2631
- };
2632
-
2633
- // ../../node_modules/.bun/unist-util-is@6.0.1/node_modules/unist-util-is/index.js
2634
- var init_unist_util_is = () => {};
2635
-
2636
- // ../../node_modules/.bun/unist-util-find-after@5.0.0/node_modules/unist-util-find-after/lib/index.js
2637
- var findAfter = function(parent, index, test) {
2638
- const is = convert(test);
2639
- if (!parent || !parent.type || !parent.children) {
2640
- throw new Error("Expected parent node");
2641
- }
2642
- if (typeof index === "number") {
2643
- if (index < 0 || index === Number.POSITIVE_INFINITY) {
2644
- throw new Error("Expected positive finite number as index");
2645
- }
2646
- } else {
2647
- index = parent.children.indexOf(index);
2648
- if (index < 0) {
2649
- throw new Error("Expected child node or index");
2650
- }
2651
- }
2652
- while (++index < parent.children.length) {
2653
- if (is(parent.children[index], index, parent)) {
2654
- return parent.children[index];
2655
- }
2656
- }
2657
- return;
2658
- };
2659
- var init_lib6 = __esm(() => {
2660
- init_unist_util_is();
2661
- });
2662
-
2663
- // ../../node_modules/.bun/unist-util-find-after@5.0.0/node_modules/unist-util-find-after/index.js
2664
- var init_unist_util_find_after = __esm(() => {
2665
- init_lib6();
2666
- });
2667
-
2668
- // ../../node_modules/.bun/hast-util-is-element@3.0.0/node_modules/hast-util-is-element/lib/index.js
2669
- function anyFactory2(tests) {
2670
- const checks = [];
2671
- let index = -1;
2672
- while (++index < tests.length) {
2673
- checks[index] = convertElement(tests[index]);
2674
- }
2675
- return castFactory2(any);
2676
- function any(...parameters) {
2677
- let index = -1;
2678
- while (++index < checks.length) {
2679
- if (checks[index].apply(this, parameters))
2680
- return true;
2681
- }
2682
- return false;
2683
- }
2684
- }
2685
- function tagNameFactory(check) {
2686
- return castFactory2(tagName);
2687
- function tagName(element) {
2688
- return element.tagName === check;
2689
- }
2690
- }
2691
- function castFactory2(testFunction) {
2692
- return check;
2693
- function check(value, index, parent) {
2694
- return Boolean(looksLikeAnElement(value) && testFunction.call(this, value, typeof index === "number" ? index : undefined, parent || undefined));
2695
- }
2696
- }
2697
- function element2(element) {
2698
- return Boolean(element && typeof element === "object" && "type" in element && element.type === "element" && "tagName" in element && typeof element.tagName === "string");
2699
- }
2700
- function looksLikeAnElement(value) {
2701
- return value !== null && typeof value === "object" && "type" in value && "tagName" in value;
2702
- }
2703
- var convertElement = function(test) {
2704
- if (test === null || test === undefined) {
2705
- return element2;
2706
- }
2707
- if (typeof test === "string") {
2708
- return tagNameFactory(test);
2709
- }
2710
- if (typeof test === "object") {
2711
- return anyFactory2(test);
2712
- }
2713
- if (typeof test === "function") {
2714
- return castFactory2(test);
2715
- }
2716
- throw new Error("Expected function, string, or array as `test`");
2717
- };
2718
-
2719
- // ../../node_modules/.bun/hast-util-is-element@3.0.0/node_modules/hast-util-is-element/index.js
2720
- var init_hast_util_is_element = () => {};
2721
-
2722
- // ../../node_modules/.bun/hast-util-to-text@4.0.2/node_modules/hast-util-to-text/lib/index.js
2570
+ // ../../node_modules/.bun/hast-util-to-text@4.0.3/node_modules/hast-util-to-text/lib/index.js
2723
2571
  function toText(tree, options) {
2724
2572
  const options_ = options || {};
2725
2573
  const children = "children" in tree ? tree.children : [];
2726
- const block = blockOrCaption(tree);
2574
+ let block = false;
2575
+ let inTable = false;
2576
+ if (tree.type === "element") {
2577
+ block = blockOrCaptionNames.has(tree.tagName);
2578
+ inTable = tree.tagName === "table" || rowGroup(tree);
2579
+ }
2727
2580
  const whitespace = inferWhitespace(tree, {
2728
- whitespace: options_.whitespace || "normal",
2581
+ breakAfter: false,
2729
2582
  breakBefore: false,
2730
- breakAfter: false
2583
+ whitespace: options_.whitespace || "normal"
2731
2584
  });
2732
2585
  const results = [];
2733
2586
  if (tree.type === "text" || tree.type === "comment") {
2734
- results.push(...collectText(tree, {
2735
- whitespace,
2587
+ append(results, collectText(tree, {
2588
+ breakAfter: true,
2736
2589
  breakBefore: true,
2737
- breakAfter: true
2590
+ whitespace
2738
2591
  }));
2739
2592
  }
2740
2593
  let index = -1;
2741
2594
  while (++index < children.length) {
2742
- results.push(...renderedTextCollection(children[index], tree, {
2743
- whitespace,
2744
- breakBefore: index ? undefined : block,
2745
- breakAfter: index < children.length - 1 ? br(children[index + 1]) : block
2595
+ const next = children[index + 1];
2596
+ const breakAfter = next ? next.type === "element" && next.tagName === "br" : block;
2597
+ const breakBefore = index ? undefined : block;
2598
+ append(results, renderedTextCollection(children[index], index, tree, {
2599
+ breakAfter,
2600
+ breakBefore,
2601
+ rowAfter: inTable ? inferRowAfter(tree, index, undefined) : undefined,
2602
+ whitespace
2746
2603
  }));
2747
2604
  }
2748
2605
  const result = [];
@@ -2764,46 +2621,58 @@ function toText(tree, options) {
2764
2621
  }
2765
2622
  return result.join("");
2766
2623
  }
2767
- function renderedTextCollection(node, parent, info) {
2624
+ function renderedTextCollection(node, index, parent, info) {
2768
2625
  if (node.type === "element") {
2769
- return collectElement(node, parent, info);
2626
+ return collectElement(node, index, parent, info);
2770
2627
  }
2771
2628
  if (node.type === "text") {
2629
+ if (whitespaceOnly.test(node.value) && parent.type === "element" && (parent.tagName === "table" || parent.tagName === "tr" || rowGroup(parent))) {
2630
+ const before = parent.children[index - 1];
2631
+ const after = parent.children[index + 1];
2632
+ if ((!before || before.type === "element" && tablePartNames.has(before.tagName)) && (!after || after.type === "element" && tablePartNames.has(after.tagName))) {
2633
+ return [];
2634
+ }
2635
+ }
2772
2636
  return info.whitespace === "normal" ? collectText(node, info) : collectPreText(node);
2773
2637
  }
2774
2638
  return [];
2775
2639
  }
2776
- function collectElement(node, parent, info) {
2640
+ function collectElement(node, position, parent, info) {
2777
2641
  const whitespace = inferWhitespace(node, info);
2778
2642
  const children = node.children || [];
2643
+ const inTable = node.tagName === "table" || rowGroup(node);
2779
2644
  let index = -1;
2780
- let items = [];
2781
- if (notRendered(node)) {
2645
+ const items = [];
2646
+ if (notRenderedNames.has(node.tagName) || node.properties?.hidden || node.tagName === "dialog" && !node.properties?.open) {
2782
2647
  return items;
2783
2648
  }
2784
2649
  let prefix;
2785
2650
  let suffix;
2786
- if (br(node)) {
2651
+ if (node.tagName === "br") {
2787
2652
  suffix = `
2788
2653
  `;
2789
- } else if (row(node) && findAfter(parent, node, row)) {
2654
+ } else if (row(node) && (info.rowAfter || after(parent, position, row))) {
2790
2655
  suffix = `
2791
2656
  `;
2792
- } else if (p(node)) {
2657
+ } else if (node.tagName === "p") {
2793
2658
  prefix = 2;
2794
2659
  suffix = 2;
2795
- } else if (blockOrCaption(node)) {
2660
+ } else if (blockOrCaptionNames.has(node.tagName)) {
2796
2661
  prefix = 1;
2797
2662
  suffix = 1;
2798
2663
  }
2799
2664
  while (++index < children.length) {
2800
- items = items.concat(renderedTextCollection(children[index], node, {
2801
- whitespace,
2802
- breakBefore: index ? undefined : prefix,
2803
- breakAfter: index < children.length - 1 ? br(children[index + 1]) : suffix
2665
+ const next = children[index + 1];
2666
+ const breakAfter = next ? next.type === "element" && next.tagName === "br" : suffix;
2667
+ const breakBefore = index ? undefined : prefix;
2668
+ append(items, renderedTextCollection(children[index], index, node, {
2669
+ breakAfter,
2670
+ breakBefore,
2671
+ rowAfter: inTable ? inferRowAfter(node, index, info.rowAfter) : undefined,
2672
+ whitespace
2804
2673
  }));
2805
2674
  }
2806
- if (cell(node) && findAfter(parent, node, cell)) {
2675
+ if (cell(node) && after(parent, position, cell)) {
2807
2676
  items.push("\t");
2808
2677
  }
2809
2678
  if (prefix)
@@ -2867,7 +2736,6 @@ function trimAndCollapseSpacesAndTabs(value, breakBefore, breakAfter) {
2867
2736
  }
2868
2737
  function inferWhitespace(node, info) {
2869
2738
  if (node.type === "element") {
2870
- const properties = node.properties || {};
2871
2739
  switch (node.tagName) {
2872
2740
  case "listing":
2873
2741
  case "plaintext":
@@ -2878,11 +2746,11 @@ function inferWhitespace(node, info) {
2878
2746
  return "nowrap";
2879
2747
  }
2880
2748
  case "pre": {
2881
- return properties.wrap ? "pre-wrap" : "pre";
2749
+ return node.properties?.wrap ? "pre-wrap" : "pre";
2882
2750
  }
2883
2751
  case "td":
2884
2752
  case "th": {
2885
- return properties.noWrap ? "nowrap" : info.whitespace;
2753
+ return node.properties?.noWrap ? "nowrap" : info.whitespace;
2886
2754
  }
2887
2755
  case "textarea": {
2888
2756
  return "pre-wrap";
@@ -2892,26 +2760,62 @@ function inferWhitespace(node, info) {
2892
2760
  }
2893
2761
  return info.whitespace;
2894
2762
  }
2895
- function hidden(node) {
2896
- return Boolean((node.properties || {}).hidden);
2763
+ function inferRowAfter(parent, index, rowAfter) {
2764
+ return parent.type === "element" && parent.tagName === "table" ? after(parent, index, rowOrRowGroupWithRow) : rowAfter;
2897
2765
  }
2898
- function isCell(node) {
2766
+ function after(parent, index, test) {
2767
+ while (++index < parent.children.length) {
2768
+ const child = parent.children[index];
2769
+ if (child.type === "element" && test(child))
2770
+ return true;
2771
+ }
2772
+ return false;
2773
+ }
2774
+ function append(list, items) {
2775
+ let index = -1;
2776
+ while (++index < items.length) {
2777
+ list.push(items[index]);
2778
+ }
2779
+ }
2780
+ function cell(node) {
2899
2781
  return node.tagName === "td" || node.tagName === "th";
2900
2782
  }
2901
- function closedDialog(node) {
2902
- return node.tagName === "dialog" && !(node.properties || {}).open;
2783
+ function rowGroup(node) {
2784
+ return node.tagName === "tbody" || node.tagName === "tfoot" || node.tagName === "thead";
2903
2785
  }
2904
- var searchLineFeeds, searchTabOrSpaces, br, cell, p, row, notRendered, blockOrCaption;
2905
- var init_lib7 = __esm(() => {
2906
- init_unist_util_find_after();
2907
- init_hast_util_is_element();
2786
+ function rowOrRowGroupWithRow(node) {
2787
+ if (row(node))
2788
+ return true;
2789
+ if (rowGroup(node)) {
2790
+ let index = -1;
2791
+ while (++index < node.children.length) {
2792
+ const child = node.children[index];
2793
+ if (child.type === "element" && row(child))
2794
+ return true;
2795
+ }
2796
+ }
2797
+ return false;
2798
+ }
2799
+ function row(node) {
2800
+ return node.tagName === "tr";
2801
+ }
2802
+ var searchLineFeeds, searchTabOrSpaces, whitespaceOnly, tablePartNames, notRenderedNames, blockOrCaptionNames;
2803
+ var init_lib6 = __esm(() => {
2908
2804
  searchLineFeeds = /\n/g;
2909
2805
  searchTabOrSpaces = /[\t ]+/g;
2910
- br = convertElement("br");
2911
- cell = convertElement(isCell);
2912
- p = convertElement("p");
2913
- row = convertElement("tr");
2914
- notRendered = convertElement([
2806
+ whitespaceOnly = /^[\t\n\f\r ]+$/;
2807
+ tablePartNames = new Set([
2808
+ "caption",
2809
+ "col",
2810
+ "colgroup",
2811
+ "tbody",
2812
+ "td",
2813
+ "tfoot",
2814
+ "th",
2815
+ "thead",
2816
+ "tr"
2817
+ ]);
2818
+ notRenderedNames = new Set([
2915
2819
  "datalist",
2916
2820
  "head",
2917
2821
  "noembed",
@@ -2921,11 +2825,9 @@ var init_lib7 = __esm(() => {
2921
2825
  "script",
2922
2826
  "style",
2923
2827
  "template",
2924
- "title",
2925
- hidden,
2926
- closedDialog
2828
+ "title"
2927
2829
  ]);
2928
- blockOrCaption = convertElement([
2830
+ blockOrCaptionNames = new Set([
2929
2831
  "address",
2930
2832
  "article",
2931
2833
  "aside",
@@ -2942,7 +2844,7 @@ var init_lib7 = __esm(() => {
2942
2844
  "figure",
2943
2845
  "figcaption",
2944
2846
  "footer",
2945
- "form,",
2847
+ "form",
2946
2848
  "h1",
2947
2849
  "h2",
2948
2850
  "h3",
@@ -2969,27 +2871,121 @@ var init_lib7 = __esm(() => {
2969
2871
  ]);
2970
2872
  });
2971
2873
 
2972
- // ../../node_modules/.bun/hast-util-to-text@4.0.2/node_modules/hast-util-to-text/index.js
2874
+ // ../../node_modules/.bun/hast-util-to-text@4.0.3/node_modules/hast-util-to-text/index.js
2973
2875
  var init_hast_util_to_text = __esm(() => {
2974
- init_lib7();
2876
+ init_lib6();
2975
2877
  });
2976
2878
 
2977
- // ../../node_modules/.bun/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/color.js
2879
+ // ../../node_modules/.bun/unist-util-is@6.0.1/node_modules/unist-util-is/lib/index.js
2880
+ function anyFactory(tests) {
2881
+ const checks = [];
2882
+ let index = -1;
2883
+ while (++index < tests.length) {
2884
+ checks[index] = convert(tests[index]);
2885
+ }
2886
+ return castFactory(any);
2887
+ function any(...parameters) {
2888
+ let index = -1;
2889
+ while (++index < checks.length) {
2890
+ if (checks[index].apply(this, parameters))
2891
+ return true;
2892
+ }
2893
+ return false;
2894
+ }
2895
+ }
2896
+ function propertiesFactory(check) {
2897
+ const checkAsRecord = check;
2898
+ return castFactory(all);
2899
+ function all(node) {
2900
+ const nodeAsRecord = node;
2901
+ let key;
2902
+ for (key in check) {
2903
+ if (nodeAsRecord[key] !== checkAsRecord[key])
2904
+ return false;
2905
+ }
2906
+ return true;
2907
+ }
2908
+ }
2909
+ function typeFactory(check) {
2910
+ return castFactory(type);
2911
+ function type(node) {
2912
+ return node && node.type === check;
2913
+ }
2914
+ }
2915
+ function castFactory(testFunction) {
2916
+ return check;
2917
+ function check(value, index, parent) {
2918
+ return Boolean(looksLikeANode(value) && testFunction.call(this, value, typeof index === "number" ? index : undefined, parent || undefined));
2919
+ }
2920
+ }
2921
+ function ok2() {
2922
+ return true;
2923
+ }
2924
+ function looksLikeANode(value) {
2925
+ return value !== null && typeof value === "object" && "type" in value;
2926
+ }
2927
+ var convert = function(test) {
2928
+ if (test === null || test === undefined) {
2929
+ return ok2;
2930
+ }
2931
+ if (typeof test === "function") {
2932
+ return castFactory(test);
2933
+ }
2934
+ if (typeof test === "object") {
2935
+ return Array.isArray(test) ? anyFactory(test) : propertiesFactory(test);
2936
+ }
2937
+ if (typeof test === "string") {
2938
+ return typeFactory(test);
2939
+ }
2940
+ throw new Error("Expected function, string, or object as test");
2941
+ };
2942
+
2943
+ // ../../node_modules/.bun/unist-util-is@6.0.1/node_modules/unist-util-is/index.js
2944
+ var init_unist_util_is = () => {};
2945
+
2946
+ // ../../node_modules/.bun/unist-util-visit-parents@6.1.0/node_modules/unist-util-visit-parents/lib/color.js
2978
2947
  function color(d) {
2979
2948
  return d;
2980
2949
  }
2981
2950
 
2982
- // ../../node_modules/.bun/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/index.js
2983
- function visitParents(tree, test, visitor, reverse) {
2951
+ // ../../node_modules/.bun/unist-util-visit-parents@6.1.0/node_modules/unist-util-visit-parents/lib/index.js
2952
+ function visitParents(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, reverse) {
2953
+ if (!tree || typeof tree !== "object") {
2954
+ throw new Error("Unexpected value `" + tree + "` for `tree`, expected node");
2955
+ }
2956
+ let preorder = true;
2984
2957
  let check;
2985
- if (typeof test === "function" && typeof visitor !== "function") {
2986
- reverse = visitor;
2987
- visitor = test;
2958
+ let visitors;
2959
+ let enter;
2960
+ let exit;
2961
+ if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
2962
+ check = testOrEnterOrVisitors;
2963
+ visitors = enterOrVisitorsOrReverse;
2964
+ if (reverse)
2965
+ preorder = false;
2988
2966
  } else {
2989
- check = test;
2967
+ visitors = testOrEnterOrVisitors;
2968
+ if (enterOrVisitorsOrReverse)
2969
+ preorder = false;
2970
+ }
2971
+ if (typeof visitors === "function") {
2972
+ enter = visitors;
2973
+ } else if (visitors && typeof visitors === "object") {
2974
+ if (visitors.enter === null || visitors.enter === undefined) {} else if (typeof visitors.enter === "function") {
2975
+ enter = visitors.enter;
2976
+ } else {
2977
+ throw new Error("Unexpected value `" + visitors.enter + "` for `visitors.enter`, expected optional visitor");
2978
+ }
2979
+ if (typeof visitors.exit === "function") {
2980
+ exit = visitors.exit;
2981
+ } else {
2982
+ throw new Error("Unexpected value `" + visitors.exit + "` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)");
2983
+ }
2984
+ } else {
2985
+ throw new Error("Unexpected value `" + visitors + "` for `enter` or `visitors`, expected visitor or object with visitors");
2990
2986
  }
2991
2987
  const is = convert(check);
2992
- const step = reverse ? -1 : 1;
2988
+ const step = preorder ? 1 : -1;
2993
2989
  factory(tree, undefined, [])();
2994
2990
  function factory(node, index, parents) {
2995
2991
  const value = node && typeof node === "object" ? node : {};
@@ -3001,12 +2997,10 @@ function visitParents(tree, test, visitor, reverse) {
3001
2997
  }
3002
2998
  return visit;
3003
2999
  function visit() {
3000
+ const matches = !check || is(node, index, parents[parents.length - 1] || undefined);
3004
3001
  let result = empty;
3005
- let subresult;
3006
- let offset;
3007
- let grandparents;
3008
- if (!test || is(node, index, parents[parents.length - 1] || undefined)) {
3009
- result = toResult(visitor(node, parents));
3002
+ if (enter && matches) {
3003
+ result = toResult(enter(node, parents, index));
3010
3004
  if (result[0] === EXIT) {
3011
3005
  return result;
3012
3006
  }
@@ -3014,11 +3008,11 @@ function visitParents(tree, test, visitor, reverse) {
3014
3008
  if ("children" in node && node.children) {
3015
3009
  const nodeAsParent = node;
3016
3010
  if (nodeAsParent.children && result[0] !== SKIP) {
3017
- offset = (reverse ? nodeAsParent.children.length : -1) + step;
3018
- grandparents = parents.concat(nodeAsParent);
3011
+ let offset = (preorder ? -1 : nodeAsParent.children.length) + step;
3012
+ const grandparents = [...parents, nodeAsParent];
3019
3013
  while (offset > -1 && offset < nodeAsParent.children.length) {
3020
3014
  const child = nodeAsParent.children[offset];
3021
- subresult = factory(child, offset, grandparents)();
3015
+ const subresult = factory(child, offset, grandparents)();
3022
3016
  if (subresult[0] === EXIT) {
3023
3017
  return subresult;
3024
3018
  }
@@ -3026,6 +3020,15 @@ function visitParents(tree, test, visitor, reverse) {
3026
3020
  }
3027
3021
  }
3028
3022
  }
3023
+ if (exit && matches) {
3024
+ const exitResult = toResult(exit(node, parents, index));
3025
+ if (exitResult[0] === SKIP) {
3026
+ throw new Error("Unexpected value `" + exitResult[0] + "` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing");
3027
+ }
3028
+ if (exitResult[0] === EXIT || typeof exitResult[1] === "number") {
3029
+ return exitResult;
3030
+ }
3031
+ }
3029
3032
  return result;
3030
3033
  }
3031
3034
  }
@@ -3040,14 +3043,14 @@ function toResult(value) {
3040
3043
  return value === null || value === undefined ? empty : [value];
3041
3044
  }
3042
3045
  var empty, CONTINUE = true, EXIT = false, SKIP = "skip";
3043
- var init_lib8 = __esm(() => {
3046
+ var init_lib7 = __esm(() => {
3044
3047
  init_unist_util_is();
3045
3048
  empty = [];
3046
3049
  });
3047
3050
 
3048
- // ../../node_modules/.bun/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/index.js
3051
+ // ../../node_modules/.bun/unist-util-visit-parents@6.1.0/node_modules/unist-util-visit-parents/index.js
3049
3052
  var init_unist_util_visit_parents = __esm(() => {
3050
- init_lib8();
3053
+ init_lib7();
3051
3054
  });
3052
3055
 
3053
3056
  // ../../node_modules/.bun/rehype-katex@7.0.1/node_modules/rehype-katex/lib/index.js
@@ -3123,7 +3126,7 @@ function rehypeKatex(options) {
3123
3126
  };
3124
3127
  }
3125
3128
  var import_katex, emptyOptions2, emptyClasses;
3126
- var init_lib9 = __esm(() => {
3129
+ var init_lib8 = __esm(() => {
3127
3130
  init_browser();
3128
3131
  init_hast_util_to_text();
3129
3132
  init_unist_util_visit_parents();
@@ -3138,7 +3141,7 @@ __export(exports_rehype_katex, {
3138
3141
  default: () => rehypeKatex
3139
3142
  });
3140
3143
  var init_rehype_katex = __esm(() => {
3141
- init_lib9();
3144
+ init_lib8();
3142
3145
  });
3143
3146
 
3144
3147
  // src/render.ts
@@ -3215,7 +3218,7 @@ var sanitizeSchema = deepMergeSchemas(import_rehype_sanitize.defaultSchema, {
3215
3218
  var localMermaidSpecifier = "./mermaid.js";
3216
3219
  function loadMermaid() {
3217
3220
  const nativeRuntime = globalThis.process?.versions?.node;
3218
- const specifier = nativeRuntime ? localMermaidSpecifier : "https://cdn.jsdelivr.net/npm/@duskmoon-dev/el-markdown-input@1.10.2/dist/esm/mermaid.js";
3221
+ const specifier = nativeRuntime ? localMermaidSpecifier : "https://cdn.jsdelivr.net/npm/@duskmoon-dev/el-markdown-input@1.10.3/dist/esm/mermaid.js";
3219
3222
  return import(specifier);
3220
3223
  }
3221
3224
 
@@ -3354,5 +3357,5 @@ Source: %s`, id, err, block.textContent?.slice(0, 200));
3354
3357
  }
3355
3358
  }
3356
3359
 
3357
- //# debugId=43F1BB59E0AE2CA664756E2164756E21
3360
+ //# debugId=A9EDB9AE34EC3DBD64756E2164756E21
3358
3361
  //# sourceMappingURL=render.js.map