@jxsuite/parser 4.1.2 → 4.3.0

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/dist/serialize.js CHANGED
@@ -892,6 +892,9 @@ function isRef(value) {
892
892
  function isNodeObject(value) {
893
893
  return isJsonObject(value);
894
894
  }
895
+ function isTemplateString(value) {
896
+ return typeof value === "string" && value.includes("${");
897
+ }
895
898
  function isPlainTagName(tagName) {
896
899
  return typeof tagName === "string";
897
900
  }
@@ -9682,10 +9685,402 @@ function checkEmphasis(state) {
9682
9685
  return marker;
9683
9686
  }
9684
9687
 
9688
+ // ../../node_modules/mdast-util-to-markdown/lib/util/character.js
9689
+ function firstCharacter(value) {
9690
+ const code = value.codePointAt(0);
9691
+ return code === undefined ? "" : String.fromCodePoint(code);
9692
+ }
9693
+ function lastCharacter(value) {
9694
+ const code = value.codePointAt(value.length - 2);
9695
+ return code !== undefined && code > 65535 ? value.slice(-2) : value.slice(-1);
9696
+ }
9697
+
9698
+ // ../../node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
9699
+ function encodeCharacterReference(code) {
9700
+ return "&#x" + code.toString(16).toUpperCase() + ";";
9701
+ }
9702
+
9703
+ // ../../node_modules/mdast-util-to-markdown/lib/util/encode-info.js
9704
+ function encodeInfo(outside, inside, marker) {
9705
+ const outsideKind = classifyCharacter(outside);
9706
+ const insideKind = classifyCharacter(inside);
9707
+ if (outsideKind === undefined) {
9708
+ return insideKind === undefined ? marker === "_" ? { inside: true, outside: true } : { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: true } : { inside: false, outside: true };
9709
+ }
9710
+ if (outsideKind === 1) {
9711
+ return insideKind === undefined ? { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: true } : { inside: false, outside: false };
9712
+ }
9713
+ return insideKind === undefined ? { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: false } : { inside: false, outside: false };
9714
+ }
9715
+ var init_encode_info = __esm(() => {
9716
+ init_dev6();
9717
+ });
9718
+
9719
+ // ../../node_modules/mdast-util-to-markdown/lib/util/html-kind.js
9720
+ function htmlKind(value) {
9721
+ if (value.charCodeAt(0) !== 60)
9722
+ return;
9723
+ const next = value.charCodeAt(1);
9724
+ if (next === 33) {
9725
+ const code = value.charCodeAt(2);
9726
+ if (code === 45)
9727
+ return 2;
9728
+ if (code === 91)
9729
+ return 5;
9730
+ if (asciiAlpha(code))
9731
+ return 4;
9732
+ return;
9733
+ }
9734
+ if (next === 63)
9735
+ return 3;
9736
+ const closing = next === 47;
9737
+ const start = closing ? 2 : 1;
9738
+ let end = start;
9739
+ let code = value.charCodeAt(end);
9740
+ if (!asciiAlpha(code))
9741
+ return;
9742
+ while (code === 45 || asciiAlphanumeric(code)) {
9743
+ code = value.charCodeAt(++end);
9744
+ }
9745
+ const name = value.slice(start, end).toLowerCase();
9746
+ if (!closing && code !== 47 && htmlRawNames.includes(name)) {
9747
+ return 1;
9748
+ }
9749
+ return htmlBlockNames.includes(name) ? 6 : 7;
9750
+ }
9751
+ var init_html_kind = __esm(() => {
9752
+ init_dev4();
9753
+ init_micromark_util_html_tag_name();
9754
+ });
9755
+
9756
+ // ../../node_modules/mdast-util-to-markdown/lib/util/container-phrasing.js
9757
+ function candidates(tokens, involved, runOf) {
9758
+ const related = new Set;
9759
+ for (const token of tokens) {
9760
+ const siblings = runOf.get(token);
9761
+ if (siblings && token.attention && involved.some((d) => d.attention === token.attention)) {
9762
+ for (const sibling of siblings.tokens) {
9763
+ related.add(sibling.attention);
9764
+ }
9765
+ }
9766
+ }
9767
+ const ordered = [];
9768
+ for (const token of tokens) {
9769
+ if (token.attention && related.delete(token.attention)) {
9770
+ ordered.push(token.attention);
9771
+ }
9772
+ }
9773
+ ordered.reverse();
9774
+ return ordered;
9775
+ }
9776
+ function check(tokens, before, after) {
9777
+ const runs = [];
9778
+ const wrong = new Map;
9779
+ const runOf = new Map;
9780
+ let index = 0;
9781
+ while (index < tokens.length) {
9782
+ if (!tokens[index].attention) {
9783
+ index++;
9784
+ continue;
9785
+ }
9786
+ const marker = tokens[index].value.charAt(0);
9787
+ const strict = builtins.get(marker);
9788
+ let end = index + 1;
9789
+ while (end < tokens.length && tokens[end].attention && tokens[end].value.charAt(0) === marker) {
9790
+ end++;
9791
+ }
9792
+ const head = index ? tokens[index - 1].value : before;
9793
+ const previous = classifyCharacter(head.charCodeAt(head.length - 1));
9794
+ const next = classifyCharacter((end < tokens.length ? tokens[end].value : after).charCodeAt(0));
9795
+ const open = !next || next === 2 && Boolean(previous);
9796
+ const close = !previous || previous === 2 && Boolean(next);
9797
+ const run = {
9798
+ tokens: tokens.slice(index, end),
9799
+ markers: [],
9800
+ start: 0,
9801
+ end: 0,
9802
+ open: strict ? open && (Boolean(previous) || !close) : open,
9803
+ close: strict ? close && (Boolean(next) || !open) : close,
9804
+ split: strict !== undefined
9805
+ };
9806
+ for (const token of run.tokens) {
9807
+ wrong.set(token, [...run.tokens]);
9808
+ runOf.set(token, run);
9809
+ let size = token.value.length;
9810
+ while (size--)
9811
+ run.markers.push(token);
9812
+ }
9813
+ run.end = run.markers.length;
9814
+ runs.push(run);
9815
+ index = end;
9816
+ }
9817
+ pair(runs, wrong);
9818
+ index = -1;
9819
+ while (++index < tokens.length) {
9820
+ const involved = wrong.get(tokens[index]);
9821
+ if (involved)
9822
+ return { attention: candidates(tokens, involved, runOf), index };
9823
+ }
9824
+ }
9825
+ function containerPhrasing(parent, state, info) {
9826
+ return serialize(phrasing2(parent, state, info), info.before, info.after);
9827
+ }
9828
+ function encode(tokens, start) {
9829
+ const token = tokens[start ? 0 : tokens.length - 1];
9830
+ if (!token || token.attention)
9831
+ return;
9832
+ const character = start ? firstCharacter(token.value) : lastCharacter(token.value);
9833
+ const reference = encodeCharacterReference(character.codePointAt(0));
9834
+ if (start) {
9835
+ token.value = reference + token.value.slice(character.length);
9836
+ } else {
9837
+ let value = token.value.slice(0, token.value.length - character.length);
9838
+ let escapes = 0;
9839
+ while (value.charCodeAt(value.length - 1 - escapes) === 92) {
9840
+ escapes++;
9841
+ }
9842
+ if (escapes % 2)
9843
+ value += "\\";
9844
+ token.value = value + reference;
9845
+ }
9846
+ }
9847
+ function improve(items, chosen, mistake, before, after) {
9848
+ for (const attention of mistake.attention) {
9849
+ const current = chosen.get(attention) || attention.sequences[0];
9850
+ for (const sequence of attention.sequences) {
9851
+ if (sequence === current)
9852
+ continue;
9853
+ const trial = new Map(chosen);
9854
+ trial.set(attention, sequence);
9855
+ const tokens = render(items, trial, before, after);
9856
+ const next = check(tokens, before, after);
9857
+ if (!next || next.index > mistake.index) {
9858
+ return { chosen: trial, mistake: next, tokens };
9859
+ }
9860
+ }
9861
+ }
9862
+ }
9863
+ function pair(runs, wrong) {
9864
+ const openersByMarker = new Map;
9865
+ for (const closer of runs) {
9866
+ const marker = closer.tokens[0].value.charAt(0);
9867
+ let openers = openersByMarker.get(marker);
9868
+ if (!openers) {
9869
+ openers = [];
9870
+ openersByMarker.set(marker, openers);
9871
+ }
9872
+ let open = closer.close ? openers.length : 0;
9873
+ while (open-- && closer.start < closer.end) {
9874
+ const opener = openers[open];
9875
+ const openerSize = opener.end - opener.start;
9876
+ const closerSize = closer.end - closer.start;
9877
+ if (closer.split ? (opener.close || closer.open) && closerSize % 3 && !((openerSize + closerSize) % 3) : openerSize !== opener.markers.length || openerSize !== closerSize) {
9878
+ continue;
9879
+ }
9880
+ const size = closer.split ? openerSize > 1 && closerSize > 1 ? 2 : 1 : closerSize;
9881
+ const opening = opener.markers.slice(opener.end - size, opener.end);
9882
+ const closing = closer.markers.slice(closer.start, closer.start + size);
9883
+ const openToken = opening[0];
9884
+ const closeToken = closing[0];
9885
+ if (openToken === opening[size - 1] && openToken.value.length === size && closeToken === closing[size - 1] && closeToken.value.length === size && openToken.attention === closeToken.attention) {
9886
+ wrong.delete(openToken);
9887
+ wrong.delete(closeToken);
9888
+ } else {
9889
+ const involved = [...new Set([...opening, ...closing])];
9890
+ for (const token of involved) {
9891
+ const list = wrong.get(token);
9892
+ if (list)
9893
+ list.push(...involved);
9894
+ }
9895
+ }
9896
+ opener.end -= size;
9897
+ closer.start += size;
9898
+ if (opener.start === opener.end)
9899
+ openers.splice(open, 1);
9900
+ open = openers.length;
9901
+ }
9902
+ if (closer.open && closer.start < closer.end)
9903
+ openers.push(closer);
9904
+ }
9905
+ }
9906
+ function attentionSequences(type, markers, sizes) {
9907
+ if (markers.length === 0) {
9908
+ throw new Error("Cannot serialize `" + type + "` as attention without markers, expected one or more markers");
9909
+ }
9910
+ if (sizes.length === 0) {
9911
+ throw new Error("Cannot serialize `" + type + "` as attention without sizes, expected one or more sizes");
9912
+ }
9913
+ for (const size of sizes) {
9914
+ if (!Number.isSafeInteger(size) || size < 1) {
9915
+ throw new Error("Cannot serialize `" + type + "` as attention with `" + size + "` as size, expected positive integer");
9916
+ }
9917
+ }
9918
+ const sequences = [];
9919
+ for (const marker of markers) {
9920
+ if (marker.length !== 1) {
9921
+ throw new Error("Cannot serialize `" + type + "` as attention with `" + marker + "` as marker, expected a single ascii character");
9922
+ }
9923
+ if (!asciiPunctuation(marker.charCodeAt(0))) {
9924
+ throw new Error("Cannot serialize `" + type + "` as attention with `" + marker + "` as marker, expected ascii punctuation");
9925
+ }
9926
+ for (const size of sizes) {
9927
+ sequences.push(marker.repeat(size));
9928
+ }
9929
+ }
9930
+ return sequences;
9931
+ }
9932
+ function phrasing2(parent, state, info) {
9933
+ const indexStack = state.indexStack;
9934
+ const children = parent.children || [];
9935
+ const results = [];
9936
+ let index = -1;
9937
+ let before = info.before;
9938
+ indexStack.push(-1);
9939
+ let tracker = state.createTracker(info);
9940
+ while (++index < children.length) {
9941
+ const child = children[index];
9942
+ let after;
9943
+ indexStack[indexStack.length - 1] = index;
9944
+ if (index + 1 < children.length) {
9945
+ let handle = state.handle.handlers[children[index + 1].type];
9946
+ if (handle && handle.peek)
9947
+ handle = handle.peek;
9948
+ after = handle ? firstCharacter(handle(children[index + 1], parent, state, {
9949
+ before: "",
9950
+ after: "",
9951
+ ...tracker.current()
9952
+ })) : "";
9953
+ } else {
9954
+ after = info.after;
9955
+ }
9956
+ const previous = results[results.length - 1];
9957
+ if (typeof previous === "string" && (before === "\r" || before === `
9958
+ `) && child.type === "html" && htmlKind(child.value) !== 7) {
9959
+ results[results.length - 1] = previous.replace(/(\r?\n|\r)$/, " ");
9960
+ before = " ";
9961
+ tracker = state.createTracker(info);
9962
+ tracker.move(serialize(results, info.before, info.after));
9963
+ }
9964
+ const handle = state.handle.handlers[child.type];
9965
+ if (handle && handle.attention) {
9966
+ const item = attentionItem(child, handle.attention, state, tracker);
9967
+ results.push(item);
9968
+ before = lastCharacter(item.sequences[0]);
9969
+ } else {
9970
+ const value = state.handle(child, parent, state, {
9971
+ ...tracker.current(),
9972
+ after,
9973
+ before
9974
+ });
9975
+ if (!value)
9976
+ continue;
9977
+ tracker.move(value);
9978
+ results.push(value);
9979
+ before = lastCharacter(value);
9980
+ }
9981
+ }
9982
+ indexStack.pop();
9983
+ return results;
9984
+ }
9985
+ function attentionItem(node, attention, state, tracker) {
9986
+ const { construct, markers, sizes } = attention(node, state);
9987
+ const sequences = attentionSequences(node.type, markers, sizes);
9988
+ const sequence = sequences[0];
9989
+ const exit = state.enter(construct);
9990
+ tracker.move(sequence);
9991
+ const children = phrasing2(node, state, {
9992
+ ...tracker.current(),
9993
+ before: sequence,
9994
+ after: sequence
9995
+ });
9996
+ tracker.move(serialize(children, sequence, sequence));
9997
+ tracker.move(sequence);
9998
+ exit();
9999
+ return { children, sequences };
10000
+ }
10001
+ function render(items, chosen, before, after) {
10002
+ const tokens = [];
10003
+ let encodeAfter;
10004
+ let previous = lastCharacter(before);
10005
+ let index = -1;
10006
+ while (++index < items.length) {
10007
+ const item = items[index];
10008
+ if (typeof item === "string") {
10009
+ const token = { value: item, attention: undefined };
10010
+ if (encodeAfter && encodeAfter === firstCharacter(item)) {
10011
+ encode([token], true);
10012
+ }
10013
+ encodeAfter = undefined;
10014
+ tokens.push(token);
10015
+ if (token.value)
10016
+ previous = lastCharacter(token.value);
10017
+ continue;
10018
+ }
10019
+ const sequence = chosen.get(item) || item.sequences[0];
10020
+ const marker = sequence.charAt(0);
10021
+ const next = items[index + 1];
10022
+ const outsideBefore = previous;
10023
+ const outsideAfter = firstCharacter(next === undefined ? after : typeof next === "string" ? next : chosen.get(next) || next.sequences[0]);
10024
+ const inside = render(item.children, chosen, sequence, sequence);
10025
+ const head = inside.length > 0 ? inside[0].value : "";
10026
+ const open = encodeInfo(outsideBefore.charCodeAt(outsideBefore.length - 1), head.charCodeAt(0), marker);
10027
+ if (open.inside)
10028
+ encode(inside, true);
10029
+ const tail = inside.length > 0 ? lastCharacter(inside[inside.length - 1].value) : "";
10030
+ const close = encodeInfo(outsideAfter.charCodeAt(0), tail.charCodeAt(tail.length - 1), marker);
10031
+ if (close.inside)
10032
+ encode(inside, false);
10033
+ if (open.outside && outsideBefore !== `
10034
+ ` && outsideBefore !== "\r") {
10035
+ encode(tokens, false);
10036
+ }
10037
+ if (close.outside)
10038
+ encodeAfter = outsideAfter;
10039
+ tokens.push({ value: sequence, attention: item }, ...inside, {
10040
+ value: sequence,
10041
+ attention: item
10042
+ });
10043
+ previous = sequence.charAt(sequence.length - 1);
10044
+ }
10045
+ return tokens;
10046
+ }
10047
+ function serialize(items, before, after) {
10048
+ let chosen = new Map;
10049
+ const initial = render(items, chosen, before, after);
10050
+ let tokens = initial;
10051
+ let mistake = check(tokens, before, after);
10052
+ while (mistake) {
10053
+ const next = improve(items, chosen, mistake, before, after);
10054
+ if (!next) {
10055
+ tokens = initial;
10056
+ break;
10057
+ }
10058
+ chosen = next.chosen;
10059
+ tokens = next.tokens;
10060
+ mistake = next.mistake;
10061
+ }
10062
+ let result = "";
10063
+ for (const token of tokens)
10064
+ result += token.value;
10065
+ return result;
10066
+ }
10067
+ var builtins;
10068
+ var init_container_phrasing = __esm(() => {
10069
+ init_dev4();
10070
+ init_dev6();
10071
+ init_encode_info();
10072
+ init_html_kind();
10073
+ builtins = new Map([
10074
+ ["*", false],
10075
+ ["_", true]
10076
+ ]);
10077
+ });
10078
+
9685
10079
  // ../../node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
9686
10080
  function emphasis(node, _, state, info) {
9687
10081
  const exit = state.enter("phrasing");
9688
- const value = state.containerPhrasing({ type: "root", children: [node] }, info);
10082
+ const item = attentionItem(node, attention2, state, state.createTracker(info));
10083
+ const value = serialize([item], info.before, info.after);
9689
10084
  exit();
9690
10085
  return value;
9691
10086
  }
@@ -9701,15 +10096,11 @@ function peek(_, _1, state) {
9701
10096
  return state.options.emphasis || "*";
9702
10097
  }
9703
10098
  var init_emphasis = __esm(() => {
10099
+ init_container_phrasing();
9704
10100
  emphasis.attention = attention2;
9705
10101
  emphasis.peek = peek;
9706
10102
  });
9707
10103
 
9708
- // ../../node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
9709
- function encodeCharacterReference(code) {
9710
- return "&#x" + code.toString(16).toUpperCase() + ";";
9711
- }
9712
-
9713
10104
  // ../../node_modules/unist-util-visit/node_modules/unist-util-visit-parents/lib/color.node.js
9714
10105
  function color(d) {
9715
10106
  return "\x1B[33m" + d + "\x1B[39m";
@@ -10094,14 +10485,27 @@ function link(node, _, state, info) {
10094
10485
  const exit = state.enter("link");
10095
10486
  let subexit = state.enter("label");
10096
10487
  let value = tracker.move("[");
10097
- value += tracker.move(state.containerPhrasing(node, {
10488
+ const text = state.containerPhrasing(node, {
10098
10489
  before: value,
10099
10490
  after: "](",
10100
10491
  ...tracker.current()
10101
- }));
10102
- value += tracker.move("](");
10492
+ });
10493
+ value += tracker.move(text);
10103
10494
  subexit();
10104
- if (!node.url && node.title || /[\0- \u007F]/.test(node.url)) {
10495
+ value += tracker.move("](");
10496
+ const enclose = /[\0- \u007F]/.test(node.url);
10497
+ const last = info.before.charAt(info.before.length - 1);
10498
+ let title = node.title || undefined;
10499
+ if (!title && !enclose && (last === `
10500
+ ` || last === "\r")) {
10501
+ let index = 0;
10502
+ while (index < text.length && text.charCodeAt(index) !== 93) {
10503
+ index += text.charCodeAt(index) === 92 ? 2 : 1;
10504
+ }
10505
+ if (text.charCodeAt(index + 1) === 58)
10506
+ title = "";
10507
+ }
10508
+ if (!node.url && typeof title === "string" || enclose) {
10105
10509
  subexit = state.enter("destinationLiteral");
10106
10510
  value += tracker.move("<");
10107
10511
  value += tracker.move(state.safe(node.url, { before: value, after: ">", ...tracker.current() }));
@@ -10110,15 +10514,15 @@ function link(node, _, state, info) {
10110
10514
  subexit = state.enter("destinationRaw");
10111
10515
  value += tracker.move(state.safe(node.url, {
10112
10516
  before: value,
10113
- after: node.title ? " " : ")",
10517
+ after: typeof title === "string" ? " " : ")",
10114
10518
  ...tracker.current()
10115
10519
  }));
10116
10520
  }
10117
10521
  subexit();
10118
- if (node.title) {
10522
+ if (typeof title === "string") {
10119
10523
  subexit = state.enter(`title${suffix}`);
10120
10524
  value += tracker.move(" " + quote);
10121
- value += tracker.move(state.safe(node.title, {
10525
+ value += tracker.move(state.safe(title, {
10122
10526
  before: value,
10123
10527
  after: quote,
10124
10528
  ...tracker.current()
@@ -10336,7 +10740,8 @@ function checkStrong(state) {
10336
10740
  // ../../node_modules/mdast-util-to-markdown/lib/handle/strong.js
10337
10741
  function strong(node, _, state, info) {
10338
10742
  const exit = state.enter("phrasing");
10339
- const value = state.containerPhrasing({ type: "root", children: [node] }, info);
10743
+ const item = attentionItem(node, attention3, state, state.createTracker(info));
10744
+ const value = serialize([item], info.before, info.after);
10340
10745
  exit();
10341
10746
  return value;
10342
10747
  }
@@ -10352,6 +10757,7 @@ function peek2(_, _1, state) {
10352
10757
  return state.options.strong || "*";
10353
10758
  }
10354
10759
  var init_strong = __esm(() => {
10760
+ init_container_phrasing();
10355
10761
  strong.attention = attention3;
10356
10762
  strong.peek = peek2;
10357
10763
  });
@@ -10359,7 +10765,7 @@ var init_strong = __esm(() => {
10359
10765
  // ../../node_modules/mdast-util-to-markdown/lib/handle/text.js
10360
10766
  function text3(node, parent, state, info) {
10361
10767
  const siblings = parent ? parent.children : [];
10362
- const index = siblings.indexOf(node);
10768
+ const index = state.indexStack[state.indexStack.length - 1];
10363
10769
  return state.safe(node.value, {
10364
10770
  ...info,
10365
10771
  afterNode: siblings[index + 1],
@@ -10426,63 +10832,44 @@ var init_handle = __esm(() => {
10426
10832
  };
10427
10833
  });
10428
10834
 
10429
- // ../../node_modules/mdast-util-to-markdown/lib/util/html-kind.js
10430
- function htmlKind(value) {
10431
- if (value.charCodeAt(0) !== 60)
10432
- return;
10433
- const next = value.charCodeAt(1);
10434
- if (next === 33) {
10435
- const code = value.charCodeAt(2);
10436
- if (code === 45)
10437
- return 2;
10438
- if (code === 91)
10439
- return 5;
10440
- if (asciiAlpha(code))
10441
- return 4;
10442
- return;
10443
- }
10444
- if (next === 63)
10445
- return 3;
10446
- const closing = next === 47;
10447
- const start = closing ? 2 : 1;
10448
- let end = start;
10449
- let code = value.charCodeAt(end);
10450
- if (!asciiAlpha(code))
10451
- return;
10452
- while (code === 45 || asciiAlphanumeric(code)) {
10453
- code = value.charCodeAt(++end);
10454
- }
10455
- const name = value.slice(start, end).toLowerCase();
10456
- if (!closing && code !== 47 && htmlRawNames.includes(name)) {
10457
- return 1;
10458
- }
10459
- return htmlBlockNames.includes(name) ? 6 : 7;
10460
- }
10461
- var init_html_kind = __esm(() => {
10462
- init_dev4();
10463
- init_micromark_util_html_tag_name();
10464
- });
10465
-
10466
10835
  // ../../node_modules/mdast-util-to-markdown/lib/join.js
10467
10836
  function joinDefaults(left, right, parent, state) {
10468
10837
  if (right.type === "code" && formatCodeAsIndented(right, state) && (left.type === "list" || left.type === right.type && formatCodeAsIndented(left, state))) {
10469
10838
  return false;
10470
10839
  }
10471
10840
  if ("spread" in parent && typeof parent.spread === "boolean") {
10472
- if (left.type === "paragraph" && (left.type === right.type || right.type === "definition" || right.type === "heading" && formatHeadingAsSetext(right, state))) {
10473
- return;
10474
- }
10841
+ if (parent.spread)
10842
+ return 1;
10475
10843
  if (left.type === "html") {
10476
10844
  const kind = htmlKind(left.value);
10477
10845
  if (kind === undefined || kind === 6 || kind === 7)
10478
10846
  return 1;
10479
10847
  }
10480
- if (left.type === "paragraph" && right.type === "html") {
10848
+ if (left.type === "blockquote" && right.type === "blockquote")
10849
+ return 1;
10850
+ if ((left.type === "definition" || left.type === "paragraph") && right.type === "list" && (right.ordered && typeof right.start === "number" && right.start !== 1 || right.children.length > 0 && right.children[0].children.length === 0)) {
10851
+ return 1;
10852
+ }
10853
+ if (left.type === "paragraph" && right.type === "thematicBreak" && checkRule(state) === "-" && !state.options.ruleSpaces) {
10854
+ return 1;
10855
+ }
10856
+ let tail = left;
10857
+ while ((tail.type === "blockquote" || tail.type === "list" || tail.type === "listItem") && tail.children.length > 0) {
10858
+ tail = tail.children[tail.children.length - 1];
10859
+ }
10860
+ if (tail.type !== "definition" && tail.type !== "paragraph")
10861
+ return 0;
10862
+ if (right.type === "code" && formatCodeAsIndented(right, state))
10863
+ return 1;
10864
+ if (right.type === "html") {
10481
10865
  const kind = htmlKind(right.value);
10482
10866
  if (kind === undefined || kind === 7)
10483
10867
  return 1;
10484
10868
  }
10485
- return parent.spread ? 1 : 0;
10869
+ if ((left.type === "paragraph" || left !== tail) && (right.type === "definition" || right.type === "heading" && formatHeadingAsSetext(right, state) || right.type === "paragraph")) {
10870
+ return 1;
10871
+ }
10872
+ return 0;
10486
10873
  }
10487
10874
  }
10488
10875
  var join;
@@ -10555,7 +10942,21 @@ var init_unsafe = __esm(() => {
10555
10942
  { atBreak: true, character: "#" },
10556
10943
  { character: "#", inConstruct: "headingAtx", after: `(?:[\r
10557
10944
  ]|$)` },
10558
- { character: "&", after: "[#A-Za-z]", inConstruct: "phrasing" },
10945
+ {
10946
+ character: "&",
10947
+ after: "[#A-Za-z]",
10948
+ inConstruct: [
10949
+ "codeFencedLangGraveAccent",
10950
+ "codeFencedLangTilde",
10951
+ "codeFencedMetaGraveAccent",
10952
+ "codeFencedMetaTilde",
10953
+ "destinationLiteral",
10954
+ "destinationRaw",
10955
+ "phrasing",
10956
+ "titleApostrophe",
10957
+ "titleQuote"
10958
+ ]
10959
+ },
10559
10960
  { character: "'", inConstruct: "titleApostrophe" },
10560
10961
  { character: "(", inConstruct: "destinationRaw" },
10561
10962
  {
@@ -10629,333 +11030,6 @@ function compilePattern(pattern) {
10629
11030
  return pattern._compiled;
10630
11031
  }
10631
11032
 
10632
- // ../../node_modules/mdast-util-to-markdown/lib/util/character.js
10633
- function firstCharacter(value) {
10634
- const code = value.codePointAt(0);
10635
- return code === undefined ? "" : String.fromCodePoint(code);
10636
- }
10637
- function lastCharacter(value) {
10638
- const code = value.codePointAt(value.length - 2);
10639
- return code !== undefined && code > 65535 ? value.slice(-2) : value.slice(-1);
10640
- }
10641
-
10642
- // ../../node_modules/mdast-util-to-markdown/lib/util/encode-info.js
10643
- function encodeInfo(outside, inside, marker) {
10644
- const outsideKind = classifyCharacter(outside);
10645
- const insideKind = classifyCharacter(inside);
10646
- if (outsideKind === undefined) {
10647
- return insideKind === undefined ? marker === "_" ? { inside: true, outside: true } : { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: true } : { inside: false, outside: true };
10648
- }
10649
- if (outsideKind === 1) {
10650
- return insideKind === undefined ? { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: true } : { inside: false, outside: false };
10651
- }
10652
- return insideKind === undefined ? { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: false } : { inside: false, outside: false };
10653
- }
10654
- var init_encode_info = __esm(() => {
10655
- init_dev6();
10656
- });
10657
-
10658
- // ../../node_modules/mdast-util-to-markdown/lib/util/container-phrasing.js
10659
- function candidates(tokens, involved, runOf) {
10660
- const related = new Set;
10661
- for (const token of tokens) {
10662
- const siblings = runOf.get(token);
10663
- if (siblings && token.attention && involved.some((d) => d.attention === token.attention)) {
10664
- for (const sibling of siblings.tokens) {
10665
- related.add(sibling.attention);
10666
- }
10667
- }
10668
- }
10669
- const ordered = [];
10670
- for (const token of tokens) {
10671
- if (token.attention && related.delete(token.attention)) {
10672
- ordered.push(token.attention);
10673
- }
10674
- }
10675
- ordered.reverse();
10676
- return ordered;
10677
- }
10678
- function check(tokens, before, after) {
10679
- const runs = [];
10680
- const wrong = new Map;
10681
- const runOf = new Map;
10682
- let index = 0;
10683
- while (index < tokens.length) {
10684
- if (!tokens[index].attention) {
10685
- index++;
10686
- continue;
10687
- }
10688
- const marker = tokens[index].value.charAt(0);
10689
- const strict = builtins.get(marker);
10690
- let end = index + 1;
10691
- while (end < tokens.length && tokens[end].attention && tokens[end].value.charAt(0) === marker) {
10692
- end++;
10693
- }
10694
- const head = index ? tokens[index - 1].value : before;
10695
- const previous = classifyCharacter(head.charCodeAt(head.length - 1));
10696
- const next = classifyCharacter((end < tokens.length ? tokens[end].value : after).charCodeAt(0));
10697
- const open = !next || next === 2 && Boolean(previous);
10698
- const close = !previous || previous === 2 && Boolean(next);
10699
- const run = {
10700
- tokens: tokens.slice(index, end),
10701
- markers: [],
10702
- start: 0,
10703
- end: 0,
10704
- open: strict ? open && (Boolean(previous) || !close) : open,
10705
- close: strict ? close && (Boolean(next) || !open) : close,
10706
- split: strict !== undefined
10707
- };
10708
- for (const token of run.tokens) {
10709
- wrong.set(token, [...run.tokens]);
10710
- runOf.set(token, run);
10711
- let size = token.value.length;
10712
- while (size--)
10713
- run.markers.push(token);
10714
- }
10715
- run.end = run.markers.length;
10716
- runs.push(run);
10717
- index = end;
10718
- }
10719
- pair(runs, wrong);
10720
- index = -1;
10721
- while (++index < tokens.length) {
10722
- const involved = wrong.get(tokens[index]);
10723
- if (involved)
10724
- return { attention: candidates(tokens, involved, runOf), index };
10725
- }
10726
- }
10727
- function containerPhrasing(parent, state, info) {
10728
- return serialize(phrasing2(parent, state, info), info.before, info.after);
10729
- }
10730
- function encode(tokens, start) {
10731
- const token = tokens[start ? 0 : tokens.length - 1];
10732
- if (!token || token.attention)
10733
- return;
10734
- const character = start ? firstCharacter(token.value) : lastCharacter(token.value);
10735
- const reference = encodeCharacterReference(character.codePointAt(0));
10736
- token.value = start ? reference + token.value.slice(character.length) : token.value.slice(0, token.value.length - character.length) + reference;
10737
- }
10738
- function improve(items, chosen, mistake, before, after) {
10739
- for (const attention of mistake.attention) {
10740
- const current = chosen.get(attention) || attention.sequences[0];
10741
- for (const sequence of attention.sequences) {
10742
- if (sequence === current)
10743
- continue;
10744
- const trial = new Map(chosen);
10745
- trial.set(attention, sequence);
10746
- const tokens = render(items, trial, before, after);
10747
- const next = check(tokens, before, after);
10748
- if (!next || next.index > mistake.index) {
10749
- return { chosen: trial, mistake: next, tokens };
10750
- }
10751
- }
10752
- }
10753
- }
10754
- function pair(runs, wrong) {
10755
- let index = 0;
10756
- while (index < runs.length) {
10757
- const closer = runs[index];
10758
- const marker = closer.tokens[0].value.charAt(0);
10759
- const closerSize = closer.end - closer.start;
10760
- let open = closer.close && closerSize ? index : 0;
10761
- while (open--) {
10762
- const opener = runs[open];
10763
- const openerSize = opener.end - opener.start;
10764
- if (opener.tokens[0].value.charAt(0) === marker && opener.open && openerSize && (closer.split ? !((opener.close || closer.open) && closerSize % 3) || (openerSize + closerSize) % 3 : openerSize === opener.markers.length && openerSize === closerSize)) {
10765
- const size = closer.split ? openerSize > 1 && closerSize > 1 ? 2 : 1 : closerSize;
10766
- const opening = opener.markers.slice(opener.end - size, opener.end);
10767
- const closing = closer.markers.slice(closer.start, closer.start + size);
10768
- const openToken = opening[0];
10769
- const closeToken = closing[0];
10770
- if (openToken === opening[size - 1] && openToken.value.length === size && closeToken === closing[size - 1] && closeToken.value.length === size && openToken.attention === closeToken.attention) {
10771
- wrong.delete(openToken);
10772
- wrong.delete(closeToken);
10773
- } else {
10774
- const involved = [...new Set([...opening, ...closing])];
10775
- for (const token of involved) {
10776
- const list = wrong.get(token);
10777
- if (list)
10778
- list.push(...involved);
10779
- }
10780
- }
10781
- opener.end -= size;
10782
- closer.start += size;
10783
- break;
10784
- }
10785
- }
10786
- if (open === -1 || closer.start === closer.end)
10787
- index++;
10788
- }
10789
- }
10790
- function attentionSequences(type, markers, sizes) {
10791
- if (markers.length === 0) {
10792
- throw new Error("Cannot serialize `" + type + "` as attention without markers, expected one or more markers");
10793
- }
10794
- if (sizes.length === 0) {
10795
- throw new Error("Cannot serialize `" + type + "` as attention without sizes, expected one or more sizes");
10796
- }
10797
- for (const size of sizes) {
10798
- if (!Number.isSafeInteger(size) || size < 1) {
10799
- throw new Error("Cannot serialize `" + type + "` as attention with `" + size + "` as size, expected positive integer");
10800
- }
10801
- }
10802
- const sequences = [];
10803
- for (const marker of markers) {
10804
- if (marker.length !== 1) {
10805
- throw new Error("Cannot serialize `" + type + "` as attention with `" + marker + "` as marker, expected a single ascii character");
10806
- }
10807
- if (!asciiPunctuation(marker.charCodeAt(0))) {
10808
- throw new Error("Cannot serialize `" + type + "` as attention with `" + marker + "` as marker, expected ascii punctuation");
10809
- }
10810
- for (const size of sizes) {
10811
- sequences.push(marker.repeat(size));
10812
- }
10813
- }
10814
- return sequences;
10815
- }
10816
- function phrasing2(parent, state, info) {
10817
- const indexStack = state.indexStack;
10818
- const children = parent.children || [];
10819
- const results = [];
10820
- let index = -1;
10821
- let before = info.before;
10822
- indexStack.push(-1);
10823
- let tracker = state.createTracker(info);
10824
- while (++index < children.length) {
10825
- const child = children[index];
10826
- let after;
10827
- indexStack[indexStack.length - 1] = index;
10828
- if (index + 1 < children.length) {
10829
- let handle = state.handle.handlers[children[index + 1].type];
10830
- if (handle && handle.peek)
10831
- handle = handle.peek;
10832
- after = handle ? firstCharacter(handle(children[index + 1], parent, state, {
10833
- before: "",
10834
- after: "",
10835
- ...tracker.current()
10836
- })) : "";
10837
- } else {
10838
- after = info.after;
10839
- }
10840
- const previous = results[results.length - 1];
10841
- if (typeof previous === "string" && (before === "\r" || before === `
10842
- `) && child.type === "html" && htmlKind(child.value) !== 7) {
10843
- results[results.length - 1] = previous.replace(/(\r?\n|\r)$/, " ");
10844
- before = " ";
10845
- tracker = state.createTracker(info);
10846
- tracker.move(serialize(results, info.before, info.after));
10847
- }
10848
- const handle = state.handle.handlers[child.type];
10849
- if (handle && handle.attention) {
10850
- const { construct, markers, sizes } = handle.attention(child, state);
10851
- const sequences = attentionSequences(child.type, markers, sizes);
10852
- const sequence = sequences[0];
10853
- const exit = state.enter(construct);
10854
- tracker.move(sequence);
10855
- const inside = phrasing2(child, state, {
10856
- ...tracker.current(),
10857
- before: sequence,
10858
- after: sequence
10859
- });
10860
- tracker.move(serialize(inside, sequence, sequence));
10861
- tracker.move(sequence);
10862
- exit();
10863
- results.push({ children: inside, sequences });
10864
- before = sequence.charAt(sequence.length - 1);
10865
- } else {
10866
- const value = state.handle(child, parent, state, {
10867
- ...tracker.current(),
10868
- after,
10869
- before
10870
- });
10871
- if (!value)
10872
- continue;
10873
- tracker.move(value);
10874
- results.push(value);
10875
- before = lastCharacter(value);
10876
- }
10877
- }
10878
- indexStack.pop();
10879
- return results;
10880
- }
10881
- function render(items, chosen, before, after) {
10882
- const tokens = [];
10883
- let encodeAfter;
10884
- let previous = lastCharacter(before);
10885
- let index = -1;
10886
- while (++index < items.length) {
10887
- const item = items[index];
10888
- if (typeof item === "string") {
10889
- const token = { value: item, attention: undefined };
10890
- if (encodeAfter && encodeAfter === firstCharacter(item)) {
10891
- encode([token], true);
10892
- }
10893
- encodeAfter = undefined;
10894
- tokens.push(token);
10895
- if (token.value)
10896
- previous = lastCharacter(token.value);
10897
- continue;
10898
- }
10899
- const sequence = chosen.get(item) || item.sequences[0];
10900
- const marker = sequence.charAt(0);
10901
- const next = items[index + 1];
10902
- const outsideBefore = previous;
10903
- const outsideAfter = firstCharacter(next === undefined ? after : typeof next === "string" ? next : chosen.get(next) || next.sequences[0]);
10904
- const inside = render(item.children, chosen, sequence, sequence);
10905
- const head = inside.length > 0 ? inside[0].value : "";
10906
- const open = encodeInfo(outsideBefore.charCodeAt(outsideBefore.length - 1), head.charCodeAt(0), marker);
10907
- if (open.inside)
10908
- encode(inside, true);
10909
- const tail = inside.length > 0 ? lastCharacter(inside[inside.length - 1].value) : "";
10910
- const close = encodeInfo(outsideAfter.charCodeAt(0), tail.charCodeAt(tail.length - 1), marker);
10911
- if (close.inside)
10912
- encode(inside, false);
10913
- if (open.outside && outsideBefore !== `
10914
- ` && outsideBefore !== "\r") {
10915
- encode(tokens, false);
10916
- }
10917
- if (close.outside)
10918
- encodeAfter = outsideAfter;
10919
- tokens.push({ value: sequence, attention: item }, ...inside, {
10920
- value: sequence,
10921
- attention: item
10922
- });
10923
- previous = sequence.charAt(sequence.length - 1);
10924
- }
10925
- return tokens;
10926
- }
10927
- function serialize(items, before, after) {
10928
- let chosen = new Map;
10929
- const initial = render(items, chosen, before, after);
10930
- let tokens = initial;
10931
- let mistake = check(tokens, before, after);
10932
- while (mistake) {
10933
- const next = improve(items, chosen, mistake, before, after);
10934
- if (!next) {
10935
- tokens = initial;
10936
- break;
10937
- }
10938
- chosen = next.chosen;
10939
- tokens = next.tokens;
10940
- mistake = next.mistake;
10941
- }
10942
- let result = "";
10943
- for (const token of tokens)
10944
- result += token.value;
10945
- return result;
10946
- }
10947
- var builtins;
10948
- var init_container_phrasing = __esm(() => {
10949
- init_dev4();
10950
- init_dev6();
10951
- init_encode_info();
10952
- init_html_kind();
10953
- builtins = new Map([
10954
- ["*", false],
10955
- ["_", true]
10956
- ]);
10957
- });
10958
-
10959
11033
  // ../../node_modules/mdast-util-to-markdown/lib/util/container-flow.js
10960
11034
  function containerFlow(parent, state, info) {
10961
11035
  const indexStack = state.indexStack;
@@ -11086,22 +11160,20 @@ function safe(state, input, config) {
11086
11160
  continue;
11087
11161
  }
11088
11162
  }
11089
- if (position + 1 < end && positions[index + 1] === position + 1 && infos[position].after && !infos[position + 1].before && !infos[position + 1].after || positions[index - 1] === position - 1 && infos[position].before && !infos[position - 1].before && !infos[position - 1].after) {
11163
+ if (position + 1 < end && positions[index + 1] === position + 1 && infos[position].after && !infos[position + 1].before && !infos[position + 1].after || position - 1 >= offset && positions[index - 1] === position - 1 && infos[position].before && !infos[position - 1].before && !infos[position - 1].after) {
11090
11164
  continue;
11091
11165
  }
11092
11166
  if (start !== position) {
11093
11167
  const slice = value.slice(start, position);
11094
11168
  result.push(percentEncode ? slice : escapeBackslashes(slice, "\\"));
11095
11169
  }
11096
- start = position;
11170
+ start = position + 1;
11097
11171
  if (percentEncode) {
11098
11172
  result.push("%" + value.charCodeAt(position).toString(16).toUpperCase().padStart(2, "0"));
11099
- start++;
11100
11173
  } else if (/[!-/:-@[-`{-~]/.test(value.charAt(position)) && (!config.encode || !config.encode.includes(value.charAt(position)))) {
11101
- result.push("\\");
11174
+ result.push("\\" + value.charAt(position));
11102
11175
  } else {
11103
11176
  result.push(encodeCharacterReference(value.charCodeAt(position)));
11104
- start++;
11105
11177
  }
11106
11178
  }
11107
11179
  const rest = value.slice(start, end);
@@ -12092,84 +12164,9 @@ var init_stringify_entities = __esm(() => {
12092
12164
  init_lib13();
12093
12165
  });
12094
12166
 
12095
- // ../../node_modules/mdast-util-directive/node_modules/unist-util-visit-parents/lib/color.node.js
12096
- function color2(d) {
12097
- return "\x1B[33m" + d + "\x1B[39m";
12098
- }
12099
-
12100
- // ../../node_modules/mdast-util-directive/node_modules/unist-util-visit-parents/lib/index.js
12101
- function visitParents2(tree, test, visitor, reverse) {
12102
- let check;
12103
- if (typeof test === "function" && typeof visitor !== "function") {
12104
- reverse = visitor;
12105
- visitor = test;
12106
- } else {
12107
- check = test;
12108
- }
12109
- const is = convert(check);
12110
- const step = reverse ? -1 : 1;
12111
- factory(tree, undefined, [])();
12112
- function factory(node, index, parents) {
12113
- const value = node && typeof node === "object" ? node : {};
12114
- if (typeof value.type === "string") {
12115
- const name = typeof value.tagName === "string" ? value.tagName : typeof value.name === "string" ? value.name : undefined;
12116
- Object.defineProperty(visit, "name", {
12117
- value: "node (" + color2(node.type + (name ? "<" + name + ">" : "")) + ")"
12118
- });
12119
- }
12120
- return visit;
12121
- function visit() {
12122
- let result = empty2;
12123
- let subresult;
12124
- let offset;
12125
- let grandparents;
12126
- if (!test || is(node, index, parents[parents.length - 1] || undefined)) {
12127
- result = toResult2(visitor(node, parents));
12128
- if (result[0] === EXIT2) {
12129
- return result;
12130
- }
12131
- }
12132
- if ("children" in node && node.children) {
12133
- const nodeAsParent = node;
12134
- if (nodeAsParent.children && result[0] !== SKIP2) {
12135
- offset = (reverse ? nodeAsParent.children.length : -1) + step;
12136
- grandparents = parents.concat(nodeAsParent);
12137
- while (offset > -1 && offset < nodeAsParent.children.length) {
12138
- const child = nodeAsParent.children[offset];
12139
- subresult = factory(child, offset, grandparents)();
12140
- if (subresult[0] === EXIT2) {
12141
- return subresult;
12142
- }
12143
- offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
12144
- }
12145
- }
12146
- }
12147
- return result;
12148
- }
12149
- }
12150
- }
12151
- function toResult2(value) {
12152
- if (Array.isArray(value)) {
12153
- return value;
12154
- }
12155
- if (typeof value === "number") {
12156
- return [CONTINUE2, value];
12157
- }
12158
- return value === null || value === undefined ? empty2 : [value];
12159
- }
12160
- var empty2, CONTINUE2 = true, EXIT2 = false, SKIP2 = "skip";
12161
- var init_lib14 = __esm(() => {
12162
- init_unist_util_is();
12163
- empty2 = [];
12164
- });
12165
-
12166
- // ../../node_modules/mdast-util-directive/node_modules/unist-util-visit-parents/index.js
12167
- var init_unist_util_visit_parents2 = __esm(() => {
12168
- init_lib14();
12169
- });
12170
-
12171
12167
  // ../../node_modules/mdast-util-directive/lib/index.js
12172
- function directiveFromMarkdown() {
12168
+ function directiveFromMarkdown(options) {
12169
+ const settings = options || emptyFromMarkdownOptions;
12173
12170
  return {
12174
12171
  canContainEols: ["textDirective"],
12175
12172
  enter: {
@@ -12183,29 +12180,57 @@ function directiveFromMarkdown() {
12183
12180
  },
12184
12181
  exit: {
12185
12182
  directiveContainer: exit2,
12183
+ directiveContainerAttributeClass: exitAttributeShortcut,
12186
12184
  directiveContainerAttributeClassValue: exitAttributeClassValue,
12185
+ directiveContainerAttributeId: exitAttributeShortcut,
12187
12186
  directiveContainerAttributeIdValue: exitAttributeIdValue,
12188
12187
  directiveContainerAttributeName: exitAttributeName,
12189
12188
  directiveContainerAttributeValue: exitAttributeValue,
12189
+ directiveContainerAttributeValueLiteral: exitAttributeValueLiteral,
12190
12190
  directiveContainerAttributes: exitAttributes,
12191
12191
  directiveContainerLabel: exitContainerLabel,
12192
12192
  directiveContainerName: exitName,
12193
+ directiveContainerSequence: exitSequence,
12193
12194
  directiveLeaf: exit2,
12195
+ directiveLeafAttributeClass: exitAttributeShortcut,
12194
12196
  directiveLeafAttributeClassValue: exitAttributeClassValue,
12197
+ directiveLeafAttributeId: exitAttributeShortcut,
12195
12198
  directiveLeafAttributeIdValue: exitAttributeIdValue,
12196
12199
  directiveLeafAttributeName: exitAttributeName,
12197
12200
  directiveLeafAttributeValue: exitAttributeValue,
12201
+ directiveLeafAttributeValueLiteral: exitAttributeValueLiteral,
12198
12202
  directiveLeafAttributes: exitAttributes,
12203
+ directiveLeafLabel: exitLabel,
12199
12204
  directiveLeafName: exitName,
12205
+ directiveLeafSequence: exitSequence,
12200
12206
  directiveText: exit2,
12207
+ directiveTextAttributeClass: exitAttributeShortcut,
12201
12208
  directiveTextAttributeClassValue: exitAttributeClassValue,
12209
+ directiveTextAttributeId: exitAttributeShortcut,
12202
12210
  directiveTextAttributeIdValue: exitAttributeIdValue,
12203
12211
  directiveTextAttributeName: exitAttributeName,
12204
12212
  directiveTextAttributeValue: exitAttributeValue,
12213
+ directiveTextAttributeValueLiteral: exitAttributeValueLiteral,
12205
12214
  directiveTextAttributes: exitAttributes,
12215
+ directiveTextLabel: exitLabel,
12216
+ directiveTextMarker: exitSequence,
12206
12217
  directiveTextName: exitName
12207
12218
  }
12208
12219
  };
12220
+ function exitSequence(token) {
12221
+ if (!settings.verbose)
12222
+ return;
12223
+ const node = this.stack[this.stack.length - 1];
12224
+ ok(node, "expected `node`");
12225
+ ok(node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective");
12226
+ const place = { start: point3(token.start), end: point3(token.end) };
12227
+ if (node.data && node.data.position) {
12228
+ ok(node.type === "containerDirective");
12229
+ node.data.position.closing = place;
12230
+ } else {
12231
+ node.data = { position: { opening: place } };
12232
+ }
12233
+ }
12209
12234
  }
12210
12235
  function directiveToMarkdown(options) {
12211
12236
  const settings = options || emptyOptions2;
@@ -12242,8 +12267,20 @@ function directiveToMarkdown(options) {
12242
12267
  };
12243
12268
  function handleDirective(node, _, state, info) {
12244
12269
  const tracker = state.createTracker(info);
12245
- const sequence = fence(node);
12246
12270
  const exit = state.enter(node.type);
12271
+ let content;
12272
+ if (node.type === "containerDirective") {
12273
+ const head = (node.children || [])[0];
12274
+ const children = inlineDirectiveLabel(head) ? node.children.slice(1) : node.children;
12275
+ if (children && children.length > 0) {
12276
+ const current = tracker.current();
12277
+ content = state.containerFlow({ ...node, children }, {
12278
+ now: { line: current.now.line + 1, column: 1 + current.lineShift },
12279
+ lineShift: current.lineShift
12280
+ });
12281
+ }
12282
+ }
12283
+ const sequence = fence(node, content ? longestColonLine(content) : 0);
12247
12284
  let value = tracker.move(sequence + (node.name || ""));
12248
12285
  const attributesValue = attributes(node, state);
12249
12286
  const after = info.after.charCodeAt(0);
@@ -12272,15 +12309,9 @@ function directiveToMarkdown(options) {
12272
12309
  }
12273
12310
  value += tracker.move(attributesValue || (after === 123 ? "{}" : ""));
12274
12311
  if (node.type === "containerDirective") {
12275
- const head = (node.children || [])[0];
12276
- let shallow = node;
12277
- if (inlineDirectiveLabel(head)) {
12278
- shallow = Object.assign({}, node, { children: node.children.slice(1) });
12279
- }
12280
- if (shallow && shallow.children && shallow.children.length > 0) {
12312
+ if (content) {
12281
12313
  value += tracker.move(`
12282
- `);
12283
- value += tracker.move(state.containerFlow(shallow, tracker.current()));
12314
+ ` + content);
12284
12315
  }
12285
12316
  value += tracker.move(`
12286
12317
  ` + sequence);
@@ -12297,16 +12328,15 @@ function directiveToMarkdown(options) {
12297
12328
  let key;
12298
12329
  for (key in attributes) {
12299
12330
  if (own8.call(attributes, key) && attributes[key] !== undefined && attributes[key] !== null) {
12300
- const value = String(attributes[key]);
12331
+ const value = encode2(String(attributes[key]));
12301
12332
  if (key === "id") {
12302
12333
  id = settings.preferShortcut !== false && shortcut.test(value) ? "#" + value : quoted("id", value, node, state);
12303
12334
  } else if (key === "class") {
12304
12335
  const list = value.split(/[\t\n\r ]+/);
12305
12336
  const classesFullList = [];
12306
12337
  const classesList = [];
12307
- let index = -1;
12308
- while (++index < list.length) {
12309
- (settings.preferShortcut !== false && shortcut.test(list[index]) ? classesList : classesFullList).push(list[index]);
12338
+ for (const item of list) {
12339
+ (settings.preferShortcut !== false && shortcut.test(item) ? classesList : classesFullList).push(item);
12310
12340
  }
12311
12341
  classesFull = classesFullList.length > 0 ? quoted("class", classesFullList.join(" "), node, state) : "";
12312
12342
  classes = classesList.length > 0 ? "." + classesList.join(".") : "";
@@ -12354,19 +12384,50 @@ function enter(type, token) {
12354
12384
  }
12355
12385
  function exitName(token) {
12356
12386
  const node = this.stack[this.stack.length - 1];
12387
+ ok(node, "expected `node`");
12357
12388
  ok(node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective");
12358
12389
  node.name = this.sliceSerialize(token);
12390
+ openingEnd(node, token);
12359
12391
  }
12360
12392
  function enterContainerLabel(token) {
12361
12393
  this.enter({ type: "paragraph", data: { directiveLabel: true }, children: [] }, token);
12362
12394
  }
12363
12395
  function exitContainerLabel(token) {
12364
12396
  this.exit(token);
12397
+ const node = this.stack[this.stack.length - 1];
12398
+ ok(node, "expected `node`");
12399
+ ok(node.type === "containerDirective");
12400
+ openingEnd(node, token);
12401
+ }
12402
+ function exitLabel(token) {
12403
+ const node = this.stack[this.stack.length - 1];
12404
+ ok(node, "expected `node`");
12405
+ ok(node.type === "leafDirective" || node.type === "textDirective");
12406
+ openingEnd(node, token);
12365
12407
  }
12366
12408
  function enterAttributes() {
12409
+ const node = this.stack[this.stack.length - 1];
12410
+ ok(node, "expected `node`");
12411
+ ok(node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective");
12412
+ if (node.data && node.data.position) {
12413
+ this.data.directiveAttributePositions = {};
12414
+ }
12367
12415
  this.data.directiveAttributes = [];
12368
12416
  this.buffer();
12369
12417
  }
12418
+ function exitAttributeShortcut(token) {
12419
+ const positions = this.data.directiveAttributePositions;
12420
+ if (positions) {
12421
+ const list = this.data.directiveAttributes;
12422
+ ok(list, "expected `directiveAttributes`");
12423
+ const tail = list[list.length - 1];
12424
+ ok(tail, "expected attribute");
12425
+ positions[tail[0]] = { start: point3(token.start), end: point3(token.end) };
12426
+ }
12427
+ }
12428
+ function exitAttributeValueLiteral(token) {
12429
+ attributeEnd(this, token);
12430
+ }
12370
12431
  function exitAttributeIdValue(token) {
12371
12432
  const list = this.data.directiveAttributes;
12372
12433
  ok(list, "expected `directiveAttributes`");
@@ -12386,33 +12447,67 @@ function exitAttributeClassValue(token) {
12386
12447
  function exitAttributeValue(token) {
12387
12448
  const list = this.data.directiveAttributes;
12388
12449
  ok(list, "expected `directiveAttributes`");
12389
- list[list.length - 1][1] = parseEntities(this.sliceSerialize(token), {
12390
- attribute: true
12391
- });
12450
+ const tail = list[list.length - 1];
12451
+ ok(tail, "expected attribute");
12452
+ tail[1] = parseEntities(this.sliceSerialize(token), { attribute: true });
12453
+ attributeEnd(this, token);
12392
12454
  }
12393
12455
  function exitAttributeName(token) {
12394
12456
  const list = this.data.directiveAttributes;
12395
12457
  ok(list, "expected `directiveAttributes`");
12396
- list.push([this.sliceSerialize(token), ""]);
12458
+ const name = this.sliceSerialize(token);
12459
+ list.push([name, ""]);
12460
+ const positions = this.data.directiveAttributePositions;
12461
+ if (positions) {
12462
+ positions[name] = { start: point3(token.start), end: point3(token.end) };
12463
+ }
12397
12464
  }
12398
- function exitAttributes() {
12465
+ function exitAttributes(token) {
12399
12466
  const list = this.data.directiveAttributes;
12400
12467
  ok(list, "expected `directiveAttributes`");
12401
12468
  const cleaned = {};
12402
- let index = -1;
12403
- while (++index < list.length) {
12404
- const attribute = list[index];
12469
+ for (const attribute of list) {
12405
12470
  if (attribute[0] === "class" && cleaned.class) {
12406
12471
  cleaned.class += " " + attribute[1];
12407
12472
  } else {
12408
12473
  cleaned[attribute[0]] = attribute[1];
12409
12474
  }
12410
12475
  }
12476
+ const positions = this.data.directiveAttributePositions;
12477
+ this.data.directiveAttributePositions = undefined;
12411
12478
  this.data.directiveAttributes = undefined;
12412
12479
  this.resume();
12413
12480
  const node = this.stack[this.stack.length - 1];
12481
+ ok(node, "expected `node`");
12414
12482
  ok(node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective");
12415
12483
  node.attributes = cleaned;
12484
+ if (positions) {
12485
+ ok(node.data && node.data.position, "expected `position`");
12486
+ node.data.position.attributes = positions;
12487
+ }
12488
+ openingEnd(node, token);
12489
+ }
12490
+ function openingEnd(node, token) {
12491
+ if (node.data && node.data.position) {
12492
+ const { opening } = node.data.position;
12493
+ ok(opening, "expected `opening`");
12494
+ opening.end = point3(token.end);
12495
+ }
12496
+ }
12497
+ function attributeEnd(context, token) {
12498
+ const positions = context.data.directiveAttributePositions;
12499
+ if (positions) {
12500
+ const list = context.data.directiveAttributes;
12501
+ ok(list, "expected `directiveAttributes`");
12502
+ const tail = list[list.length - 1];
12503
+ ok(tail, "expected attribute");
12504
+ const position = positions[tail[0]];
12505
+ ok(position, "expected position");
12506
+ position.end = point3(token.end);
12507
+ }
12508
+ }
12509
+ function point3(d) {
12510
+ return { line: d.line, column: d.column, offset: d.offset };
12416
12511
  }
12417
12512
  function exit2(token) {
12418
12513
  this.exit(token);
@@ -12420,26 +12515,28 @@ function exit2(token) {
12420
12515
  function peekDirective() {
12421
12516
  return ":";
12422
12517
  }
12518
+ function encode2(value) {
12519
+ const result = [];
12520
+ let start = 0;
12521
+ let index = value.indexOf("&");
12522
+ while (index !== -1) {
12523
+ const code = value.charCodeAt(index + 1);
12524
+ if (code === 35 || asciiAlpha(code)) {
12525
+ result.push(value.slice(start, index), "&#x26;");
12526
+ start = index + 1;
12527
+ }
12528
+ index = value.indexOf("&", index + 1);
12529
+ }
12530
+ result.push(value.slice(start));
12531
+ return result.join("");
12532
+ }
12423
12533
  function inlineDirectiveLabel(node) {
12424
12534
  return Boolean(node && node.type === "paragraph" && node.data && node.data.directiveLabel);
12425
12535
  }
12426
- function fence(node) {
12536
+ function fence(node, longest) {
12427
12537
  let size = 0;
12428
12538
  if (node.type === "containerDirective") {
12429
- visitParents2(node, function(node, parents) {
12430
- if (node.type === "containerDirective") {
12431
- let index = parents.length;
12432
- let nesting = 0;
12433
- while (index--) {
12434
- if (parents[index].type === "containerDirective") {
12435
- nesting++;
12436
- }
12437
- }
12438
- if (nesting > size)
12439
- size = nesting;
12440
- }
12441
- });
12442
- size += 3;
12539
+ size = Math.max(3, longest + 1);
12443
12540
  } else if (node.type === "leafDirective") {
12444
12541
  size = 2;
12445
12542
  } else {
@@ -12447,14 +12544,40 @@ function fence(node) {
12447
12544
  }
12448
12545
  return ":".repeat(size);
12449
12546
  }
12450
- var own8, emptyOptions2, shortcut, unquoted;
12451
- var init_lib15 = __esm(() => {
12547
+ function longestColonLine(value) {
12548
+ let longest = 0;
12549
+ let index = 0;
12550
+ while (index < value.length) {
12551
+ let size = 0;
12552
+ let code = value.charCodeAt(index);
12553
+ while (code === 9 || code === 32) {
12554
+ code = value.charCodeAt(++index);
12555
+ }
12556
+ while (code === 58) {
12557
+ size++;
12558
+ code = value.charCodeAt(++index);
12559
+ }
12560
+ while (code === 9 || code === 32) {
12561
+ code = value.charCodeAt(++index);
12562
+ }
12563
+ while (!(code === 10 || code === 13 || Number.isNaN(code))) {
12564
+ size = 0;
12565
+ code = value.charCodeAt(++index);
12566
+ }
12567
+ if (size > longest)
12568
+ longest = size;
12569
+ index++;
12570
+ }
12571
+ return longest;
12572
+ }
12573
+ var own8, emptyFromMarkdownOptions, emptyOptions2, shortcut, unquoted;
12574
+ var init_lib14 = __esm(() => {
12452
12575
  init_development();
12453
12576
  init_dev4();
12454
12577
  init_parse_entities();
12455
12578
  init_stringify_entities();
12456
- init_unist_util_visit_parents2();
12457
12579
  own8 = {}.hasOwnProperty;
12580
+ emptyFromMarkdownOptions = {};
12458
12581
  emptyOptions2 = {};
12459
12582
  shortcut = /^[^\t\n\r "#'.<=>`}]+$/;
12460
12583
  unquoted = /^[^\t\n\r "'<=>`}]+$/;
@@ -12462,7 +12585,7 @@ var init_lib15 = __esm(() => {
12462
12585
 
12463
12586
  // ../../node_modules/mdast-util-directive/index.js
12464
12587
  var init_mdast_util_directive = __esm(() => {
12465
- init_lib15();
12588
+ init_lib14();
12466
12589
  });
12467
12590
 
12468
12591
  // ../../node_modules/micromark-extension-directive/dev/lib/factory-attributes.js
@@ -13078,14 +13201,14 @@ function remarkDirective() {
13078
13201
  fromMarkdownExtensions.push(directiveFromMarkdown());
13079
13202
  toMarkdownExtensions.push(directiveToMarkdown());
13080
13203
  }
13081
- var init_lib16 = __esm(() => {
13204
+ var init_lib15 = __esm(() => {
13082
13205
  init_mdast_util_directive();
13083
13206
  init_dev16();
13084
13207
  });
13085
13208
 
13086
13209
  // ../../node_modules/remark-directive/index.js
13087
13210
  var init_remark_directive = __esm(() => {
13088
- init_lib16();
13211
+ init_lib15();
13089
13212
  });
13090
13213
 
13091
13214
  // ../../node_modules/mdast-util-find-and-replace/node_modules/escape-string-regexp/index.js
@@ -13097,79 +13220,113 @@ function escapeStringRegexp(string) {
13097
13220
  }
13098
13221
 
13099
13222
  // ../../node_modules/mdast-util-find-and-replace/node_modules/unist-util-visit-parents/lib/color.node.js
13100
- function color3(d) {
13223
+ function color2(d) {
13101
13224
  return "\x1B[33m" + d + "\x1B[39m";
13102
13225
  }
13103
13226
 
13104
13227
  // ../../node_modules/mdast-util-find-and-replace/node_modules/unist-util-visit-parents/lib/index.js
13105
- function visitParents3(tree, test, visitor, reverse) {
13228
+ function visitParents2(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, reverse) {
13229
+ if (!tree || typeof tree !== "object") {
13230
+ throw new Error("Unexpected value `" + tree + "` for `tree`, expected node");
13231
+ }
13232
+ let preorder = true;
13106
13233
  let check;
13107
- if (typeof test === "function" && typeof visitor !== "function") {
13108
- reverse = visitor;
13109
- visitor = test;
13234
+ let visitors;
13235
+ let enter;
13236
+ let exit;
13237
+ if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
13238
+ check = testOrEnterOrVisitors;
13239
+ visitors = enterOrVisitorsOrReverse;
13240
+ if (reverse)
13241
+ preorder = false;
13110
13242
  } else {
13111
- check = test;
13243
+ visitors = testOrEnterOrVisitors;
13244
+ if (enterOrVisitorsOrReverse)
13245
+ preorder = false;
13246
+ }
13247
+ if (typeof visitors === "function") {
13248
+ enter = visitors;
13249
+ } else if (visitors && typeof visitors === "object") {
13250
+ if (visitors.enter === null || visitors.enter === undefined) {} else if (typeof visitors.enter === "function") {
13251
+ enter = visitors.enter;
13252
+ } else {
13253
+ throw new Error("Unexpected value `" + visitors.enter + "` for `visitors.enter`, expected optional visitor");
13254
+ }
13255
+ if (typeof visitors.exit === "function") {
13256
+ exit = visitors.exit;
13257
+ } else {
13258
+ throw new Error("Unexpected value `" + visitors.exit + "` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)");
13259
+ }
13260
+ } else {
13261
+ throw new Error("Unexpected value `" + visitors + "` for `enter` or `visitors`, expected visitor or object with visitors");
13112
13262
  }
13113
13263
  const is = convert(check);
13114
- const step = reverse ? -1 : 1;
13264
+ const step = preorder ? 1 : -1;
13115
13265
  factory(tree, undefined, [])();
13116
13266
  function factory(node, index, parents) {
13117
13267
  const value = node && typeof node === "object" ? node : {};
13118
13268
  if (typeof value.type === "string") {
13119
13269
  const name = typeof value.tagName === "string" ? value.tagName : typeof value.name === "string" ? value.name : undefined;
13120
13270
  Object.defineProperty(visit, "name", {
13121
- value: "node (" + color3(node.type + (name ? "<" + name + ">" : "")) + ")"
13271
+ value: "node (" + color2(node.type + (name ? "<" + name + ">" : "")) + ")"
13122
13272
  });
13123
13273
  }
13124
13274
  return visit;
13125
13275
  function visit() {
13126
- let result = empty3;
13127
- let subresult;
13128
- let offset;
13129
- let grandparents;
13130
- if (!test || is(node, index, parents[parents.length - 1] || undefined)) {
13131
- result = toResult3(visitor(node, parents));
13132
- if (result[0] === EXIT3) {
13276
+ const matches = !check || is(node, index, parents[parents.length - 1] || undefined);
13277
+ let result = empty2;
13278
+ if (enter && matches) {
13279
+ result = toResult2(enter(node, parents, index));
13280
+ if (result[0] === EXIT2) {
13133
13281
  return result;
13134
13282
  }
13135
13283
  }
13136
13284
  if ("children" in node && node.children) {
13137
13285
  const nodeAsParent = node;
13138
- if (nodeAsParent.children && result[0] !== SKIP3) {
13139
- offset = (reverse ? nodeAsParent.children.length : -1) + step;
13140
- grandparents = parents.concat(nodeAsParent);
13286
+ if (nodeAsParent.children && result[0] !== SKIP2) {
13287
+ let offset = (preorder ? -1 : nodeAsParent.children.length) + step;
13288
+ const grandparents = [...parents, nodeAsParent];
13141
13289
  while (offset > -1 && offset < nodeAsParent.children.length) {
13142
13290
  const child = nodeAsParent.children[offset];
13143
- subresult = factory(child, offset, grandparents)();
13144
- if (subresult[0] === EXIT3) {
13291
+ const subresult = factory(child, offset, grandparents)();
13292
+ if (subresult[0] === EXIT2) {
13145
13293
  return subresult;
13146
13294
  }
13147
13295
  offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
13148
13296
  }
13149
13297
  }
13150
13298
  }
13299
+ if (exit && matches) {
13300
+ const exitResult = toResult2(exit(node, parents, index));
13301
+ if (exitResult[0] === SKIP2) {
13302
+ throw new Error("Unexpected value `" + exitResult[0] + "` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing");
13303
+ }
13304
+ if (exitResult[0] === EXIT2 || typeof exitResult[1] === "number") {
13305
+ return exitResult;
13306
+ }
13307
+ }
13151
13308
  return result;
13152
13309
  }
13153
13310
  }
13154
13311
  }
13155
- function toResult3(value) {
13312
+ function toResult2(value) {
13156
13313
  if (Array.isArray(value)) {
13157
13314
  return value;
13158
13315
  }
13159
13316
  if (typeof value === "number") {
13160
- return [CONTINUE3, value];
13317
+ return [CONTINUE2, value];
13161
13318
  }
13162
- return value === null || value === undefined ? empty3 : [value];
13319
+ return value === null || value === undefined ? empty2 : [value];
13163
13320
  }
13164
- var empty3, CONTINUE3 = true, EXIT3 = false, SKIP3 = "skip";
13165
- var init_lib17 = __esm(() => {
13321
+ var empty2, CONTINUE2 = true, EXIT2 = false, SKIP2 = "skip";
13322
+ var init_lib16 = __esm(() => {
13166
13323
  init_unist_util_is();
13167
- empty3 = [];
13324
+ empty2 = [];
13168
13325
  });
13169
13326
 
13170
13327
  // ../../node_modules/mdast-util-find-and-replace/node_modules/unist-util-visit-parents/index.js
13171
- var init_unist_util_visit_parents3 = __esm(() => {
13172
- init_lib17();
13328
+ var init_unist_util_visit_parents2 = __esm(() => {
13329
+ init_lib16();
13173
13330
  });
13174
13331
 
13175
13332
  // ../../node_modules/mdast-util-find-and-replace/lib/index.js
@@ -13179,30 +13336,20 @@ function findAndReplace(tree, list, options) {
13179
13336
  const pairs = toPairs(list);
13180
13337
  let pairIndex = -1;
13181
13338
  while (++pairIndex < pairs.length) {
13182
- visitParents3(tree, "text", visitor);
13339
+ visitParents2(tree, visitor);
13183
13340
  }
13184
- function visitor(node, parents) {
13185
- let index = -1;
13186
- let grandparent;
13187
- while (++index < parents.length) {
13188
- const parent = parents[index];
13189
- const siblings = grandparent ? grandparent.children : undefined;
13190
- if (ignored(parent, siblings ? siblings.indexOf(parent) : undefined, grandparent)) {
13191
- return;
13192
- }
13193
- grandparent = parent;
13194
- }
13195
- if (grandparent) {
13196
- return handler(node, parents);
13341
+ function visitor(node, parents, index) {
13342
+ if (node.type === "text" && typeof index === "number") {
13343
+ return handler(node, parents, index);
13197
13344
  }
13345
+ if (ignored(node, index, parents[parents.length - 1]))
13346
+ return SKIP2;
13198
13347
  }
13199
- function handler(node, parents) {
13348
+ function handler(node, parents, index) {
13200
13349
  const parent = parents[parents.length - 1];
13201
13350
  const find = pairs[pairIndex][0];
13202
13351
  const replace = pairs[pairIndex][1];
13203
13352
  let start = 0;
13204
- const siblings = parent.children;
13205
- const index = siblings.indexOf(node);
13206
13353
  let change = false;
13207
13354
  let nodes = [];
13208
13355
  find.lastIndex = 0;
@@ -13278,14 +13425,14 @@ function toFunction(replace) {
13278
13425
  return replace;
13279
13426
  };
13280
13427
  }
13281
- var init_lib18 = __esm(() => {
13282
- init_unist_util_visit_parents3();
13428
+ var init_lib17 = __esm(() => {
13429
+ init_unist_util_visit_parents2();
13283
13430
  init_unist_util_is();
13284
13431
  });
13285
13432
 
13286
13433
  // ../../node_modules/mdast-util-find-and-replace/index.js
13287
13434
  var init_mdast_util_find_and_replace = __esm(() => {
13288
- init_lib18();
13435
+ init_lib17();
13289
13436
  });
13290
13437
 
13291
13438
  // ../../node_modules/mdast-util-gfm-autolink-literal/lib/index.js
@@ -13428,7 +13575,7 @@ function previous3(match, email) {
13428
13575
  return (match.index === 0 || unicodeWhitespace(code) || unicodePunctuation(code)) && (!email || code !== 47);
13429
13576
  }
13430
13577
  var inConstruct = "phrasing", notInConstruct;
13431
- var init_lib19 = __esm(() => {
13578
+ var init_lib18 = __esm(() => {
13432
13579
  init_development();
13433
13580
  init_dev4();
13434
13581
  init_mdast_util_find_and_replace();
@@ -13437,7 +13584,7 @@ var init_lib19 = __esm(() => {
13437
13584
 
13438
13585
  // ../../node_modules/mdast-util-gfm-autolink-literal/index.js
13439
13586
  var init_mdast_util_gfm_autolink_literal = __esm(() => {
13440
- init_lib19();
13587
+ init_lib18();
13441
13588
  });
13442
13589
 
13443
13590
  // ../../node_modules/mdast-util-gfm-footnote/lib/index.js
@@ -13535,7 +13682,7 @@ function mapExceptFirst(line, index, blank) {
13535
13682
  function mapAll(line, index, blank) {
13536
13683
  return (blank ? "" : " ") + line;
13537
13684
  }
13538
- var init_lib20 = __esm(() => {
13685
+ var init_lib19 = __esm(() => {
13539
13686
  init_development();
13540
13687
  init_dev3();
13541
13688
  footnoteReference.peek = footnoteReferencePeek;
@@ -13543,7 +13690,7 @@ var init_lib20 = __esm(() => {
13543
13690
 
13544
13691
  // ../../node_modules/mdast-util-gfm-footnote/index.js
13545
13692
  var init_mdast_util_gfm_footnote = __esm(() => {
13546
- init_lib20();
13693
+ init_lib19();
13547
13694
  });
13548
13695
 
13549
13696
  // ../../node_modules/mdast-util-gfm-strikethrough/lib/index.js
@@ -13593,7 +13740,7 @@ function peekDelete() {
13593
13740
  return "~";
13594
13741
  }
13595
13742
  var constructsWithoutStrikethrough;
13596
- var init_lib21 = __esm(() => {
13743
+ var init_lib20 = __esm(() => {
13597
13744
  constructsWithoutStrikethrough = [
13598
13745
  "autolink",
13599
13746
  "destinationLiteral",
@@ -13608,7 +13755,7 @@ var init_lib21 = __esm(() => {
13608
13755
 
13609
13756
  // ../../node_modules/mdast-util-gfm-strikethrough/index.js
13610
13757
  var init_mdast_util_gfm_strikethrough = __esm(() => {
13611
- init_lib21();
13758
+ init_lib20();
13612
13759
  });
13613
13760
 
13614
13761
  // ../../node_modules/markdown-table/index.js
@@ -13884,14 +14031,14 @@ function gfmTableToMarkdown(options) {
13884
14031
  return value;
13885
14032
  }
13886
14033
  }
13887
- var init_lib22 = __esm(() => {
14034
+ var init_lib21 = __esm(() => {
13888
14035
  init_development();
13889
14036
  init_mdast_util_to_markdown();
13890
14037
  });
13891
14038
 
13892
14039
  // ../../node_modules/mdast-util-gfm-table/index.js
13893
14040
  var init_mdast_util_gfm_table = __esm(() => {
13894
- init_lib22();
14041
+ init_lib21();
13895
14042
  });
13896
14043
 
13897
14044
  // ../../node_modules/mdast-util-gfm-task-list-item/lib/index.js
@@ -13966,14 +14113,14 @@ function listItemWithTaskListItem(node, parent, state, info) {
13966
14113
  return $0 + checkbox;
13967
14114
  }
13968
14115
  }
13969
- var init_lib23 = __esm(() => {
14116
+ var init_lib22 = __esm(() => {
13970
14117
  init_development();
13971
14118
  init_mdast_util_to_markdown();
13972
14119
  });
13973
14120
 
13974
14121
  // ../../node_modules/mdast-util-gfm-task-list-item/index.js
13975
14122
  var init_mdast_util_gfm_task_list_item = __esm(() => {
13976
- init_lib23();
14123
+ init_lib22();
13977
14124
  });
13978
14125
 
13979
14126
  // ../../node_modules/mdast-util-gfm/lib/index.js
@@ -13997,7 +14144,7 @@ function gfmToMarkdown(options) {
13997
14144
  ]
13998
14145
  };
13999
14146
  }
14000
- var init_lib24 = __esm(() => {
14147
+ var init_lib23 = __esm(() => {
14001
14148
  init_mdast_util_gfm_autolink_literal();
14002
14149
  init_mdast_util_gfm_footnote();
14003
14150
  init_mdast_util_gfm_strikethrough();
@@ -14007,7 +14154,7 @@ var init_lib24 = __esm(() => {
14007
14154
 
14008
14155
  // ../../node_modules/mdast-util-gfm/index.js
14009
14156
  var init_mdast_util_gfm = __esm(() => {
14010
- init_lib24();
14157
+ init_lib23();
14011
14158
  });
14012
14159
 
14013
14160
  // ../../node_modules/micromark-extension-gfm-autolink-literal/dev/lib/syntax.js
@@ -15313,7 +15460,7 @@ function remarkGfm(options) {
15313
15460
  toMarkdownExtensions.push(gfmToMarkdown(settings));
15314
15461
  }
15315
15462
  var emptyOptions3;
15316
- var init_lib25 = __esm(() => {
15463
+ var init_lib24 = __esm(() => {
15317
15464
  init_mdast_util_gfm();
15318
15465
  init_micromark_extension_gfm();
15319
15466
  emptyOptions3 = {};
@@ -15321,7 +15468,7 @@ var init_lib25 = __esm(() => {
15321
15468
 
15322
15469
  // ../../node_modules/remark-gfm/index.js
15323
15470
  var init_remark_gfm = __esm(() => {
15324
- init_lib25();
15471
+ init_lib24();
15325
15472
  });
15326
15473
 
15327
15474
  // ../../node_modules/yaml/dist/nodes/identity.js
@@ -23572,13 +23719,13 @@ function parseSelector(selector, defaultTagName) {
23572
23719
  };
23573
23720
  }
23574
23721
  var search2;
23575
- var init_lib26 = __esm(() => {
23722
+ var init_lib25 = __esm(() => {
23576
23723
  search2 = /[#.]/g;
23577
23724
  });
23578
23725
 
23579
23726
  // ../../node_modules/hast-util-parse-selector/index.js
23580
23727
  var init_hast_util_parse_selector = __esm(() => {
23581
- init_lib26();
23728
+ init_lib25();
23582
23729
  });
23583
23730
 
23584
23731
  // ../../node_modules/space-separated-tokens/index.js
@@ -23615,7 +23762,7 @@ function createH(schema, defaultTagName, caseSensitive) {
23615
23762
  for (const child of children) {
23616
23763
  addChild(node.children, child);
23617
23764
  }
23618
- if (node.type === "element" && node.tagName === "template") {
23765
+ if (node.type === "element" && node.tagName === "template" && schema.space === "html") {
23619
23766
  node.content = { type: "root", children: node.children };
23620
23767
  node.children = [];
23621
23768
  }
@@ -23650,10 +23797,10 @@ function isChild(value) {
23650
23797
  return false;
23651
23798
  }
23652
23799
  function addProperty(schema, properties, key, value) {
23653
- const info = find(schema, key);
23654
- let result;
23655
23800
  if (value === null || value === undefined)
23656
23801
  return;
23802
+ const info = find(schema, key);
23803
+ let result;
23657
23804
  if (typeof value === "number") {
23658
23805
  if (Number.isNaN(value))
23659
23806
  return;
@@ -23683,7 +23830,8 @@ function addProperty(schema, properties, key, value) {
23683
23830
  result = finalResult;
23684
23831
  }
23685
23832
  if (info.property === "className" && Array.isArray(properties.className)) {
23686
- result = properties.className.concat(result);
23833
+ const add = result;
23834
+ result = [...properties.className, ...Array.isArray(add) ? add : [add]];
23687
23835
  }
23688
23836
  properties[info.property] = result;
23689
23837
  }
@@ -23782,7 +23930,7 @@ var init_svg_case_sensitive_tag_names = __esm(() => {
23782
23930
 
23783
23931
  // ../../node_modules/hastscript/lib/index.js
23784
23932
  var h, s;
23785
- var init_lib27 = __esm(() => {
23933
+ var init_lib26 = __esm(() => {
23786
23934
  init_property_information();
23787
23935
  init_create_h();
23788
23936
  init_svg_case_sensitive_tag_names();
@@ -23792,7 +23940,7 @@ var init_lib27 = __esm(() => {
23792
23940
 
23793
23941
  // ../../node_modules/hastscript/index.js
23794
23942
  var init_hastscript = __esm(() => {
23795
- init_lib27();
23943
+ init_lib26();
23796
23944
  });
23797
23945
 
23798
23946
  // ../../node_modules/vfile-location/lib/index.js
@@ -23932,7 +24080,7 @@ function all2(state, nodes) {
23932
24080
  return results;
23933
24081
  }
23934
24082
  function element(state, node) {
23935
- const schema = state.schema;
24083
+ const { schema } = state;
23936
24084
  state.schema = node.namespaceURI === webNamespaces.svg ? svg2 : html3;
23937
24085
  let index = -1;
23938
24086
  const properties = {};
@@ -23947,15 +24095,20 @@ function element(state, node) {
23947
24095
  const result = x(node.tagName, properties, all2(state, node.childNodes));
23948
24096
  patch(state, node, result);
23949
24097
  if (result.tagName === "template") {
23950
- const reference = node;
23951
- const pos = reference.sourceCodeLocation;
23952
- const startTag = pos && pos.startTag && position2(pos.startTag);
23953
- const endTag = pos && pos.endTag && position2(pos.endTag);
23954
- const content = one2(state, reference.content);
23955
- if (startTag && endTag && state.file) {
23956
- content.position = { start: startTag.end, end: endTag.start };
24098
+ if (node.namespaceURI === webNamespaces.html) {
24099
+ const reference = node;
24100
+ const pos = reference.sourceCodeLocation;
24101
+ const startTag = pos && pos.startTag && position2(pos.startTag);
24102
+ const endTag = pos && pos.endTag && position2(pos.endTag);
24103
+ const content = one2(state, reference.content);
24104
+ if (startTag && endTag && state.file) {
24105
+ content.position = { start: startTag.end, end: endTag.start };
24106
+ }
24107
+ result.content = content;
24108
+ } else if (result.content) {
24109
+ result.children = result.content.children;
24110
+ delete result.content;
23957
24111
  }
23958
- result.content = content;
23959
24112
  }
23960
24113
  state.schema = schema;
23961
24114
  return result;
@@ -23999,23 +24152,23 @@ function createLocation(state, node, location) {
23999
24152
  return result;
24000
24153
  }
24001
24154
  function position2(loc) {
24002
- const start = point3({
24155
+ const start = point4({
24003
24156
  line: loc.startLine,
24004
24157
  column: loc.startCol,
24005
24158
  offset: loc.startOffset
24006
24159
  });
24007
- const end = point3({
24160
+ const end = point4({
24008
24161
  line: loc.endLine,
24009
24162
  column: loc.endCol,
24010
24163
  offset: loc.endOffset
24011
24164
  });
24012
24165
  return start || end ? { start, end } : undefined;
24013
24166
  }
24014
- function point3(point) {
24167
+ function point4(point) {
24015
24168
  return point.line && point.column ? point : undefined;
24016
24169
  }
24017
24170
  var own9, proto;
24018
- var init_lib28 = __esm(() => {
24171
+ var init_lib27 = __esm(() => {
24019
24172
  init_development();
24020
24173
  init_hastscript();
24021
24174
  init_property_information();
@@ -24027,7 +24180,7 @@ var init_lib28 = __esm(() => {
24027
24180
 
24028
24181
  // ../../node_modules/hast-util-from-parse5/index.js
24029
24182
  var init_hast_util_from_parse5 = __esm(() => {
24030
- init_lib28();
24183
+ init_lib27();
24031
24184
  });
24032
24185
 
24033
24186
  // ../../node_modules/parse5/dist/common/unicode.js
@@ -31920,7 +32073,7 @@ function visualizeCharacterCode(charCode) {
31920
32073
  return "0x" + charCode.toString(16).toUpperCase();
31921
32074
  }
31922
32075
  var base = "https://html.spec.whatwg.org/multipage/parsing.html#parse-error-", dashToCamelRe, formatCRe, formatXRe, fatalities, emptyOptions4;
31923
- var init_lib29 = __esm(() => {
32076
+ var init_lib28 = __esm(() => {
31924
32077
  init_development();
31925
32078
  init_hast_util_from_parse5();
31926
32079
  init_dist3();
@@ -31936,24 +32089,24 @@ var init_lib29 = __esm(() => {
31936
32089
 
31937
32090
  // ../../node_modules/hast-util-from-html/index.js
31938
32091
  var init_hast_util_from_html = __esm(() => {
31939
- init_lib29();
32092
+ init_lib28();
31940
32093
  });
31941
32094
 
31942
32095
  // ../../node_modules/hast-util-whitespace/lib/index.js
31943
32096
  function whitespace(thing) {
31944
- return typeof thing === "object" ? thing.type === "text" ? empty4(thing.value) : false : empty4(thing);
32097
+ return typeof thing === "object" ? thing.type === "text" ? empty3(thing.value) : false : empty3(thing);
31945
32098
  }
31946
- function empty4(value) {
32099
+ function empty3(value) {
31947
32100
  return value.replace(re, "") === "";
31948
32101
  }
31949
32102
  var re;
31950
- var init_lib30 = __esm(() => {
32103
+ var init_lib29 = __esm(() => {
31951
32104
  re = /[ \t\n\f\r]/g;
31952
32105
  });
31953
32106
 
31954
32107
  // ../../node_modules/hast-util-whitespace/index.js
31955
32108
  var init_hast_util_whitespace = __esm(() => {
31956
- init_lib30();
32109
+ init_lib29();
31957
32110
  });
31958
32111
 
31959
32112
  // ../../packages/markup/src/html-to-jx.ts
@@ -32438,14 +32591,14 @@ function fence3(matter, prop) {
32438
32591
  function pick2(schema, prop) {
32439
32592
  return typeof schema === "string" ? schema : schema[prop];
32440
32593
  }
32441
- var init_lib31 = __esm(() => {
32594
+ var init_lib30 = __esm(() => {
32442
32595
  init_development();
32443
32596
  init_dev22();
32444
32597
  });
32445
32598
 
32446
32599
  // ../../node_modules/mdast-util-frontmatter/index.js
32447
32600
  var init_mdast_util_frontmatter = __esm(() => {
32448
- init_lib31();
32601
+ init_lib30();
32449
32602
  });
32450
32603
 
32451
32604
  // ../../node_modules/remark-frontmatter/lib/index.js
@@ -32461,14 +32614,14 @@ function remarkFrontmatter(options) {
32461
32614
  toMarkdownExtensions.push(frontmatterToMarkdown(settings));
32462
32615
  }
32463
32616
  var emptyOptions5 = "yaml";
32464
- var init_lib32 = __esm(() => {
32617
+ var init_lib31 = __esm(() => {
32465
32618
  init_mdast_util_frontmatter();
32466
32619
  init_dev22();
32467
32620
  });
32468
32621
 
32469
32622
  // ../../node_modules/remark-frontmatter/index.js
32470
32623
  var init_remark_frontmatter = __esm(() => {
32471
- init_lib32();
32624
+ init_lib31();
32472
32625
  });
32473
32626
 
32474
32627
  // ../../node_modules/unist-util-visit-parents/node_modules/unist-util-is/convert.js
@@ -40814,6 +40967,9 @@ function normalizeAllowlist(allowlist) {
40814
40967
  return allowlist instanceof Set ? allowlist : new Set(allowlist);
40815
40968
  }
40816
40969
  function hasJxProps(el) {
40970
+ if (isTemplateString(el.children)) {
40971
+ return true;
40972
+ }
40817
40973
  for (const key of Object.keys(el)) {
40818
40974
  if (key === "tagName" || key === "children" || key === "textContent" || key === "innerHTML" || key === "attributes") {
40819
40975
  continue;
@@ -41027,7 +41183,7 @@ function collectDirectiveAttrs(el) {
41027
41183
  continue;
41028
41184
  }
41029
41185
  if (key === "children") {
41030
- if (isJsonObject(value)) {
41186
+ if (isJsonObject(value) || isTemplateString(value)) {
41031
41187
  propsObj.children = value;
41032
41188
  }
41033
41189
  continue;