@jxsuite/parser 4.1.2 → 4.2.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.
@@ -17660,16 +17660,43 @@ function color(d) {
17660
17660
  }
17661
17661
 
17662
17662
  // ../../node_modules/mdast-util-find-and-replace/node_modules/unist-util-visit-parents/lib/index.js
17663
- function visitParents(tree, test, visitor, reverse) {
17663
+ function visitParents(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, reverse) {
17664
+ if (!tree || typeof tree !== "object") {
17665
+ throw new Error("Unexpected value `" + tree + "` for `tree`, expected node");
17666
+ }
17667
+ let preorder = true;
17664
17668
  let check;
17665
- if (typeof test === "function" && typeof visitor !== "function") {
17666
- reverse = visitor;
17667
- visitor = test;
17669
+ let visitors;
17670
+ let enter;
17671
+ let exit;
17672
+ if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
17673
+ check = testOrEnterOrVisitors;
17674
+ visitors = enterOrVisitorsOrReverse;
17675
+ if (reverse)
17676
+ preorder = false;
17677
+ } else {
17678
+ visitors = testOrEnterOrVisitors;
17679
+ if (enterOrVisitorsOrReverse)
17680
+ preorder = false;
17681
+ }
17682
+ if (typeof visitors === "function") {
17683
+ enter = visitors;
17684
+ } else if (visitors && typeof visitors === "object") {
17685
+ if (visitors.enter === null || visitors.enter === undefined) {} else if (typeof visitors.enter === "function") {
17686
+ enter = visitors.enter;
17687
+ } else {
17688
+ throw new Error("Unexpected value `" + visitors.enter + "` for `visitors.enter`, expected optional visitor");
17689
+ }
17690
+ if (typeof visitors.exit === "function") {
17691
+ exit = visitors.exit;
17692
+ } else {
17693
+ throw new Error("Unexpected value `" + visitors.exit + "` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)");
17694
+ }
17668
17695
  } else {
17669
- check = test;
17696
+ throw new Error("Unexpected value `" + visitors + "` for `enter` or `visitors`, expected visitor or object with visitors");
17670
17697
  }
17671
17698
  const is = convert(check);
17672
- const step = reverse ? -1 : 1;
17699
+ const step = preorder ? 1 : -1;
17673
17700
  factory(tree, undefined, [])();
17674
17701
  function factory(node, index, parents) {
17675
17702
  const value = node && typeof node === "object" ? node : {};
@@ -17681,12 +17708,10 @@ function visitParents(tree, test, visitor, reverse) {
17681
17708
  }
17682
17709
  return visit;
17683
17710
  function visit() {
17711
+ const matches = !check || is(node, index, parents[parents.length - 1] || undefined);
17684
17712
  let result = empty;
17685
- let subresult;
17686
- let offset;
17687
- let grandparents;
17688
- if (!test || is(node, index, parents[parents.length - 1] || undefined)) {
17689
- result = toResult(visitor(node, parents));
17713
+ if (enter && matches) {
17714
+ result = toResult(enter(node, parents, index));
17690
17715
  if (result[0] === EXIT) {
17691
17716
  return result;
17692
17717
  }
@@ -17694,11 +17719,11 @@ function visitParents(tree, test, visitor, reverse) {
17694
17719
  if ("children" in node && node.children) {
17695
17720
  const nodeAsParent = node;
17696
17721
  if (nodeAsParent.children && result[0] !== SKIP) {
17697
- offset = (reverse ? nodeAsParent.children.length : -1) + step;
17698
- grandparents = parents.concat(nodeAsParent);
17722
+ let offset = (preorder ? -1 : nodeAsParent.children.length) + step;
17723
+ const grandparents = [...parents, nodeAsParent];
17699
17724
  while (offset > -1 && offset < nodeAsParent.children.length) {
17700
17725
  const child = nodeAsParent.children[offset];
17701
- subresult = factory(child, offset, grandparents)();
17726
+ const subresult = factory(child, offset, grandparents)();
17702
17727
  if (subresult[0] === EXIT) {
17703
17728
  return subresult;
17704
17729
  }
@@ -17706,6 +17731,15 @@ function visitParents(tree, test, visitor, reverse) {
17706
17731
  }
17707
17732
  }
17708
17733
  }
17734
+ if (exit && matches) {
17735
+ const exitResult = toResult(exit(node, parents, index));
17736
+ if (exitResult[0] === SKIP) {
17737
+ throw new Error("Unexpected value `" + exitResult[0] + "` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing");
17738
+ }
17739
+ if (exitResult[0] === EXIT || typeof exitResult[1] === "number") {
17740
+ return exitResult;
17741
+ }
17742
+ }
17709
17743
  return result;
17710
17744
  }
17711
17745
  }
@@ -17737,30 +17771,20 @@ function findAndReplace(tree, list, options) {
17737
17771
  const pairs = toPairs(list);
17738
17772
  let pairIndex = -1;
17739
17773
  while (++pairIndex < pairs.length) {
17740
- visitParents(tree, "text", visitor);
17774
+ visitParents(tree, visitor);
17741
17775
  }
17742
- function visitor(node, parents) {
17743
- let index = -1;
17744
- let grandparent;
17745
- while (++index < parents.length) {
17746
- const parent = parents[index];
17747
- const siblings = grandparent ? grandparent.children : undefined;
17748
- if (ignored(parent, siblings ? siblings.indexOf(parent) : undefined, grandparent)) {
17749
- return;
17750
- }
17751
- grandparent = parent;
17752
- }
17753
- if (grandparent) {
17754
- return handler(node, parents);
17776
+ function visitor(node, parents, index) {
17777
+ if (node.type === "text" && typeof index === "number") {
17778
+ return handler(node, parents, index);
17755
17779
  }
17780
+ if (ignored(node, index, parents[parents.length - 1]))
17781
+ return SKIP;
17756
17782
  }
17757
- function handler(node, parents) {
17783
+ function handler(node, parents, index) {
17758
17784
  const parent = parents[parents.length - 1];
17759
17785
  const find = pairs[pairIndex][0];
17760
17786
  const replace = pairs[pairIndex][1];
17761
17787
  let start = 0;
17762
- const siblings = parent.children;
17763
- const index = siblings.indexOf(node);
17764
17788
  let change = false;
17765
17789
  let nodes = [];
17766
17790
  find.lastIndex = 0;
@@ -18609,1279 +18633,1350 @@ function checkEmphasis(state) {
18609
18633
  return marker;
18610
18634
  }
18611
18635
 
18612
- // ../../node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
18613
- function emphasis(node, _, state, info) {
18614
- const exit = state.enter("phrasing");
18615
- const value = state.containerPhrasing({ type: "root", children: [node] }, info);
18616
- exit();
18617
- return value;
18618
- }
18619
- function attention2(_, state) {
18620
- const marker = checkEmphasis(state);
18621
- return {
18622
- construct: "emphasis",
18623
- markers: marker === "*" ? ["*", "_"] : ["_", "*"],
18624
- sizes: [1]
18625
- };
18636
+ // ../../node_modules/mdast-util-to-markdown/lib/util/character.js
18637
+ function firstCharacter(value) {
18638
+ const code = value.codePointAt(0);
18639
+ return code === undefined ? "" : String.fromCodePoint(code);
18626
18640
  }
18627
- function peek(_, _1, state) {
18628
- return state.options.emphasis || "*";
18641
+ function lastCharacter(value) {
18642
+ const code = value.codePointAt(value.length - 2);
18643
+ return code !== undefined && code > 65535 ? value.slice(-2) : value.slice(-1);
18629
18644
  }
18630
- var init_emphasis = __esm(() => {
18631
- emphasis.attention = attention2;
18632
- emphasis.peek = peek;
18633
- });
18634
18645
 
18635
18646
  // ../../node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
18636
18647
  function encodeCharacterReference(code) {
18637
18648
  return "&#x" + code.toString(16).toUpperCase() + ";";
18638
18649
  }
18639
18650
 
18640
- // ../../node_modules/unist-util-visit/node_modules/unist-util-visit-parents/lib/color.node.js
18641
- function color2(d) {
18642
- return "\x1B[33m" + d + "\x1B[39m";
18643
- }
18644
-
18645
- // ../../node_modules/unist-util-visit/node_modules/unist-util-visit-parents/lib/index.js
18646
- function visitParents2(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, reverse) {
18647
- if (!tree || typeof tree !== "object") {
18648
- throw new Error("Unexpected value `" + tree + "` for `tree`, expected node");
18649
- }
18650
- let preorder = true;
18651
- let check;
18652
- let visitors;
18653
- let enter;
18654
- let exit;
18655
- if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
18656
- check = testOrEnterOrVisitors;
18657
- visitors = enterOrVisitorsOrReverse;
18658
- if (reverse)
18659
- preorder = false;
18660
- } else {
18661
- visitors = testOrEnterOrVisitors;
18662
- if (enterOrVisitorsOrReverse)
18663
- preorder = false;
18664
- }
18665
- if (typeof visitors === "function") {
18666
- enter = visitors;
18667
- } else if (visitors && typeof visitors === "object") {
18668
- if (visitors.enter === null || visitors.enter === undefined) {} else if (typeof visitors.enter === "function") {
18669
- enter = visitors.enter;
18670
- } else {
18671
- throw new Error("Unexpected value `" + visitors.enter + "` for `visitors.enter`, expected optional visitor");
18672
- }
18673
- if (typeof visitors.exit === "function") {
18674
- exit = visitors.exit;
18675
- } else {
18676
- throw new Error("Unexpected value `" + visitors.exit + "` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)");
18677
- }
18678
- } else {
18679
- throw new Error("Unexpected value `" + visitors + "` for `enter` or `visitors`, expected visitor or object with visitors");
18680
- }
18681
- const is = convert(check);
18682
- const step = preorder ? 1 : -1;
18683
- factory(tree, undefined, [])();
18684
- function factory(node, index, parents) {
18685
- const value = node && typeof node === "object" ? node : {};
18686
- if (typeof value.type === "string") {
18687
- const name = typeof value.tagName === "string" ? value.tagName : typeof value.name === "string" ? value.name : undefined;
18688
- Object.defineProperty(visit, "name", {
18689
- value: "node (" + color2(node.type + (name ? "<" + name + ">" : "")) + ")"
18690
- });
18691
- }
18692
- return visit;
18693
- function visit() {
18694
- const matches = !check || is(node, index, parents[parents.length - 1] || undefined);
18695
- let result = empty2;
18696
- if (enter && matches) {
18697
- result = toResult2(enter(node, parents, index));
18698
- if (result[0] === EXIT2) {
18699
- return result;
18700
- }
18701
- }
18702
- if ("children" in node && node.children) {
18703
- const nodeAsParent = node;
18704
- if (nodeAsParent.children && result[0] !== SKIP2) {
18705
- let offset = (preorder ? -1 : nodeAsParent.children.length) + step;
18706
- const grandparents = [...parents, nodeAsParent];
18707
- while (offset > -1 && offset < nodeAsParent.children.length) {
18708
- const child = nodeAsParent.children[offset];
18709
- const subresult = factory(child, offset, grandparents)();
18710
- if (subresult[0] === EXIT2) {
18711
- return subresult;
18712
- }
18713
- offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
18714
- }
18715
- }
18716
- }
18717
- if (exit && matches) {
18718
- const exitResult = toResult2(exit(node, parents, index));
18719
- if (exitResult[0] === SKIP2) {
18720
- throw new Error("Unexpected value `" + exitResult[0] + "` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing");
18721
- }
18722
- if (exitResult[0] === EXIT2 || typeof exitResult[1] === "number") {
18723
- return exitResult;
18724
- }
18725
- }
18726
- return result;
18727
- }
18728
- }
18729
- }
18730
- function toResult2(value) {
18731
- if (Array.isArray(value)) {
18732
- return value;
18651
+ // ../../node_modules/mdast-util-to-markdown/lib/util/encode-info.js
18652
+ function encodeInfo(outside, inside, marker) {
18653
+ const outsideKind = classifyCharacter(outside);
18654
+ const insideKind = classifyCharacter(inside);
18655
+ if (outsideKind === undefined) {
18656
+ return insideKind === undefined ? marker === "_" ? { inside: true, outside: true } : { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: true } : { inside: false, outside: true };
18733
18657
  }
18734
- if (typeof value === "number") {
18735
- return [CONTINUE2, value];
18658
+ if (outsideKind === 1) {
18659
+ return insideKind === undefined ? { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: true } : { inside: false, outside: false };
18736
18660
  }
18737
- return value === null || value === undefined ? empty2 : [value];
18661
+ return insideKind === undefined ? { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: false } : { inside: false, outside: false };
18738
18662
  }
18739
- var empty2, CONTINUE2 = true, EXIT2 = false, SKIP2 = "skip";
18740
- var init_lib15 = __esm(() => {
18741
- init_unist_util_is();
18742
- empty2 = [];
18743
- });
18744
-
18745
- // ../../node_modules/unist-util-visit/node_modules/unist-util-visit-parents/index.js
18746
- var init_unist_util_visit_parents2 = __esm(() => {
18747
- init_lib15();
18663
+ var init_encode_info = __esm(() => {
18664
+ init_dev6();
18748
18665
  });
18749
18666
 
18750
- // ../../node_modules/unist-util-visit/lib/index.js
18751
- function visit(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, maybeReverse) {
18752
- let check;
18753
- let visitors;
18754
- let reverse;
18755
- if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
18756
- check = testOrEnterOrVisitors;
18757
- visitors = enterOrVisitorsOrReverse;
18758
- reverse = maybeReverse;
18759
- } else {
18760
- visitors = testOrEnterOrVisitors;
18761
- reverse = enterOrVisitorsOrReverse;
18667
+ // ../../node_modules/mdast-util-to-markdown/lib/util/html-kind.js
18668
+ function htmlKind(value) {
18669
+ if (value.charCodeAt(0) !== 60)
18670
+ return;
18671
+ const next = value.charCodeAt(1);
18672
+ if (next === 33) {
18673
+ const code = value.charCodeAt(2);
18674
+ if (code === 45)
18675
+ return 2;
18676
+ if (code === 91)
18677
+ return 5;
18678
+ if (asciiAlpha(code))
18679
+ return 4;
18680
+ return;
18762
18681
  }
18763
- if (typeof visitors === "function") {
18764
- visitParents2(tree, check, wrap2(visitors), reverse);
18765
- } else {
18766
- visitParents2(tree, check, wrapVisitors(visitors), reverse);
18682
+ if (next === 63)
18683
+ return 3;
18684
+ const closing = next === 47;
18685
+ const start = closing ? 2 : 1;
18686
+ let end = start;
18687
+ let code = value.charCodeAt(end);
18688
+ if (!asciiAlpha(code))
18689
+ return;
18690
+ while (code === 45 || asciiAlphanumeric(code)) {
18691
+ code = value.charCodeAt(++end);
18767
18692
  }
18768
- }
18769
- function wrapVisitors(visitors) {
18770
- if (!visitors || typeof visitors !== "object")
18771
- return visitors;
18772
- return {
18773
- enter: typeof visitors.enter === "function" ? wrap2(visitors.enter) : visitors.enter,
18774
- exit: typeof visitors.exit === "function" ? wrap2(visitors.exit) : visitors.exit
18775
- };
18776
- }
18777
- function wrap2(visitor) {
18778
- return overload;
18779
- function overload(node, parents, index) {
18780
- return visitor(node, index, parents[parents.length - 1]);
18693
+ const name = value.slice(start, end).toLowerCase();
18694
+ if (!closing && code !== 47 && htmlRawNames.includes(name)) {
18695
+ return 1;
18781
18696
  }
18697
+ return htmlBlockNames.includes(name) ? 6 : 7;
18782
18698
  }
18783
- var init_lib16 = __esm(() => {
18784
- init_unist_util_visit_parents2();
18785
- init_unist_util_visit_parents2();
18699
+ var init_html_kind = __esm(() => {
18700
+ init_dev4();
18701
+ init_micromark_util_html_tag_name();
18786
18702
  });
18787
18703
 
18788
- // ../../node_modules/unist-util-visit/index.js
18789
- var init_unist_util_visit = __esm(() => {
18790
- init_lib16();
18791
- });
18792
-
18793
- // ../../node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js
18794
- function formatHeadingAsSetext(node, state) {
18795
- let literalWithBreak = false;
18796
- visit(node, function(node) {
18797
- if ("value" in node && /\r?\n|\r/.test(node.value) || node.type === "break") {
18798
- literalWithBreak = true;
18799
- return EXIT2;
18704
+ // ../../node_modules/mdast-util-to-markdown/lib/util/container-phrasing.js
18705
+ function candidates(tokens, involved, runOf) {
18706
+ const related = new Set;
18707
+ for (const token of tokens) {
18708
+ const siblings = runOf.get(token);
18709
+ if (siblings && token.attention && involved.some((d) => d.attention === token.attention)) {
18710
+ for (const sibling of siblings.tokens) {
18711
+ related.add(sibling.attention);
18712
+ }
18800
18713
  }
18801
- });
18802
- return Boolean((!node.depth || node.depth < 3) && toString(node) && (state.options.setext || literalWithBreak));
18803
- }
18804
- var init_format_heading_as_setext = __esm(() => {
18805
- init_unist_util_visit();
18806
- init_mdast_util_to_string();
18807
- });
18808
-
18809
- // ../../node_modules/mdast-util-to-markdown/lib/handle/heading.js
18810
- function heading(node, _, state, info) {
18811
- const rank = Math.max(Math.min(6, node.depth || 1), 1);
18812
- const tracker = state.createTracker(info);
18813
- if (formatHeadingAsSetext(node, state)) {
18814
- const exit = state.enter("headingSetext");
18815
- const subexit = state.enter("phrasing");
18816
- const value = state.containerPhrasing(node, {
18817
- ...tracker.current(),
18818
- before: `
18819
- `,
18820
- after: `
18821
- `
18822
- });
18823
- subexit();
18824
- exit();
18825
- return value + `
18826
- ` + (rank === 1 ? "=" : "-").repeat(value.length - (Math.max(value.lastIndexOf("\r"), value.lastIndexOf(`
18827
- `)) + 1));
18828
- }
18829
- const sequence = "#".repeat(rank);
18830
- const exit = state.enter("headingAtx");
18831
- const subexit = state.enter("phrasing");
18832
- tracker.move(sequence + " ");
18833
- let value = state.containerPhrasing(node, {
18834
- before: "# ",
18835
- after: `
18836
- `,
18837
- ...tracker.current()
18838
- });
18839
- const head = value.charCodeAt(0);
18840
- if (head === 9 || head === 32) {
18841
- value = encodeCharacterReference(head) + value.slice(1);
18842
18714
  }
18843
- value = value ? sequence + " " + value : sequence;
18844
- if (state.options.closeAtx) {
18845
- value += " " + sequence;
18715
+ const ordered = [];
18716
+ for (const token of tokens) {
18717
+ if (token.attention && related.delete(token.attention)) {
18718
+ ordered.push(token.attention);
18719
+ }
18846
18720
  }
18847
- subexit();
18848
- exit();
18849
- return value;
18850
- }
18851
- var init_heading = __esm(() => {
18852
- init_format_heading_as_setext();
18853
- });
18854
-
18855
- // ../../node_modules/mdast-util-to-markdown/lib/handle/html.js
18856
- function html(node) {
18857
- return node.value || "";
18858
- }
18859
- function htmlPeek() {
18860
- return "<";
18721
+ ordered.reverse();
18722
+ return ordered;
18861
18723
  }
18862
- var init_html = __esm(() => {
18863
- html.peek = htmlPeek;
18864
- });
18865
-
18866
- // ../../node_modules/mdast-util-to-markdown/lib/handle/image.js
18867
- function image(node, _, state, info) {
18868
- const quote = checkQuote(state);
18869
- const suffix = quote === '"' ? "Quote" : "Apostrophe";
18870
- const exit = state.enter("image");
18871
- let subexit = state.enter("label");
18872
- const tracker = state.createTracker(info);
18873
- let value = tracker.move("![");
18874
- value += tracker.move(state.safe(node.alt, { before: value, after: "]", ...tracker.current() }));
18875
- value += tracker.move("](");
18876
- subexit();
18877
- if (!node.url && node.title || /[\0- \u007F]/.test(node.url)) {
18878
- subexit = state.enter("destinationLiteral");
18879
- value += tracker.move("<");
18880
- value += tracker.move(state.safe(node.url, { before: value, after: ">", ...tracker.current() }));
18881
- value += tracker.move(">");
18882
- } else {
18883
- subexit = state.enter("destinationRaw");
18884
- value += tracker.move(state.safe(node.url, {
18885
- before: value,
18886
- after: node.title ? " " : ")",
18887
- ...tracker.current()
18888
- }));
18724
+ function check(tokens, before, after) {
18725
+ const runs = [];
18726
+ const wrong = new Map;
18727
+ const runOf = new Map;
18728
+ let index = 0;
18729
+ while (index < tokens.length) {
18730
+ if (!tokens[index].attention) {
18731
+ index++;
18732
+ continue;
18733
+ }
18734
+ const marker = tokens[index].value.charAt(0);
18735
+ const strict = builtins.get(marker);
18736
+ let end = index + 1;
18737
+ while (end < tokens.length && tokens[end].attention && tokens[end].value.charAt(0) === marker) {
18738
+ end++;
18739
+ }
18740
+ const head = index ? tokens[index - 1].value : before;
18741
+ const previous = classifyCharacter(head.charCodeAt(head.length - 1));
18742
+ const next = classifyCharacter((end < tokens.length ? tokens[end].value : after).charCodeAt(0));
18743
+ const open = !next || next === 2 && Boolean(previous);
18744
+ const close = !previous || previous === 2 && Boolean(next);
18745
+ const run = {
18746
+ tokens: tokens.slice(index, end),
18747
+ markers: [],
18748
+ start: 0,
18749
+ end: 0,
18750
+ open: strict ? open && (Boolean(previous) || !close) : open,
18751
+ close: strict ? close && (Boolean(next) || !open) : close,
18752
+ split: strict !== undefined
18753
+ };
18754
+ for (const token of run.tokens) {
18755
+ wrong.set(token, [...run.tokens]);
18756
+ runOf.set(token, run);
18757
+ let size = token.value.length;
18758
+ while (size--)
18759
+ run.markers.push(token);
18760
+ }
18761
+ run.end = run.markers.length;
18762
+ runs.push(run);
18763
+ index = end;
18889
18764
  }
18890
- subexit();
18891
- if (node.title) {
18892
- subexit = state.enter(`title${suffix}`);
18893
- value += tracker.move(" " + quote);
18894
- value += tracker.move(state.safe(node.title, {
18895
- before: value,
18896
- after: quote,
18897
- ...tracker.current()
18898
- }));
18899
- value += tracker.move(quote);
18900
- subexit();
18765
+ pair(runs, wrong);
18766
+ index = -1;
18767
+ while (++index < tokens.length) {
18768
+ const involved = wrong.get(tokens[index]);
18769
+ if (involved)
18770
+ return { attention: candidates(tokens, involved, runOf), index };
18901
18771
  }
18902
- value += tracker.move(")");
18903
- exit();
18904
- return value;
18905
18772
  }
18906
- function imagePeek() {
18907
- return "!";
18773
+ function containerPhrasing(parent, state, info) {
18774
+ return serialize2(phrasing2(parent, state, info), info.before, info.after);
18908
18775
  }
18909
- var init_image = __esm(() => {
18910
- image.peek = imagePeek;
18911
- });
18912
-
18913
- // ../../node_modules/mdast-util-to-markdown/lib/handle/image-reference.js
18914
- function imageReference(node, _, state, info) {
18915
- const type = node.referenceType;
18916
- const exit = state.enter("imageReference");
18917
- let subexit = state.enter("label");
18918
- const tracker = state.createTracker(info);
18919
- let value = tracker.move("![");
18920
- const alt = state.safe(node.alt, {
18921
- before: value,
18922
- after: "]",
18923
- ...tracker.current()
18924
- });
18925
- value += tracker.move(alt + "][");
18926
- subexit();
18927
- const stack = state.stack;
18928
- state.stack = stack.filter(function(d) {
18929
- return d !== "phrasing";
18930
- });
18931
- subexit = state.enter("reference");
18932
- const reference = state.safe(state.associationId(node), {
18933
- before: value,
18934
- after: "]",
18935
- ...tracker.current()
18936
- });
18937
- subexit();
18938
- state.stack = stack;
18939
- exit();
18940
- if (type === "full" || !alt || alt !== reference) {
18941
- value += tracker.move(reference + "]");
18942
- } else if (type === "shortcut") {
18943
- value = value.slice(0, -1);
18776
+ function encode(tokens, start) {
18777
+ const token = tokens[start ? 0 : tokens.length - 1];
18778
+ if (!token || token.attention)
18779
+ return;
18780
+ const character = start ? firstCharacter(token.value) : lastCharacter(token.value);
18781
+ const reference = encodeCharacterReference(character.codePointAt(0));
18782
+ if (start) {
18783
+ token.value = reference + token.value.slice(character.length);
18944
18784
  } else {
18945
- value += tracker.move("]");
18785
+ let value = token.value.slice(0, token.value.length - character.length);
18786
+ let escapes = 0;
18787
+ while (value.charCodeAt(value.length - 1 - escapes) === 92) {
18788
+ escapes++;
18789
+ }
18790
+ if (escapes % 2)
18791
+ value += "\\";
18792
+ token.value = value + reference;
18946
18793
  }
18947
- return value;
18948
18794
  }
18949
- function imageReferencePeek() {
18950
- return "!";
18795
+ function improve(items, chosen, mistake, before, after) {
18796
+ for (const attention of mistake.attention) {
18797
+ const current = chosen.get(attention) || attention.sequences[0];
18798
+ for (const sequence of attention.sequences) {
18799
+ if (sequence === current)
18800
+ continue;
18801
+ const trial = new Map(chosen);
18802
+ trial.set(attention, sequence);
18803
+ const tokens = render(items, trial, before, after);
18804
+ const next = check(tokens, before, after);
18805
+ if (!next || next.index > mistake.index) {
18806
+ return { chosen: trial, mistake: next, tokens };
18807
+ }
18808
+ }
18809
+ }
18951
18810
  }
18952
- var init_image_reference = __esm(() => {
18953
- imageReference.peek = imageReferencePeek;
18954
- });
18955
-
18956
- // ../../node_modules/mdast-util-to-markdown/lib/handle/inline-code.js
18957
- function inlineCode(node, _, state) {
18958
- let value = node.value || "";
18959
- let sequence = "`";
18960
- let index = -1;
18961
- while (new RegExp("(^|[^`])" + sequence + "([^`]|$)").test(value)) {
18962
- sequence += "`";
18811
+ function pair(runs, wrong) {
18812
+ const openersByMarker = new Map;
18813
+ for (const closer of runs) {
18814
+ const marker = closer.tokens[0].value.charAt(0);
18815
+ let openers = openersByMarker.get(marker);
18816
+ if (!openers) {
18817
+ openers = [];
18818
+ openersByMarker.set(marker, openers);
18819
+ }
18820
+ let open = closer.close ? openers.length : 0;
18821
+ while (open-- && closer.start < closer.end) {
18822
+ const opener = openers[open];
18823
+ const openerSize = opener.end - opener.start;
18824
+ const closerSize = closer.end - closer.start;
18825
+ if (closer.split ? (opener.close || closer.open) && closerSize % 3 && !((openerSize + closerSize) % 3) : openerSize !== opener.markers.length || openerSize !== closerSize) {
18826
+ continue;
18827
+ }
18828
+ const size = closer.split ? openerSize > 1 && closerSize > 1 ? 2 : 1 : closerSize;
18829
+ const opening = opener.markers.slice(opener.end - size, opener.end);
18830
+ const closing = closer.markers.slice(closer.start, closer.start + size);
18831
+ const openToken = opening[0];
18832
+ const closeToken = closing[0];
18833
+ if (openToken === opening[size - 1] && openToken.value.length === size && closeToken === closing[size - 1] && closeToken.value.length === size && openToken.attention === closeToken.attention) {
18834
+ wrong.delete(openToken);
18835
+ wrong.delete(closeToken);
18836
+ } else {
18837
+ const involved = [...new Set([...opening, ...closing])];
18838
+ for (const token of involved) {
18839
+ const list = wrong.get(token);
18840
+ if (list)
18841
+ list.push(...involved);
18842
+ }
18843
+ }
18844
+ opener.end -= size;
18845
+ closer.start += size;
18846
+ if (opener.start === opener.end)
18847
+ openers.splice(open, 1);
18848
+ open = openers.length;
18849
+ }
18850
+ if (closer.open && closer.start < closer.end)
18851
+ openers.push(closer);
18963
18852
  }
18964
- if (/[^\n\r ]/.test(value) && (/^[\n\r ]/.test(value) && /[\n\r ]$/.test(value) || /^`|`$/.test(value))) {
18965
- value = " " + value + " ";
18853
+ }
18854
+ function attentionSequences(type, markers, sizes) {
18855
+ if (markers.length === 0) {
18856
+ throw new Error("Cannot serialize `" + type + "` as attention without markers, expected one or more markers");
18966
18857
  }
18967
- while (++index < state.unsafe.length) {
18968
- const pattern = state.unsafe[index];
18969
- const expression = state.compilePattern(pattern);
18970
- if (!pattern.atBreak)
18971
- continue;
18972
- let match;
18973
- while (match = expression.exec(value)) {
18974
- let position = match.index;
18975
- if (value.charCodeAt(position) === 10 && value.charCodeAt(position - 1) === 13) {
18976
- position--;
18977
- }
18978
- value = value.slice(0, position) + " " + value.slice(match.index + 1);
18858
+ if (sizes.length === 0) {
18859
+ throw new Error("Cannot serialize `" + type + "` as attention without sizes, expected one or more sizes");
18860
+ }
18861
+ for (const size of sizes) {
18862
+ if (!Number.isSafeInteger(size) || size < 1) {
18863
+ throw new Error("Cannot serialize `" + type + "` as attention with `" + size + "` as size, expected positive integer");
18979
18864
  }
18980
18865
  }
18981
- return sequence + value + sequence;
18866
+ const sequences = [];
18867
+ for (const marker of markers) {
18868
+ if (marker.length !== 1) {
18869
+ throw new Error("Cannot serialize `" + type + "` as attention with `" + marker + "` as marker, expected a single ascii character");
18870
+ }
18871
+ if (!asciiPunctuation(marker.charCodeAt(0))) {
18872
+ throw new Error("Cannot serialize `" + type + "` as attention with `" + marker + "` as marker, expected ascii punctuation");
18873
+ }
18874
+ for (const size of sizes) {
18875
+ sequences.push(marker.repeat(size));
18876
+ }
18877
+ }
18878
+ return sequences;
18982
18879
  }
18983
- function inlineCodePeek() {
18984
- return "`";
18880
+ function phrasing2(parent, state, info) {
18881
+ const indexStack = state.indexStack;
18882
+ const children = parent.children || [];
18883
+ const results = [];
18884
+ let index = -1;
18885
+ let before = info.before;
18886
+ indexStack.push(-1);
18887
+ let tracker = state.createTracker(info);
18888
+ while (++index < children.length) {
18889
+ const child = children[index];
18890
+ let after;
18891
+ indexStack[indexStack.length - 1] = index;
18892
+ if (index + 1 < children.length) {
18893
+ let handle = state.handle.handlers[children[index + 1].type];
18894
+ if (handle && handle.peek)
18895
+ handle = handle.peek;
18896
+ after = handle ? firstCharacter(handle(children[index + 1], parent, state, {
18897
+ before: "",
18898
+ after: "",
18899
+ ...tracker.current()
18900
+ })) : "";
18901
+ } else {
18902
+ after = info.after;
18903
+ }
18904
+ const previous = results[results.length - 1];
18905
+ if (typeof previous === "string" && (before === "\r" || before === `
18906
+ `) && child.type === "html" && htmlKind(child.value) !== 7) {
18907
+ results[results.length - 1] = previous.replace(/(\r?\n|\r)$/, " ");
18908
+ before = " ";
18909
+ tracker = state.createTracker(info);
18910
+ tracker.move(serialize2(results, info.before, info.after));
18911
+ }
18912
+ const handle = state.handle.handlers[child.type];
18913
+ if (handle && handle.attention) {
18914
+ const item = attentionItem(child, handle.attention, state, tracker);
18915
+ results.push(item);
18916
+ before = lastCharacter(item.sequences[0]);
18917
+ } else {
18918
+ const value = state.handle(child, parent, state, {
18919
+ ...tracker.current(),
18920
+ after,
18921
+ before
18922
+ });
18923
+ if (!value)
18924
+ continue;
18925
+ tracker.move(value);
18926
+ results.push(value);
18927
+ before = lastCharacter(value);
18928
+ }
18929
+ }
18930
+ indexStack.pop();
18931
+ return results;
18985
18932
  }
18986
- var init_inline_code = __esm(() => {
18987
- inlineCode.peek = inlineCodePeek;
18988
- });
18989
-
18990
- // ../../node_modules/mdast-util-to-markdown/lib/util/format-link-as-autolink.js
18991
- function formatLinkAsAutolink(node, state) {
18992
- const raw = toString(node);
18993
- return Boolean(!state.options.resourceLink && node.url && !node.title && node.children && node.children.length === 1 && node.children[0].type === "text" && (raw === node.url || "mailto:" + raw === node.url) && /^[a-z][+\-.a-z]+:/i.test(node.url) && !/[\0- <>\u007F]/.test(node.url));
18933
+ function attentionItem(node, attention, state, tracker) {
18934
+ const { construct, markers, sizes } = attention(node, state);
18935
+ const sequences = attentionSequences(node.type, markers, sizes);
18936
+ const sequence = sequences[0];
18937
+ const exit = state.enter(construct);
18938
+ tracker.move(sequence);
18939
+ const children = phrasing2(node, state, {
18940
+ ...tracker.current(),
18941
+ before: sequence,
18942
+ after: sequence
18943
+ });
18944
+ tracker.move(serialize2(children, sequence, sequence));
18945
+ tracker.move(sequence);
18946
+ exit();
18947
+ return { children, sequences };
18994
18948
  }
18995
- var init_format_link_as_autolink = __esm(() => {
18996
- init_mdast_util_to_string();
18997
- });
18998
-
18999
- // ../../node_modules/mdast-util-to-markdown/lib/handle/link.js
19000
- function link(node, _, state, info) {
19001
- const quote = checkQuote(state);
19002
- const suffix = quote === '"' ? "Quote" : "Apostrophe";
19003
- const tracker = state.createTracker(info);
19004
- if (formatLinkAsAutolink(node, state)) {
19005
- const stack = state.stack;
19006
- state.stack = stack.filter(function(d) {
19007
- return d !== "phrasing";
18949
+ function render(items, chosen, before, after) {
18950
+ const tokens = [];
18951
+ let encodeAfter;
18952
+ let previous = lastCharacter(before);
18953
+ let index = -1;
18954
+ while (++index < items.length) {
18955
+ const item = items[index];
18956
+ if (typeof item === "string") {
18957
+ const token = { value: item, attention: undefined };
18958
+ if (encodeAfter && encodeAfter === firstCharacter(item)) {
18959
+ encode([token], true);
18960
+ }
18961
+ encodeAfter = undefined;
18962
+ tokens.push(token);
18963
+ if (token.value)
18964
+ previous = lastCharacter(token.value);
18965
+ continue;
18966
+ }
18967
+ const sequence = chosen.get(item) || item.sequences[0];
18968
+ const marker = sequence.charAt(0);
18969
+ const next = items[index + 1];
18970
+ const outsideBefore = previous;
18971
+ const outsideAfter = firstCharacter(next === undefined ? after : typeof next === "string" ? next : chosen.get(next) || next.sequences[0]);
18972
+ const inside = render(item.children, chosen, sequence, sequence);
18973
+ const head = inside.length > 0 ? inside[0].value : "";
18974
+ const open = encodeInfo(outsideBefore.charCodeAt(outsideBefore.length - 1), head.charCodeAt(0), marker);
18975
+ if (open.inside)
18976
+ encode(inside, true);
18977
+ const tail = inside.length > 0 ? lastCharacter(inside[inside.length - 1].value) : "";
18978
+ const close = encodeInfo(outsideAfter.charCodeAt(0), tail.charCodeAt(tail.length - 1), marker);
18979
+ if (close.inside)
18980
+ encode(inside, false);
18981
+ if (open.outside && outsideBefore !== `
18982
+ ` && outsideBefore !== "\r") {
18983
+ encode(tokens, false);
18984
+ }
18985
+ if (close.outside)
18986
+ encodeAfter = outsideAfter;
18987
+ tokens.push({ value: sequence, attention: item }, ...inside, {
18988
+ value: sequence,
18989
+ attention: item
19008
18990
  });
19009
- const exit = state.enter("autolink");
19010
- let value = tracker.move("<");
19011
- value += tracker.move(state.containerPhrasing(node, {
19012
- before: value,
19013
- after: ">",
19014
- ...tracker.current()
19015
- }));
19016
- value += tracker.move(">");
19017
- exit();
19018
- state.stack = stack;
19019
- return value;
19020
- }
19021
- const exit = state.enter("link");
19022
- let subexit = state.enter("label");
19023
- let value = tracker.move("[");
19024
- value += tracker.move(state.containerPhrasing(node, {
19025
- before: value,
19026
- after: "](",
19027
- ...tracker.current()
19028
- }));
19029
- value += tracker.move("](");
19030
- subexit();
19031
- if (!node.url && node.title || /[\0- \u007F]/.test(node.url)) {
19032
- subexit = state.enter("destinationLiteral");
19033
- value += tracker.move("<");
19034
- value += tracker.move(state.safe(node.url, { before: value, after: ">", ...tracker.current() }));
19035
- value += tracker.move(">");
19036
- } else {
19037
- subexit = state.enter("destinationRaw");
19038
- value += tracker.move(state.safe(node.url, {
19039
- before: value,
19040
- after: node.title ? " " : ")",
19041
- ...tracker.current()
19042
- }));
18991
+ previous = sequence.charAt(sequence.length - 1);
19043
18992
  }
19044
- subexit();
19045
- if (node.title) {
19046
- subexit = state.enter(`title${suffix}`);
19047
- value += tracker.move(" " + quote);
19048
- value += tracker.move(state.safe(node.title, {
19049
- before: value,
19050
- after: quote,
19051
- ...tracker.current()
19052
- }));
19053
- value += tracker.move(quote);
19054
- subexit();
18993
+ return tokens;
18994
+ }
18995
+ function serialize2(items, before, after) {
18996
+ let chosen = new Map;
18997
+ const initial = render(items, chosen, before, after);
18998
+ let tokens = initial;
18999
+ let mistake = check(tokens, before, after);
19000
+ while (mistake) {
19001
+ const next = improve(items, chosen, mistake, before, after);
19002
+ if (!next) {
19003
+ tokens = initial;
19004
+ break;
19005
+ }
19006
+ chosen = next.chosen;
19007
+ tokens = next.tokens;
19008
+ mistake = next.mistake;
19055
19009
  }
19056
- value += tracker.move(")");
19010
+ let result = "";
19011
+ for (const token of tokens)
19012
+ result += token.value;
19013
+ return result;
19014
+ }
19015
+ var builtins;
19016
+ var init_container_phrasing = __esm(() => {
19017
+ init_dev4();
19018
+ init_dev6();
19019
+ init_encode_info();
19020
+ init_html_kind();
19021
+ builtins = new Map([
19022
+ ["*", false],
19023
+ ["_", true]
19024
+ ]);
19025
+ });
19026
+
19027
+ // ../../node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
19028
+ function emphasis(node, _, state, info) {
19029
+ const exit = state.enter("phrasing");
19030
+ const item = attentionItem(node, attention2, state, state.createTracker(info));
19031
+ const value = serialize2([item], info.before, info.after);
19057
19032
  exit();
19058
19033
  return value;
19059
19034
  }
19060
- function linkPeek(node, _, state) {
19061
- return formatLinkAsAutolink(node, state) ? "<" : "[";
19035
+ function attention2(_, state) {
19036
+ const marker = checkEmphasis(state);
19037
+ return {
19038
+ construct: "emphasis",
19039
+ markers: marker === "*" ? ["*", "_"] : ["_", "*"],
19040
+ sizes: [1]
19041
+ };
19062
19042
  }
19063
- var init_link = __esm(() => {
19064
- init_format_link_as_autolink();
19065
- link.peek = linkPeek;
19043
+ function peek(_, _1, state) {
19044
+ return state.options.emphasis || "*";
19045
+ }
19046
+ var init_emphasis = __esm(() => {
19047
+ init_container_phrasing();
19048
+ emphasis.attention = attention2;
19049
+ emphasis.peek = peek;
19066
19050
  });
19067
19051
 
19068
- // ../../node_modules/mdast-util-to-markdown/lib/handle/link-reference.js
19069
- function linkReference(node, _, state, info) {
19070
- const type = node.referenceType;
19071
- const exit = state.enter("linkReference");
19072
- let subexit = state.enter("label");
19073
- const tracker = state.createTracker(info);
19074
- let value = tracker.move("[");
19075
- const text = state.containerPhrasing(node, {
19076
- before: value,
19077
- after: "]",
19078
- ...tracker.current()
19079
- });
19080
- value += tracker.move(text + "][");
19081
- subexit();
19082
- const stack = state.stack;
19083
- state.stack = stack.filter(function(d) {
19084
- return d !== "phrasing";
19085
- });
19086
- subexit = state.enter("reference");
19087
- const reference = state.safe(state.associationId(node), {
19088
- before: value,
19089
- after: "]",
19090
- ...tracker.current()
19091
- });
19092
- subexit();
19093
- state.stack = stack;
19094
- exit();
19095
- if (type === "full" || !text || text !== reference) {
19096
- value += tracker.move(reference + "]");
19097
- } else if (type === "shortcut") {
19098
- value = value.slice(0, -1);
19099
- } else {
19100
- value += tracker.move("]");
19101
- }
19102
- return value;
19103
- }
19104
- function linkReferencePeek() {
19105
- return "[";
19106
- }
19107
- var init_link_reference = __esm(() => {
19108
- linkReference.peek = linkReferencePeek;
19109
- });
19110
-
19111
- // ../../node_modules/mdast-util-to-markdown/lib/util/check-bullet.js
19112
- function checkBullet(state) {
19113
- const marker = state.options.bullet || "*";
19114
- if (marker !== "*" && marker !== "+" && marker !== "-") {
19115
- throw new Error("Cannot serialize items with `" + marker + "` for `options.bullet`, expected `*`, `+`, or `-`");
19116
- }
19117
- return marker;
19052
+ // ../../node_modules/unist-util-visit/node_modules/unist-util-visit-parents/lib/color.node.js
19053
+ function color2(d) {
19054
+ return "\x1B[33m" + d + "\x1B[39m";
19118
19055
  }
19119
19056
 
19120
- // ../../node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.js
19121
- function checkBulletOther(state) {
19122
- const bullet = checkBullet(state);
19123
- const bulletOther = state.options.bulletOther;
19124
- if (!bulletOther) {
19125
- return bullet === "*" ? "-" : "*";
19126
- }
19127
- if (bulletOther !== "*" && bulletOther !== "+" && bulletOther !== "-") {
19128
- throw new Error("Cannot serialize items with `" + bulletOther + "` for `options.bulletOther`, expected `*`, `+`, or `-`");
19129
- }
19130
- if (bulletOther === bullet) {
19131
- throw new Error("Expected `bullet` (`" + bullet + "`) and `bulletOther` (`" + bulletOther + "`) to be different");
19057
+ // ../../node_modules/unist-util-visit/node_modules/unist-util-visit-parents/lib/index.js
19058
+ function visitParents2(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, reverse) {
19059
+ if (!tree || typeof tree !== "object") {
19060
+ throw new Error("Unexpected value `" + tree + "` for `tree`, expected node");
19132
19061
  }
19133
- return bulletOther;
19134
- }
19135
- var init_check_bullet_other = () => {};
19136
-
19137
- // ../../node_modules/mdast-util-to-markdown/lib/util/check-bullet-ordered.js
19138
- function checkBulletOrdered(state) {
19139
- const marker = state.options.bulletOrdered || ".";
19140
- if (marker !== "." && marker !== ")") {
19141
- throw new Error("Cannot serialize items with `" + marker + "` for `options.bulletOrdered`, expected `.` or `)`");
19062
+ let preorder = true;
19063
+ let check;
19064
+ let visitors;
19065
+ let enter;
19066
+ let exit;
19067
+ if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
19068
+ check = testOrEnterOrVisitors;
19069
+ visitors = enterOrVisitorsOrReverse;
19070
+ if (reverse)
19071
+ preorder = false;
19072
+ } else {
19073
+ visitors = testOrEnterOrVisitors;
19074
+ if (enterOrVisitorsOrReverse)
19075
+ preorder = false;
19142
19076
  }
19143
- return marker;
19144
- }
19145
-
19146
- // ../../node_modules/mdast-util-to-markdown/lib/util/check-rule.js
19147
- function checkRule(state) {
19148
- const marker = state.options.rule || "*";
19149
- if (marker !== "*" && marker !== "-" && marker !== "_") {
19150
- throw new Error("Cannot serialize rules with `" + marker + "` for `options.rule`, expected `*`, `-`, or `_`");
19077
+ if (typeof visitors === "function") {
19078
+ enter = visitors;
19079
+ } else if (visitors && typeof visitors === "object") {
19080
+ if (visitors.enter === null || visitors.enter === undefined) {} else if (typeof visitors.enter === "function") {
19081
+ enter = visitors.enter;
19082
+ } else {
19083
+ throw new Error("Unexpected value `" + visitors.enter + "` for `visitors.enter`, expected optional visitor");
19084
+ }
19085
+ if (typeof visitors.exit === "function") {
19086
+ exit = visitors.exit;
19087
+ } else {
19088
+ throw new Error("Unexpected value `" + visitors.exit + "` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)");
19089
+ }
19090
+ } else {
19091
+ throw new Error("Unexpected value `" + visitors + "` for `enter` or `visitors`, expected visitor or object with visitors");
19151
19092
  }
19152
- return marker;
19153
- }
19154
-
19155
- // ../../node_modules/mdast-util-to-markdown/lib/handle/list.js
19156
- function list3(node, parent, state, info) {
19157
- const exit = state.enter("list");
19158
- const bulletCurrent = state.bulletCurrent;
19159
- let bullet = node.ordered ? checkBulletOrdered(state) : checkBullet(state);
19160
- const bulletOther = node.ordered ? bullet === "." ? ")" : "." : checkBulletOther(state);
19161
- let useDifferentMarker = parent && state.bulletLastUsed ? bullet === state.bulletLastUsed : false;
19162
- if (!node.ordered) {
19163
- const firstListItem = node.children ? node.children[0] : undefined;
19164
- if ((bullet === "*" || bullet === "-") && firstListItem && (!firstListItem.children || !firstListItem.children[0]) && state.stack[state.stack.length - 1] === "list" && state.stack[state.stack.length - 2] === "listItem" && state.stack[state.stack.length - 3] === "list" && state.stack[state.stack.length - 4] === "listItem" && state.indexStack[state.indexStack.length - 1] === 0 && state.indexStack[state.indexStack.length - 2] === 0 && state.indexStack[state.indexStack.length - 3] === 0) {
19165
- useDifferentMarker = true;
19093
+ const is = convert(check);
19094
+ const step = preorder ? 1 : -1;
19095
+ factory(tree, undefined, [])();
19096
+ function factory(node, index, parents) {
19097
+ const value = node && typeof node === "object" ? node : {};
19098
+ if (typeof value.type === "string") {
19099
+ const name = typeof value.tagName === "string" ? value.tagName : typeof value.name === "string" ? value.name : undefined;
19100
+ Object.defineProperty(visit, "name", {
19101
+ value: "node (" + color2(node.type + (name ? "<" + name + ">" : "")) + ")"
19102
+ });
19166
19103
  }
19167
- if (checkRule(state) === bullet && firstListItem) {
19168
- let index = -1;
19169
- while (++index < node.children.length) {
19170
- const item = node.children[index];
19171
- if (item && item.type === "listItem" && item.children && item.children[0] && item.children[0].type === "thematicBreak") {
19172
- useDifferentMarker = true;
19173
- break;
19104
+ return visit;
19105
+ function visit() {
19106
+ const matches = !check || is(node, index, parents[parents.length - 1] || undefined);
19107
+ let result = empty2;
19108
+ if (enter && matches) {
19109
+ result = toResult2(enter(node, parents, index));
19110
+ if (result[0] === EXIT2) {
19111
+ return result;
19112
+ }
19113
+ }
19114
+ if ("children" in node && node.children) {
19115
+ const nodeAsParent = node;
19116
+ if (nodeAsParent.children && result[0] !== SKIP2) {
19117
+ let offset = (preorder ? -1 : nodeAsParent.children.length) + step;
19118
+ const grandparents = [...parents, nodeAsParent];
19119
+ while (offset > -1 && offset < nodeAsParent.children.length) {
19120
+ const child = nodeAsParent.children[offset];
19121
+ const subresult = factory(child, offset, grandparents)();
19122
+ if (subresult[0] === EXIT2) {
19123
+ return subresult;
19124
+ }
19125
+ offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
19126
+ }
19127
+ }
19128
+ }
19129
+ if (exit && matches) {
19130
+ const exitResult = toResult2(exit(node, parents, index));
19131
+ if (exitResult[0] === SKIP2) {
19132
+ throw new Error("Unexpected value `" + exitResult[0] + "` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing");
19133
+ }
19134
+ if (exitResult[0] === EXIT2 || typeof exitResult[1] === "number") {
19135
+ return exitResult;
19174
19136
  }
19175
19137
  }
19138
+ return result;
19176
19139
  }
19177
19140
  }
19178
- if (useDifferentMarker) {
19179
- bullet = bulletOther;
19141
+ }
19142
+ function toResult2(value) {
19143
+ if (Array.isArray(value)) {
19144
+ return value;
19180
19145
  }
19181
- state.bulletCurrent = bullet;
19182
- const value = state.containerFlow(node, info);
19183
- state.bulletLastUsed = bullet;
19184
- state.bulletCurrent = bulletCurrent;
19185
- exit();
19186
- return value;
19146
+ if (typeof value === "number") {
19147
+ return [CONTINUE2, value];
19148
+ }
19149
+ return value === null || value === undefined ? empty2 : [value];
19187
19150
  }
19188
- var init_list2 = __esm(() => {
19189
- init_check_bullet_other();
19151
+ var empty2, CONTINUE2 = true, EXIT2 = false, SKIP2 = "skip";
19152
+ var init_lib15 = __esm(() => {
19153
+ init_unist_util_is();
19154
+ empty2 = [];
19190
19155
  });
19191
19156
 
19192
- // ../../node_modules/mdast-util-to-markdown/lib/util/check-list-item-indent.js
19193
- function checkListItemIndent(state) {
19194
- const style = state.options.listItemIndent || "one";
19195
- if (style !== "tab" && style !== "one" && style !== "mixed") {
19196
- throw new Error("Cannot serialize items with `" + style + "` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");
19197
- }
19198
- return style;
19199
- }
19157
+ // ../../node_modules/unist-util-visit/node_modules/unist-util-visit-parents/index.js
19158
+ var init_unist_util_visit_parents2 = __esm(() => {
19159
+ init_lib15();
19160
+ });
19200
19161
 
19201
- // ../../node_modules/mdast-util-to-markdown/lib/handle/list-item.js
19202
- function listItem(node, parent, state, info) {
19203
- const listItemIndent = checkListItemIndent(state);
19204
- let bullet = state.bulletCurrent || checkBullet(state);
19205
- if (parent && parent.type === "list" && parent.ordered) {
19206
- bullet = (typeof parent.start === "number" && parent.start > -1 ? parent.start : 1) + (state.options.incrementListMarker === false ? 0 : parent.children.indexOf(node)) + bullet;
19207
- }
19208
- let size = bullet.length + 1;
19209
- if (listItemIndent === "tab" || listItemIndent === "mixed" && (parent && parent.type === "list" && parent.spread || node.spread)) {
19210
- size = Math.ceil(size / 4) * 4;
19162
+ // ../../node_modules/unist-util-visit/lib/index.js
19163
+ function visit(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, maybeReverse) {
19164
+ let check;
19165
+ let visitors;
19166
+ let reverse;
19167
+ if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
19168
+ check = testOrEnterOrVisitors;
19169
+ visitors = enterOrVisitorsOrReverse;
19170
+ reverse = maybeReverse;
19171
+ } else {
19172
+ visitors = testOrEnterOrVisitors;
19173
+ reverse = enterOrVisitorsOrReverse;
19211
19174
  }
19212
- const tracker = state.createTracker(info);
19213
- tracker.move(bullet + " ".repeat(size - bullet.length));
19214
- tracker.shift(size);
19215
- const exit = state.enter("listItem");
19216
- const value = state.indentLines(state.containerFlow(node, tracker.current()), map);
19217
- exit();
19218
- return value;
19219
- function map(line, index, blank) {
19220
- if (index) {
19221
- return (blank ? "" : " ".repeat(size)) + line;
19222
- }
19223
- return (blank ? bullet : bullet + " ".repeat(size - bullet.length)) + line;
19175
+ if (typeof visitors === "function") {
19176
+ visitParents2(tree, check, wrap2(visitors), reverse);
19177
+ } else {
19178
+ visitParents2(tree, check, wrapVisitors(visitors), reverse);
19224
19179
  }
19225
19180
  }
19226
- var init_list_item = () => {};
19227
-
19228
- // ../../node_modules/mdast-util-to-markdown/lib/handle/paragraph.js
19229
- function paragraph(node, _, state, info) {
19230
- const exit = state.enter("paragraph");
19231
- const subexit = state.enter("phrasing");
19232
- const value = state.containerPhrasing(node, info);
19233
- subexit();
19234
- exit();
19235
- return value;
19181
+ function wrapVisitors(visitors) {
19182
+ if (!visitors || typeof visitors !== "object")
19183
+ return visitors;
19184
+ return {
19185
+ enter: typeof visitors.enter === "function" ? wrap2(visitors.enter) : visitors.enter,
19186
+ exit: typeof visitors.exit === "function" ? wrap2(visitors.exit) : visitors.exit
19187
+ };
19188
+ }
19189
+ function wrap2(visitor) {
19190
+ return overload;
19191
+ function overload(node, parents, index) {
19192
+ return visitor(node, index, parents[parents.length - 1]);
19193
+ }
19236
19194
  }
19195
+ var init_lib16 = __esm(() => {
19196
+ init_unist_util_visit_parents2();
19197
+ init_unist_util_visit_parents2();
19198
+ });
19237
19199
 
19238
- // ../../node_modules/mdast-util-to-markdown/lib/handle/root.js
19239
- function root(node, _, state, info) {
19240
- const hasPhrasing = node.children.some(function(d) {
19241
- return phrasing(d);
19200
+ // ../../node_modules/unist-util-visit/index.js
19201
+ var init_unist_util_visit = __esm(() => {
19202
+ init_lib16();
19203
+ });
19204
+
19205
+ // ../../node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js
19206
+ function formatHeadingAsSetext(node, state) {
19207
+ let literalWithBreak = false;
19208
+ visit(node, function(node) {
19209
+ if ("value" in node && /\r?\n|\r/.test(node.value) || node.type === "break") {
19210
+ literalWithBreak = true;
19211
+ return EXIT2;
19212
+ }
19242
19213
  });
19243
- if (!hasPhrasing)
19244
- return state.containerFlow(node, info);
19245
- const exit = state.enter("phrasing");
19246
- const value = state.containerPhrasing(node, info);
19214
+ return Boolean((!node.depth || node.depth < 3) && toString(node) && (state.options.setext || literalWithBreak));
19215
+ }
19216
+ var init_format_heading_as_setext = __esm(() => {
19217
+ init_unist_util_visit();
19218
+ init_mdast_util_to_string();
19219
+ });
19220
+
19221
+ // ../../node_modules/mdast-util-to-markdown/lib/handle/heading.js
19222
+ function heading(node, _, state, info) {
19223
+ const rank = Math.max(Math.min(6, node.depth || 1), 1);
19224
+ const tracker = state.createTracker(info);
19225
+ if (formatHeadingAsSetext(node, state)) {
19226
+ const exit = state.enter("headingSetext");
19227
+ const subexit = state.enter("phrasing");
19228
+ const value = state.containerPhrasing(node, {
19229
+ ...tracker.current(),
19230
+ before: `
19231
+ `,
19232
+ after: `
19233
+ `
19234
+ });
19235
+ subexit();
19236
+ exit();
19237
+ return value + `
19238
+ ` + (rank === 1 ? "=" : "-").repeat(value.length - (Math.max(value.lastIndexOf("\r"), value.lastIndexOf(`
19239
+ `)) + 1));
19240
+ }
19241
+ const sequence = "#".repeat(rank);
19242
+ const exit = state.enter("headingAtx");
19243
+ const subexit = state.enter("phrasing");
19244
+ tracker.move(sequence + " ");
19245
+ let value = state.containerPhrasing(node, {
19246
+ before: "# ",
19247
+ after: `
19248
+ `,
19249
+ ...tracker.current()
19250
+ });
19251
+ const head = value.charCodeAt(0);
19252
+ if (head === 9 || head === 32) {
19253
+ value = encodeCharacterReference(head) + value.slice(1);
19254
+ }
19255
+ value = value ? sequence + " " + value : sequence;
19256
+ if (state.options.closeAtx) {
19257
+ value += " " + sequence;
19258
+ }
19259
+ subexit();
19247
19260
  exit();
19248
19261
  return value;
19249
19262
  }
19250
- var init_root = __esm(() => {
19251
- init_mdast_util_phrasing();
19263
+ var init_heading = __esm(() => {
19264
+ init_format_heading_as_setext();
19252
19265
  });
19253
19266
 
19254
- // ../../node_modules/mdast-util-to-markdown/lib/util/check-strong.js
19255
- function checkStrong(state) {
19256
- const marker = state.options.strong || "*";
19257
- if (marker !== "*" && marker !== "_") {
19258
- throw new Error("Cannot serialize strong with `" + marker + "` for `options.strong`, expected `*`, or `_`");
19259
- }
19260
- return marker;
19267
+ // ../../node_modules/mdast-util-to-markdown/lib/handle/html.js
19268
+ function html(node) {
19269
+ return node.value || "";
19270
+ }
19271
+ function htmlPeek() {
19272
+ return "<";
19261
19273
  }
19274
+ var init_html = __esm(() => {
19275
+ html.peek = htmlPeek;
19276
+ });
19262
19277
 
19263
- // ../../node_modules/mdast-util-to-markdown/lib/handle/strong.js
19264
- function strong(node, _, state, info) {
19265
- const exit = state.enter("phrasing");
19266
- const value = state.containerPhrasing({ type: "root", children: [node] }, info);
19278
+ // ../../node_modules/mdast-util-to-markdown/lib/handle/image.js
19279
+ function image(node, _, state, info) {
19280
+ const quote = checkQuote(state);
19281
+ const suffix = quote === '"' ? "Quote" : "Apostrophe";
19282
+ const exit = state.enter("image");
19283
+ let subexit = state.enter("label");
19284
+ const tracker = state.createTracker(info);
19285
+ let value = tracker.move("![");
19286
+ value += tracker.move(state.safe(node.alt, { before: value, after: "]", ...tracker.current() }));
19287
+ value += tracker.move("](");
19288
+ subexit();
19289
+ if (!node.url && node.title || /[\0- \u007F]/.test(node.url)) {
19290
+ subexit = state.enter("destinationLiteral");
19291
+ value += tracker.move("<");
19292
+ value += tracker.move(state.safe(node.url, { before: value, after: ">", ...tracker.current() }));
19293
+ value += tracker.move(">");
19294
+ } else {
19295
+ subexit = state.enter("destinationRaw");
19296
+ value += tracker.move(state.safe(node.url, {
19297
+ before: value,
19298
+ after: node.title ? " " : ")",
19299
+ ...tracker.current()
19300
+ }));
19301
+ }
19302
+ subexit();
19303
+ if (node.title) {
19304
+ subexit = state.enter(`title${suffix}`);
19305
+ value += tracker.move(" " + quote);
19306
+ value += tracker.move(state.safe(node.title, {
19307
+ before: value,
19308
+ after: quote,
19309
+ ...tracker.current()
19310
+ }));
19311
+ value += tracker.move(quote);
19312
+ subexit();
19313
+ }
19314
+ value += tracker.move(")");
19267
19315
  exit();
19268
19316
  return value;
19269
19317
  }
19270
- function attention3(_, state) {
19271
- const marker = checkStrong(state);
19272
- return {
19273
- construct: "strong",
19274
- markers: marker === "*" ? ["*", "_"] : ["_", "*"],
19275
- sizes: [2]
19276
- };
19277
- }
19278
- function peek2(_, _1, state) {
19279
- return state.options.strong || "*";
19318
+ function imagePeek() {
19319
+ return "!";
19280
19320
  }
19281
- var init_strong = __esm(() => {
19282
- strong.attention = attention3;
19283
- strong.peek = peek2;
19321
+ var init_image = __esm(() => {
19322
+ image.peek = imagePeek;
19284
19323
  });
19285
19324
 
19286
- // ../../node_modules/mdast-util-to-markdown/lib/handle/text.js
19287
- function text3(node, parent, state, info) {
19288
- const siblings = parent ? parent.children : [];
19289
- const index = siblings.indexOf(node);
19290
- return state.safe(node.value, {
19291
- ...info,
19292
- afterNode: siblings[index + 1],
19293
- beforeNode: siblings[index - 1]
19325
+ // ../../node_modules/mdast-util-to-markdown/lib/handle/image-reference.js
19326
+ function imageReference(node, _, state, info) {
19327
+ const type = node.referenceType;
19328
+ const exit = state.enter("imageReference");
19329
+ let subexit = state.enter("label");
19330
+ const tracker = state.createTracker(info);
19331
+ let value = tracker.move("![");
19332
+ const alt = state.safe(node.alt, {
19333
+ before: value,
19334
+ after: "]",
19335
+ ...tracker.current()
19336
+ });
19337
+ value += tracker.move(alt + "][");
19338
+ subexit();
19339
+ const stack = state.stack;
19340
+ state.stack = stack.filter(function(d) {
19341
+ return d !== "phrasing";
19342
+ });
19343
+ subexit = state.enter("reference");
19344
+ const reference = state.safe(state.associationId(node), {
19345
+ before: value,
19346
+ after: "]",
19347
+ ...tracker.current()
19294
19348
  });
19349
+ subexit();
19350
+ state.stack = stack;
19351
+ exit();
19352
+ if (type === "full" || !alt || alt !== reference) {
19353
+ value += tracker.move(reference + "]");
19354
+ } else if (type === "shortcut") {
19355
+ value = value.slice(0, -1);
19356
+ } else {
19357
+ value += tracker.move("]");
19358
+ }
19359
+ return value;
19360
+ }
19361
+ function imageReferencePeek() {
19362
+ return "!";
19295
19363
  }
19364
+ var init_image_reference = __esm(() => {
19365
+ imageReference.peek = imageReferencePeek;
19366
+ });
19296
19367
 
19297
- // ../../node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.js
19298
- function checkRuleRepetition(state) {
19299
- const repetition = state.options.ruleRepetition || 3;
19300
- if (repetition < 3) {
19301
- throw new Error("Cannot serialize rules with repetition `" + repetition + "` for `options.ruleRepetition`, expected `3` or more");
19368
+ // ../../node_modules/mdast-util-to-markdown/lib/handle/inline-code.js
19369
+ function inlineCode(node, _, state) {
19370
+ let value = node.value || "";
19371
+ let sequence = "`";
19372
+ let index = -1;
19373
+ while (new RegExp("(^|[^`])" + sequence + "([^`]|$)").test(value)) {
19374
+ sequence += "`";
19302
19375
  }
19303
- return repetition;
19376
+ if (/[^\n\r ]/.test(value) && (/^[\n\r ]/.test(value) && /[\n\r ]$/.test(value) || /^`|`$/.test(value))) {
19377
+ value = " " + value + " ";
19378
+ }
19379
+ while (++index < state.unsafe.length) {
19380
+ const pattern = state.unsafe[index];
19381
+ const expression = state.compilePattern(pattern);
19382
+ if (!pattern.atBreak)
19383
+ continue;
19384
+ let match;
19385
+ while (match = expression.exec(value)) {
19386
+ let position = match.index;
19387
+ if (value.charCodeAt(position) === 10 && value.charCodeAt(position - 1) === 13) {
19388
+ position--;
19389
+ }
19390
+ value = value.slice(0, position) + " " + value.slice(match.index + 1);
19391
+ }
19392
+ }
19393
+ return sequence + value + sequence;
19304
19394
  }
19305
-
19306
- // ../../node_modules/mdast-util-to-markdown/lib/handle/thematic-break.js
19307
- function thematicBreak2(_, _1, state) {
19308
- const value = (checkRule(state) + (state.options.ruleSpaces ? " " : "")).repeat(checkRuleRepetition(state));
19309
- return state.options.ruleSpaces ? value.slice(0, -1) : value;
19395
+ function inlineCodePeek() {
19396
+ return "`";
19310
19397
  }
19311
- var init_thematic_break2 = () => {};
19398
+ var init_inline_code = __esm(() => {
19399
+ inlineCode.peek = inlineCodePeek;
19400
+ });
19312
19401
 
19313
- // ../../node_modules/mdast-util-to-markdown/lib/handle/index.js
19314
- var handle;
19315
- var init_handle = __esm(() => {
19316
- init_break();
19317
- init_code();
19318
- init_definition2();
19319
- init_emphasis();
19320
- init_heading();
19321
- init_html();
19322
- init_image();
19323
- init_image_reference();
19324
- init_inline_code();
19325
- init_link();
19326
- init_link_reference();
19327
- init_list2();
19328
- init_list_item();
19329
- init_root();
19330
- init_strong();
19331
- init_thematic_break2();
19332
- handle = {
19333
- blockquote,
19334
- break: hardBreak,
19335
- code,
19336
- definition: definition2,
19337
- emphasis,
19338
- hardBreak,
19339
- heading,
19340
- html,
19341
- image,
19342
- imageReference,
19343
- inlineCode,
19344
- link,
19345
- linkReference,
19346
- list: list3,
19347
- listItem,
19348
- paragraph,
19349
- root,
19350
- strong,
19351
- text: text3,
19352
- thematicBreak: thematicBreak2
19353
- };
19402
+ // ../../node_modules/mdast-util-to-markdown/lib/util/format-link-as-autolink.js
19403
+ function formatLinkAsAutolink(node, state) {
19404
+ const raw = toString(node);
19405
+ return Boolean(!state.options.resourceLink && node.url && !node.title && node.children && node.children.length === 1 && node.children[0].type === "text" && (raw === node.url || "mailto:" + raw === node.url) && /^[a-z][+\-.a-z]+:/i.test(node.url) && !/[\0- <>\u007F]/.test(node.url));
19406
+ }
19407
+ var init_format_link_as_autolink = __esm(() => {
19408
+ init_mdast_util_to_string();
19354
19409
  });
19355
19410
 
19356
- // ../../node_modules/mdast-util-to-markdown/lib/util/html-kind.js
19357
- function htmlKind(value) {
19358
- if (value.charCodeAt(0) !== 60)
19359
- return;
19360
- const next = value.charCodeAt(1);
19361
- if (next === 33) {
19362
- const code = value.charCodeAt(2);
19363
- if (code === 45)
19364
- return 2;
19365
- if (code === 91)
19366
- return 5;
19367
- if (asciiAlpha(code))
19368
- return 4;
19369
- return;
19411
+ // ../../node_modules/mdast-util-to-markdown/lib/handle/link.js
19412
+ function link(node, _, state, info) {
19413
+ const quote = checkQuote(state);
19414
+ const suffix = quote === '"' ? "Quote" : "Apostrophe";
19415
+ const tracker = state.createTracker(info);
19416
+ if (formatLinkAsAutolink(node, state)) {
19417
+ const stack = state.stack;
19418
+ state.stack = stack.filter(function(d) {
19419
+ return d !== "phrasing";
19420
+ });
19421
+ const exit = state.enter("autolink");
19422
+ let value = tracker.move("<");
19423
+ value += tracker.move(state.containerPhrasing(node, {
19424
+ before: value,
19425
+ after: ">",
19426
+ ...tracker.current()
19427
+ }));
19428
+ value += tracker.move(">");
19429
+ exit();
19430
+ state.stack = stack;
19431
+ return value;
19370
19432
  }
19371
- if (next === 63)
19372
- return 3;
19373
- const closing = next === 47;
19374
- const start = closing ? 2 : 1;
19375
- let end = start;
19376
- let code = value.charCodeAt(end);
19377
- if (!asciiAlpha(code))
19378
- return;
19379
- while (code === 45 || asciiAlphanumeric(code)) {
19380
- code = value.charCodeAt(++end);
19433
+ const exit = state.enter("link");
19434
+ let subexit = state.enter("label");
19435
+ let value = tracker.move("[");
19436
+ const text = state.containerPhrasing(node, {
19437
+ before: value,
19438
+ after: "](",
19439
+ ...tracker.current()
19440
+ });
19441
+ value += tracker.move(text);
19442
+ subexit();
19443
+ value += tracker.move("](");
19444
+ const enclose = /[\0- \u007F]/.test(node.url);
19445
+ const last = info.before.charAt(info.before.length - 1);
19446
+ let title = node.title || undefined;
19447
+ if (!title && !enclose && (last === `
19448
+ ` || last === "\r")) {
19449
+ let index = 0;
19450
+ while (index < text.length && text.charCodeAt(index) !== 93) {
19451
+ index += text.charCodeAt(index) === 92 ? 2 : 1;
19452
+ }
19453
+ if (text.charCodeAt(index + 1) === 58)
19454
+ title = "";
19381
19455
  }
19382
- const name = value.slice(start, end).toLowerCase();
19383
- if (!closing && code !== 47 && htmlRawNames.includes(name)) {
19384
- return 1;
19456
+ if (!node.url && typeof title === "string" || enclose) {
19457
+ subexit = state.enter("destinationLiteral");
19458
+ value += tracker.move("<");
19459
+ value += tracker.move(state.safe(node.url, { before: value, after: ">", ...tracker.current() }));
19460
+ value += tracker.move(">");
19461
+ } else {
19462
+ subexit = state.enter("destinationRaw");
19463
+ value += tracker.move(state.safe(node.url, {
19464
+ before: value,
19465
+ after: typeof title === "string" ? " " : ")",
19466
+ ...tracker.current()
19467
+ }));
19385
19468
  }
19386
- return htmlBlockNames.includes(name) ? 6 : 7;
19469
+ subexit();
19470
+ if (typeof title === "string") {
19471
+ subexit = state.enter(`title${suffix}`);
19472
+ value += tracker.move(" " + quote);
19473
+ value += tracker.move(state.safe(title, {
19474
+ before: value,
19475
+ after: quote,
19476
+ ...tracker.current()
19477
+ }));
19478
+ value += tracker.move(quote);
19479
+ subexit();
19480
+ }
19481
+ value += tracker.move(")");
19482
+ exit();
19483
+ return value;
19387
19484
  }
19388
- var init_html_kind = __esm(() => {
19389
- init_dev4();
19390
- init_micromark_util_html_tag_name();
19485
+ function linkPeek(node, _, state) {
19486
+ return formatLinkAsAutolink(node, state) ? "<" : "[";
19487
+ }
19488
+ var init_link = __esm(() => {
19489
+ init_format_link_as_autolink();
19490
+ link.peek = linkPeek;
19391
19491
  });
19392
19492
 
19393
- // ../../node_modules/mdast-util-to-markdown/lib/join.js
19394
- function joinDefaults(left, right, parent, state) {
19395
- if (right.type === "code" && formatCodeAsIndented(right, state) && (left.type === "list" || left.type === right.type && formatCodeAsIndented(left, state))) {
19396
- return false;
19397
- }
19398
- if ("spread" in parent && typeof parent.spread === "boolean") {
19399
- if (left.type === "paragraph" && (left.type === right.type || right.type === "definition" || right.type === "heading" && formatHeadingAsSetext(right, state))) {
19400
- return;
19401
- }
19402
- if (left.type === "html") {
19403
- const kind = htmlKind(left.value);
19404
- if (kind === undefined || kind === 6 || kind === 7)
19405
- return 1;
19406
- }
19407
- if (left.type === "paragraph" && right.type === "html") {
19408
- const kind = htmlKind(right.value);
19409
- if (kind === undefined || kind === 7)
19410
- return 1;
19411
- }
19412
- return parent.spread ? 1 : 0;
19493
+ // ../../node_modules/mdast-util-to-markdown/lib/handle/link-reference.js
19494
+ function linkReference(node, _, state, info) {
19495
+ const type = node.referenceType;
19496
+ const exit = state.enter("linkReference");
19497
+ let subexit = state.enter("label");
19498
+ const tracker = state.createTracker(info);
19499
+ let value = tracker.move("[");
19500
+ const text = state.containerPhrasing(node, {
19501
+ before: value,
19502
+ after: "]",
19503
+ ...tracker.current()
19504
+ });
19505
+ value += tracker.move(text + "][");
19506
+ subexit();
19507
+ const stack = state.stack;
19508
+ state.stack = stack.filter(function(d) {
19509
+ return d !== "phrasing";
19510
+ });
19511
+ subexit = state.enter("reference");
19512
+ const reference = state.safe(state.associationId(node), {
19513
+ before: value,
19514
+ after: "]",
19515
+ ...tracker.current()
19516
+ });
19517
+ subexit();
19518
+ state.stack = stack;
19519
+ exit();
19520
+ if (type === "full" || !text || text !== reference) {
19521
+ value += tracker.move(reference + "]");
19522
+ } else if (type === "shortcut") {
19523
+ value = value.slice(0, -1);
19524
+ } else {
19525
+ value += tracker.move("]");
19413
19526
  }
19527
+ return value;
19414
19528
  }
19415
- var join;
19416
- var init_join = __esm(() => {
19417
- init_format_heading_as_setext();
19418
- init_html_kind();
19419
- join = [joinDefaults];
19529
+ function linkReferencePeek() {
19530
+ return "[";
19531
+ }
19532
+ var init_link_reference = __esm(() => {
19533
+ linkReference.peek = linkReferencePeek;
19420
19534
  });
19421
19535
 
19422
- // ../../node_modules/mdast-util-to-markdown/lib/unsafe.js
19423
- var fullPhrasingSpans, unsafe, code2 = -1;
19424
- var init_unsafe = __esm(() => {
19425
- fullPhrasingSpans = [
19426
- "autolink",
19427
- "destinationLiteral",
19428
- "destinationRaw",
19429
- "reference",
19430
- "titleQuote",
19431
- "titleApostrophe"
19432
- ];
19433
- unsafe = [
19434
- { character: "\t", after: "[\\r\\n]", inConstruct: "phrasing" },
19435
- { character: "\t", before: "[\\r\\n]", inConstruct: "phrasing" },
19436
- {
19437
- character: "\t",
19438
- inConstruct: ["codeFencedLangGraveAccent", "codeFencedLangTilde"]
19439
- },
19440
- {
19441
- character: "\r",
19442
- inConstruct: [
19443
- "codeFencedLangGraveAccent",
19444
- "codeFencedLangTilde",
19445
- "codeFencedMetaGraveAccent",
19446
- "codeFencedMetaTilde",
19447
- "destinationLiteral",
19448
- "headingAtx"
19449
- ]
19450
- },
19451
- {
19452
- character: `
19453
- `,
19454
- inConstruct: [
19455
- "codeFencedLangGraveAccent",
19456
- "codeFencedLangTilde",
19457
- "codeFencedMetaGraveAccent",
19458
- "codeFencedMetaTilde",
19459
- "destinationLiteral",
19460
- "headingAtx"
19461
- ]
19462
- },
19463
- { character: "\r", before: "[\\r\\n]", inConstruct: "phrasing" },
19464
- { character: "\r", after: "\\r", inConstruct: "phrasing" },
19465
- { character: `
19466
- `, before: "\\n", inConstruct: "phrasing" },
19467
- { character: `
19468
- `, after: "[\\r\\n]", inConstruct: "phrasing" },
19469
- { character: " ", after: "[\\r\\n]", inConstruct: "phrasing" },
19470
- { character: " ", before: "[\\r\\n]", inConstruct: "phrasing" },
19471
- {
19472
- character: " ",
19473
- inConstruct: ["codeFencedLangGraveAccent", "codeFencedLangTilde"]
19474
- },
19475
- {
19476
- character: "!",
19477
- after: "\\[",
19478
- inConstruct: "phrasing",
19479
- notInConstruct: fullPhrasingSpans
19480
- },
19481
- { character: '"', inConstruct: "titleQuote" },
19482
- { atBreak: true, character: "#" },
19483
- { character: "#", inConstruct: "headingAtx", after: `(?:[\r
19484
- ]|$)` },
19485
- { character: "&", after: "[#A-Za-z]", inConstruct: "phrasing" },
19486
- { character: "'", inConstruct: "titleApostrophe" },
19487
- { character: "(", inConstruct: "destinationRaw" },
19488
- {
19489
- before: "\\]",
19490
- character: "(",
19491
- inConstruct: "phrasing",
19492
- notInConstruct: fullPhrasingSpans
19493
- },
19494
- { atBreak: true, before: "\\d+", character: ")" },
19495
- { character: ")", inConstruct: "destinationRaw" },
19496
- { atBreak: true, character: "*", after: `(?:[ \r
19497
- *])` },
19498
- { character: "*", inConstruct: "phrasing", notInConstruct: fullPhrasingSpans },
19499
- { atBreak: true, character: "+", after: `(?:[ \r
19500
- ])` },
19501
- { atBreak: true, character: "-", after: `(?:[ \r
19502
- -])` },
19503
- { atBreak: true, before: "\\d+", character: ".", after: `(?:[ \r
19504
- ]|$)` },
19505
- { atBreak: true, character: "<", after: "[!/?A-Za-z]" },
19506
- {
19507
- character: "<",
19508
- after: "[!/?A-Za-z]",
19509
- inConstruct: "phrasing",
19510
- notInConstruct: fullPhrasingSpans
19511
- },
19512
- { character: "<", inConstruct: "destinationLiteral" },
19513
- { atBreak: true, character: "=" },
19514
- { atBreak: true, character: ">" },
19515
- { character: ">", inConstruct: "destinationLiteral" },
19516
- { atBreak: true, character: "[" },
19517
- { character: "[", inConstruct: "phrasing", notInConstruct: fullPhrasingSpans },
19518
- { character: "[", inConstruct: ["label", "reference"] },
19519
- { character: "\\", after: "[\\r\\n]", inConstruct: "phrasing" },
19520
- { character: "]", inConstruct: ["label", "reference"] },
19521
- { atBreak: true, character: "_" },
19522
- { character: "_", inConstruct: "phrasing", notInConstruct: fullPhrasingSpans },
19523
- { atBreak: true, character: "`" },
19524
- {
19525
- character: "`",
19526
- inConstruct: ["codeFencedLangGraveAccent", "codeFencedMetaGraveAccent"]
19527
- },
19528
- { character: "`", inConstruct: "phrasing", notInConstruct: fullPhrasingSpans },
19529
- { atBreak: true, character: "~" },
19530
- { character: "<", inConstruct: "autolink" },
19531
- { character: ">", inConstruct: "autolink" },
19532
- { character: "", inConstruct: "autolink" }
19533
- ];
19534
- while (++code2 < 33) {
19535
- unsafe.push({ character: String.fromCharCode(code2), inConstruct: "autolink" });
19536
+ // ../../node_modules/mdast-util-to-markdown/lib/util/check-bullet.js
19537
+ function checkBullet(state) {
19538
+ const marker = state.options.bullet || "*";
19539
+ if (marker !== "*" && marker !== "+" && marker !== "-") {
19540
+ throw new Error("Cannot serialize items with `" + marker + "` for `options.bullet`, expected `*`, `+`, or `-`");
19536
19541
  }
19537
- });
19542
+ return marker;
19543
+ }
19538
19544
 
19539
- // ../../node_modules/mdast-util-to-markdown/lib/util/association.js
19540
- function association(node) {
19541
- if (node.label || !node.identifier) {
19542
- return node.label || "";
19545
+ // ../../node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.js
19546
+ function checkBulletOther(state) {
19547
+ const bullet = checkBullet(state);
19548
+ const bulletOther = state.options.bulletOther;
19549
+ if (!bulletOther) {
19550
+ return bullet === "*" ? "-" : "*";
19543
19551
  }
19544
- return decodeString(node.identifier);
19552
+ if (bulletOther !== "*" && bulletOther !== "+" && bulletOther !== "-") {
19553
+ throw new Error("Cannot serialize items with `" + bulletOther + "` for `options.bulletOther`, expected `*`, `+`, or `-`");
19554
+ }
19555
+ if (bulletOther === bullet) {
19556
+ throw new Error("Expected `bullet` (`" + bullet + "`) and `bulletOther` (`" + bulletOther + "`) to be different");
19557
+ }
19558
+ return bulletOther;
19545
19559
  }
19546
- var init_association = __esm(() => {
19547
- init_dev14();
19548
- });
19560
+ var init_check_bullet_other = () => {};
19549
19561
 
19550
- // ../../node_modules/mdast-util-to-markdown/lib/util/compile-pattern.js
19551
- function compilePattern(pattern) {
19552
- if (!pattern._compiled) {
19553
- const before = (pattern.atBreak ? "[\\r\\n][\\t ]*" : "") + (pattern.before ? "(?:" + pattern.before + ")" : "");
19554
- pattern._compiled = new RegExp((pattern.beforeNode ? "^" : before ? "(" + before + ")" : "") + (/[$()*+.?[\\\]^{|}]/.test(pattern.character) ? "\\" : "") + pattern.character + (pattern.afterNode ? "$" : pattern.after ? "(?:" + pattern.after + ")" : ""), pattern.unicode ? "gu" : "g");
19562
+ // ../../node_modules/mdast-util-to-markdown/lib/util/check-bullet-ordered.js
19563
+ function checkBulletOrdered(state) {
19564
+ const marker = state.options.bulletOrdered || ".";
19565
+ if (marker !== "." && marker !== ")") {
19566
+ throw new Error("Cannot serialize items with `" + marker + "` for `options.bulletOrdered`, expected `.` or `)`");
19555
19567
  }
19556
- return pattern._compiled;
19568
+ return marker;
19557
19569
  }
19558
19570
 
19559
- // ../../node_modules/mdast-util-to-markdown/lib/util/character.js
19560
- function firstCharacter(value) {
19561
- const code = value.codePointAt(0);
19562
- return code === undefined ? "" : String.fromCodePoint(code);
19563
- }
19564
- function lastCharacter(value) {
19565
- const code = value.codePointAt(value.length - 2);
19566
- return code !== undefined && code > 65535 ? value.slice(-2) : value.slice(-1);
19571
+ // ../../node_modules/mdast-util-to-markdown/lib/util/check-rule.js
19572
+ function checkRule(state) {
19573
+ const marker = state.options.rule || "*";
19574
+ if (marker !== "*" && marker !== "-" && marker !== "_") {
19575
+ throw new Error("Cannot serialize rules with `" + marker + "` for `options.rule`, expected `*`, `-`, or `_`");
19576
+ }
19577
+ return marker;
19567
19578
  }
19568
19579
 
19569
- // ../../node_modules/mdast-util-to-markdown/lib/util/encode-info.js
19570
- function encodeInfo(outside, inside, marker) {
19571
- const outsideKind = classifyCharacter(outside);
19572
- const insideKind = classifyCharacter(inside);
19573
- if (outsideKind === undefined) {
19574
- return insideKind === undefined ? marker === "_" ? { inside: true, outside: true } : { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: true } : { inside: false, outside: true };
19580
+ // ../../node_modules/mdast-util-to-markdown/lib/handle/list.js
19581
+ function list3(node, parent, state, info) {
19582
+ const exit = state.enter("list");
19583
+ const bulletCurrent = state.bulletCurrent;
19584
+ let bullet = node.ordered ? checkBulletOrdered(state) : checkBullet(state);
19585
+ const bulletOther = node.ordered ? bullet === "." ? ")" : "." : checkBulletOther(state);
19586
+ let useDifferentMarker = parent && state.bulletLastUsed ? bullet === state.bulletLastUsed : false;
19587
+ if (!node.ordered) {
19588
+ const firstListItem = node.children ? node.children[0] : undefined;
19589
+ if ((bullet === "*" || bullet === "-") && firstListItem && (!firstListItem.children || !firstListItem.children[0]) && state.stack[state.stack.length - 1] === "list" && state.stack[state.stack.length - 2] === "listItem" && state.stack[state.stack.length - 3] === "list" && state.stack[state.stack.length - 4] === "listItem" && state.indexStack[state.indexStack.length - 1] === 0 && state.indexStack[state.indexStack.length - 2] === 0 && state.indexStack[state.indexStack.length - 3] === 0) {
19590
+ useDifferentMarker = true;
19591
+ }
19592
+ if (checkRule(state) === bullet && firstListItem) {
19593
+ let index = -1;
19594
+ while (++index < node.children.length) {
19595
+ const item = node.children[index];
19596
+ if (item && item.type === "listItem" && item.children && item.children[0] && item.children[0].type === "thematicBreak") {
19597
+ useDifferentMarker = true;
19598
+ break;
19599
+ }
19600
+ }
19601
+ }
19575
19602
  }
19576
- if (outsideKind === 1) {
19577
- return insideKind === undefined ? { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: true } : { inside: false, outside: false };
19603
+ if (useDifferentMarker) {
19604
+ bullet = bulletOther;
19578
19605
  }
19579
- return insideKind === undefined ? { inside: false, outside: false } : insideKind === 1 ? { inside: true, outside: false } : { inside: false, outside: false };
19606
+ state.bulletCurrent = bullet;
19607
+ const value = state.containerFlow(node, info);
19608
+ state.bulletLastUsed = bullet;
19609
+ state.bulletCurrent = bulletCurrent;
19610
+ exit();
19611
+ return value;
19580
19612
  }
19581
- var init_encode_info = __esm(() => {
19582
- init_dev6();
19613
+ var init_list2 = __esm(() => {
19614
+ init_check_bullet_other();
19583
19615
  });
19584
19616
 
19585
- // ../../node_modules/mdast-util-to-markdown/lib/util/container-phrasing.js
19586
- function candidates(tokens, involved, runOf) {
19587
- const related = new Set;
19588
- for (const token of tokens) {
19589
- const siblings = runOf.get(token);
19590
- if (siblings && token.attention && involved.some((d) => d.attention === token.attention)) {
19591
- for (const sibling of siblings.tokens) {
19592
- related.add(sibling.attention);
19593
- }
19594
- }
19595
- }
19596
- const ordered = [];
19597
- for (const token of tokens) {
19598
- if (token.attention && related.delete(token.attention)) {
19599
- ordered.push(token.attention);
19600
- }
19617
+ // ../../node_modules/mdast-util-to-markdown/lib/util/check-list-item-indent.js
19618
+ function checkListItemIndent(state) {
19619
+ const style = state.options.listItemIndent || "one";
19620
+ if (style !== "tab" && style !== "one" && style !== "mixed") {
19621
+ throw new Error("Cannot serialize items with `" + style + "` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");
19601
19622
  }
19602
- ordered.reverse();
19603
- return ordered;
19623
+ return style;
19604
19624
  }
19605
- function check(tokens, before, after) {
19606
- const runs = [];
19607
- const wrong = new Map;
19608
- const runOf = new Map;
19609
- let index = 0;
19610
- while (index < tokens.length) {
19611
- if (!tokens[index].attention) {
19612
- index++;
19613
- continue;
19614
- }
19615
- const marker = tokens[index].value.charAt(0);
19616
- const strict = builtins.get(marker);
19617
- let end = index + 1;
19618
- while (end < tokens.length && tokens[end].attention && tokens[end].value.charAt(0) === marker) {
19619
- end++;
19620
- }
19621
- const head = index ? tokens[index - 1].value : before;
19622
- const previous = classifyCharacter(head.charCodeAt(head.length - 1));
19623
- const next = classifyCharacter((end < tokens.length ? tokens[end].value : after).charCodeAt(0));
19624
- const open = !next || next === 2 && Boolean(previous);
19625
- const close = !previous || previous === 2 && Boolean(next);
19626
- const run = {
19627
- tokens: tokens.slice(index, end),
19628
- markers: [],
19629
- start: 0,
19630
- end: 0,
19631
- open: strict ? open && (Boolean(previous) || !close) : open,
19632
- close: strict ? close && (Boolean(next) || !open) : close,
19633
- split: strict !== undefined
19634
- };
19635
- for (const token of run.tokens) {
19636
- wrong.set(token, [...run.tokens]);
19637
- runOf.set(token, run);
19638
- let size = token.value.length;
19639
- while (size--)
19640
- run.markers.push(token);
19641
- }
19642
- run.end = run.markers.length;
19643
- runs.push(run);
19644
- index = end;
19625
+
19626
+ // ../../node_modules/mdast-util-to-markdown/lib/handle/list-item.js
19627
+ function listItem(node, parent, state, info) {
19628
+ const listItemIndent = checkListItemIndent(state);
19629
+ let bullet = state.bulletCurrent || checkBullet(state);
19630
+ if (parent && parent.type === "list" && parent.ordered) {
19631
+ bullet = (typeof parent.start === "number" && parent.start > -1 ? parent.start : 1) + (state.options.incrementListMarker === false ? 0 : parent.children.indexOf(node)) + bullet;
19645
19632
  }
19646
- pair(runs, wrong);
19647
- index = -1;
19648
- while (++index < tokens.length) {
19649
- const involved = wrong.get(tokens[index]);
19650
- if (involved)
19651
- return { attention: candidates(tokens, involved, runOf), index };
19633
+ let size = bullet.length + 1;
19634
+ if (listItemIndent === "tab" || listItemIndent === "mixed" && (parent && parent.type === "list" && parent.spread || node.spread)) {
19635
+ size = Math.ceil(size / 4) * 4;
19636
+ }
19637
+ const tracker = state.createTracker(info);
19638
+ tracker.move(bullet + " ".repeat(size - bullet.length));
19639
+ tracker.shift(size);
19640
+ const exit = state.enter("listItem");
19641
+ const value = state.indentLines(state.containerFlow(node, tracker.current()), map);
19642
+ exit();
19643
+ return value;
19644
+ function map(line, index, blank) {
19645
+ if (index) {
19646
+ return (blank ? "" : " ".repeat(size)) + line;
19647
+ }
19648
+ return (blank ? bullet : bullet + " ".repeat(size - bullet.length)) + line;
19652
19649
  }
19653
19650
  }
19654
- function containerPhrasing(parent, state, info) {
19655
- return serialize2(phrasing2(parent, state, info), info.before, info.after);
19656
- }
19657
- function encode(tokens, start) {
19658
- const token = tokens[start ? 0 : tokens.length - 1];
19659
- if (!token || token.attention)
19660
- return;
19661
- const character = start ? firstCharacter(token.value) : lastCharacter(token.value);
19662
- const reference = encodeCharacterReference(character.codePointAt(0));
19663
- token.value = start ? reference + token.value.slice(character.length) : token.value.slice(0, token.value.length - character.length) + reference;
19651
+ var init_list_item = () => {};
19652
+
19653
+ // ../../node_modules/mdast-util-to-markdown/lib/handle/paragraph.js
19654
+ function paragraph(node, _, state, info) {
19655
+ const exit = state.enter("paragraph");
19656
+ const subexit = state.enter("phrasing");
19657
+ const value = state.containerPhrasing(node, info);
19658
+ subexit();
19659
+ exit();
19660
+ return value;
19664
19661
  }
19665
- function improve(items, chosen, mistake, before, after) {
19666
- for (const attention of mistake.attention) {
19667
- const current = chosen.get(attention) || attention.sequences[0];
19668
- for (const sequence of attention.sequences) {
19669
- if (sequence === current)
19670
- continue;
19671
- const trial = new Map(chosen);
19672
- trial.set(attention, sequence);
19673
- const tokens = render(items, trial, before, after);
19674
- const next = check(tokens, before, after);
19675
- if (!next || next.index > mistake.index) {
19676
- return { chosen: trial, mistake: next, tokens };
19677
- }
19678
- }
19679
- }
19662
+
19663
+ // ../../node_modules/mdast-util-to-markdown/lib/handle/root.js
19664
+ function root(node, _, state, info) {
19665
+ const hasPhrasing = node.children.some(function(d) {
19666
+ return phrasing(d);
19667
+ });
19668
+ if (!hasPhrasing)
19669
+ return state.containerFlow(node, info);
19670
+ const exit = state.enter("phrasing");
19671
+ const value = state.containerPhrasing(node, info);
19672
+ exit();
19673
+ return value;
19680
19674
  }
19681
- function pair(runs, wrong) {
19682
- let index = 0;
19683
- while (index < runs.length) {
19684
- const closer = runs[index];
19685
- const marker = closer.tokens[0].value.charAt(0);
19686
- const closerSize = closer.end - closer.start;
19687
- let open = closer.close && closerSize ? index : 0;
19688
- while (open--) {
19689
- const opener = runs[open];
19690
- const openerSize = opener.end - opener.start;
19691
- 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)) {
19692
- const size = closer.split ? openerSize > 1 && closerSize > 1 ? 2 : 1 : closerSize;
19693
- const opening = opener.markers.slice(opener.end - size, opener.end);
19694
- const closing = closer.markers.slice(closer.start, closer.start + size);
19695
- const openToken = opening[0];
19696
- const closeToken = closing[0];
19697
- if (openToken === opening[size - 1] && openToken.value.length === size && closeToken === closing[size - 1] && closeToken.value.length === size && openToken.attention === closeToken.attention) {
19698
- wrong.delete(openToken);
19699
- wrong.delete(closeToken);
19700
- } else {
19701
- const involved = [...new Set([...opening, ...closing])];
19702
- for (const token of involved) {
19703
- const list = wrong.get(token);
19704
- if (list)
19705
- list.push(...involved);
19706
- }
19707
- }
19708
- opener.end -= size;
19709
- closer.start += size;
19710
- break;
19711
- }
19712
- }
19713
- if (open === -1 || closer.start === closer.end)
19714
- index++;
19675
+ var init_root = __esm(() => {
19676
+ init_mdast_util_phrasing();
19677
+ });
19678
+
19679
+ // ../../node_modules/mdast-util-to-markdown/lib/util/check-strong.js
19680
+ function checkStrong(state) {
19681
+ const marker = state.options.strong || "*";
19682
+ if (marker !== "*" && marker !== "_") {
19683
+ throw new Error("Cannot serialize strong with `" + marker + "` for `options.strong`, expected `*`, or `_`");
19715
19684
  }
19685
+ return marker;
19716
19686
  }
19717
- function attentionSequences(type, markers, sizes) {
19718
- if (markers.length === 0) {
19719
- throw new Error("Cannot serialize `" + type + "` as attention without markers, expected one or more markers");
19720
- }
19721
- if (sizes.length === 0) {
19722
- throw new Error("Cannot serialize `" + type + "` as attention without sizes, expected one or more sizes");
19687
+
19688
+ // ../../node_modules/mdast-util-to-markdown/lib/handle/strong.js
19689
+ function strong(node, _, state, info) {
19690
+ const exit = state.enter("phrasing");
19691
+ const item = attentionItem(node, attention3, state, state.createTracker(info));
19692
+ const value = serialize2([item], info.before, info.after);
19693
+ exit();
19694
+ return value;
19695
+ }
19696
+ function attention3(_, state) {
19697
+ const marker = checkStrong(state);
19698
+ return {
19699
+ construct: "strong",
19700
+ markers: marker === "*" ? ["*", "_"] : ["_", "*"],
19701
+ sizes: [2]
19702
+ };
19703
+ }
19704
+ function peek2(_, _1, state) {
19705
+ return state.options.strong || "*";
19706
+ }
19707
+ var init_strong = __esm(() => {
19708
+ init_container_phrasing();
19709
+ strong.attention = attention3;
19710
+ strong.peek = peek2;
19711
+ });
19712
+
19713
+ // ../../node_modules/mdast-util-to-markdown/lib/handle/text.js
19714
+ function text3(node, parent, state, info) {
19715
+ const siblings = parent ? parent.children : [];
19716
+ const index = state.indexStack[state.indexStack.length - 1];
19717
+ return state.safe(node.value, {
19718
+ ...info,
19719
+ afterNode: siblings[index + 1],
19720
+ beforeNode: siblings[index - 1]
19721
+ });
19722
+ }
19723
+
19724
+ // ../../node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.js
19725
+ function checkRuleRepetition(state) {
19726
+ const repetition = state.options.ruleRepetition || 3;
19727
+ if (repetition < 3) {
19728
+ throw new Error("Cannot serialize rules with repetition `" + repetition + "` for `options.ruleRepetition`, expected `3` or more");
19723
19729
  }
19724
- for (const size of sizes) {
19725
- if (!Number.isSafeInteger(size) || size < 1) {
19726
- throw new Error("Cannot serialize `" + type + "` as attention with `" + size + "` as size, expected positive integer");
19727
- }
19730
+ return repetition;
19731
+ }
19732
+
19733
+ // ../../node_modules/mdast-util-to-markdown/lib/handle/thematic-break.js
19734
+ function thematicBreak2(_, _1, state) {
19735
+ const value = (checkRule(state) + (state.options.ruleSpaces ? " " : "")).repeat(checkRuleRepetition(state));
19736
+ return state.options.ruleSpaces ? value.slice(0, -1) : value;
19737
+ }
19738
+ var init_thematic_break2 = () => {};
19739
+
19740
+ // ../../node_modules/mdast-util-to-markdown/lib/handle/index.js
19741
+ var handle;
19742
+ var init_handle = __esm(() => {
19743
+ init_break();
19744
+ init_code();
19745
+ init_definition2();
19746
+ init_emphasis();
19747
+ init_heading();
19748
+ init_html();
19749
+ init_image();
19750
+ init_image_reference();
19751
+ init_inline_code();
19752
+ init_link();
19753
+ init_link_reference();
19754
+ init_list2();
19755
+ init_list_item();
19756
+ init_root();
19757
+ init_strong();
19758
+ init_thematic_break2();
19759
+ handle = {
19760
+ blockquote,
19761
+ break: hardBreak,
19762
+ code,
19763
+ definition: definition2,
19764
+ emphasis,
19765
+ hardBreak,
19766
+ heading,
19767
+ html,
19768
+ image,
19769
+ imageReference,
19770
+ inlineCode,
19771
+ link,
19772
+ linkReference,
19773
+ list: list3,
19774
+ listItem,
19775
+ paragraph,
19776
+ root,
19777
+ strong,
19778
+ text: text3,
19779
+ thematicBreak: thematicBreak2
19780
+ };
19781
+ });
19782
+
19783
+ // ../../node_modules/mdast-util-to-markdown/lib/join.js
19784
+ function joinDefaults(left, right, parent, state) {
19785
+ if (right.type === "code" && formatCodeAsIndented(right, state) && (left.type === "list" || left.type === right.type && formatCodeAsIndented(left, state))) {
19786
+ return false;
19728
19787
  }
19729
- const sequences = [];
19730
- for (const marker of markers) {
19731
- if (marker.length !== 1) {
19732
- throw new Error("Cannot serialize `" + type + "` as attention with `" + marker + "` as marker, expected a single ascii character");
19788
+ if ("spread" in parent && typeof parent.spread === "boolean") {
19789
+ if (parent.spread)
19790
+ return 1;
19791
+ if (left.type === "html") {
19792
+ const kind = htmlKind(left.value);
19793
+ if (kind === undefined || kind === 6 || kind === 7)
19794
+ return 1;
19733
19795
  }
19734
- if (!asciiPunctuation(marker.charCodeAt(0))) {
19735
- throw new Error("Cannot serialize `" + type + "` as attention with `" + marker + "` as marker, expected ascii punctuation");
19796
+ if (left.type === "blockquote" && right.type === "blockquote")
19797
+ return 1;
19798
+ 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)) {
19799
+ return 1;
19736
19800
  }
19737
- for (const size of sizes) {
19738
- sequences.push(marker.repeat(size));
19801
+ if (left.type === "paragraph" && right.type === "thematicBreak" && checkRule(state) === "-" && !state.options.ruleSpaces) {
19802
+ return 1;
19739
19803
  }
19740
- }
19741
- return sequences;
19742
- }
19743
- function phrasing2(parent, state, info) {
19744
- const indexStack = state.indexStack;
19745
- const children = parent.children || [];
19746
- const results = [];
19747
- let index = -1;
19748
- let before = info.before;
19749
- indexStack.push(-1);
19750
- let tracker = state.createTracker(info);
19751
- while (++index < children.length) {
19752
- const child = children[index];
19753
- let after;
19754
- indexStack[indexStack.length - 1] = index;
19755
- if (index + 1 < children.length) {
19756
- let handle = state.handle.handlers[children[index + 1].type];
19757
- if (handle && handle.peek)
19758
- handle = handle.peek;
19759
- after = handle ? firstCharacter(handle(children[index + 1], parent, state, {
19760
- before: "",
19761
- after: "",
19762
- ...tracker.current()
19763
- })) : "";
19764
- } else {
19765
- after = info.after;
19804
+ let tail = left;
19805
+ while ((tail.type === "blockquote" || tail.type === "list" || tail.type === "listItem") && tail.children.length > 0) {
19806
+ tail = tail.children[tail.children.length - 1];
19766
19807
  }
19767
- const previous = results[results.length - 1];
19768
- if (typeof previous === "string" && (before === "\r" || before === `
19769
- `) && child.type === "html" && htmlKind(child.value) !== 7) {
19770
- results[results.length - 1] = previous.replace(/(\r?\n|\r)$/, " ");
19771
- before = " ";
19772
- tracker = state.createTracker(info);
19773
- tracker.move(serialize2(results, info.before, info.after));
19808
+ if (tail.type !== "definition" && tail.type !== "paragraph")
19809
+ return 0;
19810
+ if (right.type === "code" && formatCodeAsIndented(right, state))
19811
+ return 1;
19812
+ if (right.type === "html") {
19813
+ const kind = htmlKind(right.value);
19814
+ if (kind === undefined || kind === 7)
19815
+ return 1;
19774
19816
  }
19775
- const handle = state.handle.handlers[child.type];
19776
- if (handle && handle.attention) {
19777
- const { construct, markers, sizes } = handle.attention(child, state);
19778
- const sequences = attentionSequences(child.type, markers, sizes);
19779
- const sequence = sequences[0];
19780
- const exit = state.enter(construct);
19781
- tracker.move(sequence);
19782
- const inside = phrasing2(child, state, {
19783
- ...tracker.current(),
19784
- before: sequence,
19785
- after: sequence
19786
- });
19787
- tracker.move(serialize2(inside, sequence, sequence));
19788
- tracker.move(sequence);
19789
- exit();
19790
- results.push({ children: inside, sequences });
19791
- before = sequence.charAt(sequence.length - 1);
19792
- } else {
19793
- const value = state.handle(child, parent, state, {
19794
- ...tracker.current(),
19795
- after,
19796
- before
19797
- });
19798
- if (!value)
19799
- continue;
19800
- tracker.move(value);
19801
- results.push(value);
19802
- before = lastCharacter(value);
19817
+ if ((left.type === "paragraph" || left !== tail) && (right.type === "definition" || right.type === "heading" && formatHeadingAsSetext(right, state) || right.type === "paragraph")) {
19818
+ return 1;
19803
19819
  }
19820
+ return 0;
19821
+ }
19822
+ }
19823
+ var join;
19824
+ var init_join = __esm(() => {
19825
+ init_format_heading_as_setext();
19826
+ init_html_kind();
19827
+ join = [joinDefaults];
19828
+ });
19829
+
19830
+ // ../../node_modules/mdast-util-to-markdown/lib/unsafe.js
19831
+ var fullPhrasingSpans, unsafe, code2 = -1;
19832
+ var init_unsafe = __esm(() => {
19833
+ fullPhrasingSpans = [
19834
+ "autolink",
19835
+ "destinationLiteral",
19836
+ "destinationRaw",
19837
+ "reference",
19838
+ "titleQuote",
19839
+ "titleApostrophe"
19840
+ ];
19841
+ unsafe = [
19842
+ { character: "\t", after: "[\\r\\n]", inConstruct: "phrasing" },
19843
+ { character: "\t", before: "[\\r\\n]", inConstruct: "phrasing" },
19844
+ {
19845
+ character: "\t",
19846
+ inConstruct: ["codeFencedLangGraveAccent", "codeFencedLangTilde"]
19847
+ },
19848
+ {
19849
+ character: "\r",
19850
+ inConstruct: [
19851
+ "codeFencedLangGraveAccent",
19852
+ "codeFencedLangTilde",
19853
+ "codeFencedMetaGraveAccent",
19854
+ "codeFencedMetaTilde",
19855
+ "destinationLiteral",
19856
+ "headingAtx"
19857
+ ]
19858
+ },
19859
+ {
19860
+ character: `
19861
+ `,
19862
+ inConstruct: [
19863
+ "codeFencedLangGraveAccent",
19864
+ "codeFencedLangTilde",
19865
+ "codeFencedMetaGraveAccent",
19866
+ "codeFencedMetaTilde",
19867
+ "destinationLiteral",
19868
+ "headingAtx"
19869
+ ]
19870
+ },
19871
+ { character: "\r", before: "[\\r\\n]", inConstruct: "phrasing" },
19872
+ { character: "\r", after: "\\r", inConstruct: "phrasing" },
19873
+ { character: `
19874
+ `, before: "\\n", inConstruct: "phrasing" },
19875
+ { character: `
19876
+ `, after: "[\\r\\n]", inConstruct: "phrasing" },
19877
+ { character: " ", after: "[\\r\\n]", inConstruct: "phrasing" },
19878
+ { character: " ", before: "[\\r\\n]", inConstruct: "phrasing" },
19879
+ {
19880
+ character: " ",
19881
+ inConstruct: ["codeFencedLangGraveAccent", "codeFencedLangTilde"]
19882
+ },
19883
+ {
19884
+ character: "!",
19885
+ after: "\\[",
19886
+ inConstruct: "phrasing",
19887
+ notInConstruct: fullPhrasingSpans
19888
+ },
19889
+ { character: '"', inConstruct: "titleQuote" },
19890
+ { atBreak: true, character: "#" },
19891
+ { character: "#", inConstruct: "headingAtx", after: `(?:[\r
19892
+ ]|$)` },
19893
+ {
19894
+ character: "&",
19895
+ after: "[#A-Za-z]",
19896
+ inConstruct: [
19897
+ "codeFencedLangGraveAccent",
19898
+ "codeFencedLangTilde",
19899
+ "codeFencedMetaGraveAccent",
19900
+ "codeFencedMetaTilde",
19901
+ "destinationLiteral",
19902
+ "destinationRaw",
19903
+ "phrasing",
19904
+ "titleApostrophe",
19905
+ "titleQuote"
19906
+ ]
19907
+ },
19908
+ { character: "'", inConstruct: "titleApostrophe" },
19909
+ { character: "(", inConstruct: "destinationRaw" },
19910
+ {
19911
+ before: "\\]",
19912
+ character: "(",
19913
+ inConstruct: "phrasing",
19914
+ notInConstruct: fullPhrasingSpans
19915
+ },
19916
+ { atBreak: true, before: "\\d+", character: ")" },
19917
+ { character: ")", inConstruct: "destinationRaw" },
19918
+ { atBreak: true, character: "*", after: `(?:[ \r
19919
+ *])` },
19920
+ { character: "*", inConstruct: "phrasing", notInConstruct: fullPhrasingSpans },
19921
+ { atBreak: true, character: "+", after: `(?:[ \r
19922
+ ])` },
19923
+ { atBreak: true, character: "-", after: `(?:[ \r
19924
+ -])` },
19925
+ { atBreak: true, before: "\\d+", character: ".", after: `(?:[ \r
19926
+ ]|$)` },
19927
+ { atBreak: true, character: "<", after: "[!/?A-Za-z]" },
19928
+ {
19929
+ character: "<",
19930
+ after: "[!/?A-Za-z]",
19931
+ inConstruct: "phrasing",
19932
+ notInConstruct: fullPhrasingSpans
19933
+ },
19934
+ { character: "<", inConstruct: "destinationLiteral" },
19935
+ { atBreak: true, character: "=" },
19936
+ { atBreak: true, character: ">" },
19937
+ { character: ">", inConstruct: "destinationLiteral" },
19938
+ { atBreak: true, character: "[" },
19939
+ { character: "[", inConstruct: "phrasing", notInConstruct: fullPhrasingSpans },
19940
+ { character: "[", inConstruct: ["label", "reference"] },
19941
+ { character: "\\", after: "[\\r\\n]", inConstruct: "phrasing" },
19942
+ { character: "]", inConstruct: ["label", "reference"] },
19943
+ { atBreak: true, character: "_" },
19944
+ { character: "_", inConstruct: "phrasing", notInConstruct: fullPhrasingSpans },
19945
+ { atBreak: true, character: "`" },
19946
+ {
19947
+ character: "`",
19948
+ inConstruct: ["codeFencedLangGraveAccent", "codeFencedMetaGraveAccent"]
19949
+ },
19950
+ { character: "`", inConstruct: "phrasing", notInConstruct: fullPhrasingSpans },
19951
+ { atBreak: true, character: "~" },
19952
+ { character: "<", inConstruct: "autolink" },
19953
+ { character: ">", inConstruct: "autolink" },
19954
+ { character: "", inConstruct: "autolink" }
19955
+ ];
19956
+ while (++code2 < 33) {
19957
+ unsafe.push({ character: String.fromCharCode(code2), inConstruct: "autolink" });
19804
19958
  }
19805
- indexStack.pop();
19806
- return results;
19807
- }
19808
- function render(items, chosen, before, after) {
19809
- const tokens = [];
19810
- let encodeAfter;
19811
- let previous = lastCharacter(before);
19812
- let index = -1;
19813
- while (++index < items.length) {
19814
- const item = items[index];
19815
- if (typeof item === "string") {
19816
- const token = { value: item, attention: undefined };
19817
- if (encodeAfter && encodeAfter === firstCharacter(item)) {
19818
- encode([token], true);
19819
- }
19820
- encodeAfter = undefined;
19821
- tokens.push(token);
19822
- if (token.value)
19823
- previous = lastCharacter(token.value);
19824
- continue;
19825
- }
19826
- const sequence = chosen.get(item) || item.sequences[0];
19827
- const marker = sequence.charAt(0);
19828
- const next = items[index + 1];
19829
- const outsideBefore = previous;
19830
- const outsideAfter = firstCharacter(next === undefined ? after : typeof next === "string" ? next : chosen.get(next) || next.sequences[0]);
19831
- const inside = render(item.children, chosen, sequence, sequence);
19832
- const head = inside.length > 0 ? inside[0].value : "";
19833
- const open = encodeInfo(outsideBefore.charCodeAt(outsideBefore.length - 1), head.charCodeAt(0), marker);
19834
- if (open.inside)
19835
- encode(inside, true);
19836
- const tail = inside.length > 0 ? lastCharacter(inside[inside.length - 1].value) : "";
19837
- const close = encodeInfo(outsideAfter.charCodeAt(0), tail.charCodeAt(tail.length - 1), marker);
19838
- if (close.inside)
19839
- encode(inside, false);
19840
- if (open.outside && outsideBefore !== `
19841
- ` && outsideBefore !== "\r") {
19842
- encode(tokens, false);
19843
- }
19844
- if (close.outside)
19845
- encodeAfter = outsideAfter;
19846
- tokens.push({ value: sequence, attention: item }, ...inside, {
19847
- value: sequence,
19848
- attention: item
19849
- });
19850
- previous = sequence.charAt(sequence.length - 1);
19959
+ });
19960
+
19961
+ // ../../node_modules/mdast-util-to-markdown/lib/util/association.js
19962
+ function association(node) {
19963
+ if (node.label || !node.identifier) {
19964
+ return node.label || "";
19851
19965
  }
19852
- return tokens;
19966
+ return decodeString(node.identifier);
19853
19967
  }
19854
- function serialize2(items, before, after) {
19855
- let chosen = new Map;
19856
- const initial = render(items, chosen, before, after);
19857
- let tokens = initial;
19858
- let mistake = check(tokens, before, after);
19859
- while (mistake) {
19860
- const next = improve(items, chosen, mistake, before, after);
19861
- if (!next) {
19862
- tokens = initial;
19863
- break;
19864
- }
19865
- chosen = next.chosen;
19866
- tokens = next.tokens;
19867
- mistake = next.mistake;
19968
+ var init_association = __esm(() => {
19969
+ init_dev14();
19970
+ });
19971
+
19972
+ // ../../node_modules/mdast-util-to-markdown/lib/util/compile-pattern.js
19973
+ function compilePattern(pattern) {
19974
+ if (!pattern._compiled) {
19975
+ const before = (pattern.atBreak ? "[\\r\\n][\\t ]*" : "") + (pattern.before ? "(?:" + pattern.before + ")" : "");
19976
+ pattern._compiled = new RegExp((pattern.beforeNode ? "^" : before ? "(" + before + ")" : "") + (/[$()*+.?[\\\]^{|}]/.test(pattern.character) ? "\\" : "") + pattern.character + (pattern.afterNode ? "$" : pattern.after ? "(?:" + pattern.after + ")" : ""), pattern.unicode ? "gu" : "g");
19868
19977
  }
19869
- let result = "";
19870
- for (const token of tokens)
19871
- result += token.value;
19872
- return result;
19978
+ return pattern._compiled;
19873
19979
  }
19874
- var builtins;
19875
- var init_container_phrasing = __esm(() => {
19876
- init_dev4();
19877
- init_dev6();
19878
- init_encode_info();
19879
- init_html_kind();
19880
- builtins = new Map([
19881
- ["*", false],
19882
- ["_", true]
19883
- ]);
19884
- });
19885
19980
 
19886
19981
  // ../../node_modules/mdast-util-to-markdown/lib/util/container-flow.js
19887
19982
  function containerFlow(parent, state, info) {
@@ -20013,22 +20108,20 @@ function safe(state, input, config) {
20013
20108
  continue;
20014
20109
  }
20015
20110
  }
20016
- 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) {
20111
+ 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) {
20017
20112
  continue;
20018
20113
  }
20019
20114
  if (start !== position) {
20020
20115
  const slice = value.slice(start, position);
20021
20116
  result.push(percentEncode ? slice : escapeBackslashes(slice, "\\"));
20022
20117
  }
20023
- start = position;
20118
+ start = position + 1;
20024
20119
  if (percentEncode) {
20025
20120
  result.push("%" + value.charCodeAt(position).toString(16).toUpperCase().padStart(2, "0"));
20026
- start++;
20027
20121
  } else if (/[!-/:-@[-`{-~]/.test(value.charAt(position)) && (!config.encode || !config.encode.includes(value.charAt(position)))) {
20028
- result.push("\\");
20122
+ result.push("\\" + value.charAt(position));
20029
20123
  } else {
20030
20124
  result.push(encodeCharacterReference(value.charCodeAt(position)));
20031
- start++;
20032
20125
  }
20033
20126
  }
20034
20127
  const rest = value.slice(start, end);
@@ -22561,84 +22654,9 @@ var init_stringify_entities = __esm(() => {
22561
22654
  init_lib23();
22562
22655
  });
22563
22656
 
22564
- // ../../node_modules/mdast-util-directive/node_modules/unist-util-visit-parents/lib/color.node.js
22565
- function color3(d) {
22566
- return "\x1B[33m" + d + "\x1B[39m";
22567
- }
22568
-
22569
- // ../../node_modules/mdast-util-directive/node_modules/unist-util-visit-parents/lib/index.js
22570
- function visitParents3(tree, test, visitor, reverse) {
22571
- let check;
22572
- if (typeof test === "function" && typeof visitor !== "function") {
22573
- reverse = visitor;
22574
- visitor = test;
22575
- } else {
22576
- check = test;
22577
- }
22578
- const is = convert(check);
22579
- const step = reverse ? -1 : 1;
22580
- factory(tree, undefined, [])();
22581
- function factory(node, index, parents) {
22582
- const value = node && typeof node === "object" ? node : {};
22583
- if (typeof value.type === "string") {
22584
- const name = typeof value.tagName === "string" ? value.tagName : typeof value.name === "string" ? value.name : undefined;
22585
- Object.defineProperty(visit, "name", {
22586
- value: "node (" + color3(node.type + (name ? "<" + name + ">" : "")) + ")"
22587
- });
22588
- }
22589
- return visit;
22590
- function visit() {
22591
- let result = empty3;
22592
- let subresult;
22593
- let offset;
22594
- let grandparents;
22595
- if (!test || is(node, index, parents[parents.length - 1] || undefined)) {
22596
- result = toResult3(visitor(node, parents));
22597
- if (result[0] === EXIT3) {
22598
- return result;
22599
- }
22600
- }
22601
- if ("children" in node && node.children) {
22602
- const nodeAsParent = node;
22603
- if (nodeAsParent.children && result[0] !== SKIP3) {
22604
- offset = (reverse ? nodeAsParent.children.length : -1) + step;
22605
- grandparents = parents.concat(nodeAsParent);
22606
- while (offset > -1 && offset < nodeAsParent.children.length) {
22607
- const child = nodeAsParent.children[offset];
22608
- subresult = factory(child, offset, grandparents)();
22609
- if (subresult[0] === EXIT3) {
22610
- return subresult;
22611
- }
22612
- offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
22613
- }
22614
- }
22615
- }
22616
- return result;
22617
- }
22618
- }
22619
- }
22620
- function toResult3(value) {
22621
- if (Array.isArray(value)) {
22622
- return value;
22623
- }
22624
- if (typeof value === "number") {
22625
- return [CONTINUE3, value];
22626
- }
22627
- return value === null || value === undefined ? empty3 : [value];
22628
- }
22629
- var empty3, CONTINUE3 = true, EXIT3 = false, SKIP3 = "skip";
22630
- var init_lib24 = __esm(() => {
22631
- init_unist_util_is();
22632
- empty3 = [];
22633
- });
22634
-
22635
- // ../../node_modules/mdast-util-directive/node_modules/unist-util-visit-parents/index.js
22636
- var init_unist_util_visit_parents3 = __esm(() => {
22637
- init_lib24();
22638
- });
22639
-
22640
22657
  // ../../node_modules/mdast-util-directive/lib/index.js
22641
- function directiveFromMarkdown() {
22658
+ function directiveFromMarkdown(options) {
22659
+ const settings = options || emptyFromMarkdownOptions;
22642
22660
  return {
22643
22661
  canContainEols: ["textDirective"],
22644
22662
  enter: {
@@ -22652,29 +22670,57 @@ function directiveFromMarkdown() {
22652
22670
  },
22653
22671
  exit: {
22654
22672
  directiveContainer: exit3,
22673
+ directiveContainerAttributeClass: exitAttributeShortcut,
22655
22674
  directiveContainerAttributeClassValue: exitAttributeClassValue,
22675
+ directiveContainerAttributeId: exitAttributeShortcut,
22656
22676
  directiveContainerAttributeIdValue: exitAttributeIdValue,
22657
22677
  directiveContainerAttributeName: exitAttributeName,
22658
22678
  directiveContainerAttributeValue: exitAttributeValue,
22679
+ directiveContainerAttributeValueLiteral: exitAttributeValueLiteral,
22659
22680
  directiveContainerAttributes: exitAttributes,
22660
22681
  directiveContainerLabel: exitContainerLabel,
22661
22682
  directiveContainerName: exitName,
22683
+ directiveContainerSequence: exitSequence,
22662
22684
  directiveLeaf: exit3,
22685
+ directiveLeafAttributeClass: exitAttributeShortcut,
22663
22686
  directiveLeafAttributeClassValue: exitAttributeClassValue,
22687
+ directiveLeafAttributeId: exitAttributeShortcut,
22664
22688
  directiveLeafAttributeIdValue: exitAttributeIdValue,
22665
22689
  directiveLeafAttributeName: exitAttributeName,
22666
22690
  directiveLeafAttributeValue: exitAttributeValue,
22691
+ directiveLeafAttributeValueLiteral: exitAttributeValueLiteral,
22667
22692
  directiveLeafAttributes: exitAttributes,
22693
+ directiveLeafLabel: exitLabel,
22668
22694
  directiveLeafName: exitName,
22695
+ directiveLeafSequence: exitSequence,
22669
22696
  directiveText: exit3,
22697
+ directiveTextAttributeClass: exitAttributeShortcut,
22670
22698
  directiveTextAttributeClassValue: exitAttributeClassValue,
22699
+ directiveTextAttributeId: exitAttributeShortcut,
22671
22700
  directiveTextAttributeIdValue: exitAttributeIdValue,
22672
22701
  directiveTextAttributeName: exitAttributeName,
22673
22702
  directiveTextAttributeValue: exitAttributeValue,
22703
+ directiveTextAttributeValueLiteral: exitAttributeValueLiteral,
22674
22704
  directiveTextAttributes: exitAttributes,
22705
+ directiveTextLabel: exitLabel,
22706
+ directiveTextMarker: exitSequence,
22675
22707
  directiveTextName: exitName
22676
22708
  }
22677
22709
  };
22710
+ function exitSequence(token) {
22711
+ if (!settings.verbose)
22712
+ return;
22713
+ const node = this.stack[this.stack.length - 1];
22714
+ ok(node, "expected `node`");
22715
+ ok(node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective");
22716
+ const place = { start: point3(token.start), end: point3(token.end) };
22717
+ if (node.data && node.data.position) {
22718
+ ok(node.type === "containerDirective");
22719
+ node.data.position.closing = place;
22720
+ } else {
22721
+ node.data = { position: { opening: place } };
22722
+ }
22723
+ }
22678
22724
  }
22679
22725
  function directiveToMarkdown(options) {
22680
22726
  const settings = options || emptyOptions4;
@@ -22711,8 +22757,20 @@ function directiveToMarkdown(options) {
22711
22757
  };
22712
22758
  function handleDirective(node, _, state, info) {
22713
22759
  const tracker = state.createTracker(info);
22714
- const sequence = fence3(node);
22715
22760
  const exit = state.enter(node.type);
22761
+ let content;
22762
+ if (node.type === "containerDirective") {
22763
+ const head = (node.children || [])[0];
22764
+ const children = inlineDirectiveLabel(head) ? node.children.slice(1) : node.children;
22765
+ if (children && children.length > 0) {
22766
+ const current = tracker.current();
22767
+ content = state.containerFlow({ ...node, children }, {
22768
+ now: { line: current.now.line + 1, column: 1 + current.lineShift },
22769
+ lineShift: current.lineShift
22770
+ });
22771
+ }
22772
+ }
22773
+ const sequence = fence3(node, content ? longestColonLine(content) : 0);
22716
22774
  let value = tracker.move(sequence + (node.name || ""));
22717
22775
  const attributesValue = attributes(node, state);
22718
22776
  const after = info.after.charCodeAt(0);
@@ -22741,15 +22799,9 @@ function directiveToMarkdown(options) {
22741
22799
  }
22742
22800
  value += tracker.move(attributesValue || (after === 123 ? "{}" : ""));
22743
22801
  if (node.type === "containerDirective") {
22744
- const head = (node.children || [])[0];
22745
- let shallow = node;
22746
- if (inlineDirectiveLabel(head)) {
22747
- shallow = Object.assign({}, node, { children: node.children.slice(1) });
22748
- }
22749
- if (shallow && shallow.children && shallow.children.length > 0) {
22802
+ if (content) {
22750
22803
  value += tracker.move(`
22751
- `);
22752
- value += tracker.move(state.containerFlow(shallow, tracker.current()));
22804
+ ` + content);
22753
22805
  }
22754
22806
  value += tracker.move(`
22755
22807
  ` + sequence);
@@ -22766,16 +22818,15 @@ function directiveToMarkdown(options) {
22766
22818
  let key;
22767
22819
  for (key in attributes) {
22768
22820
  if (own9.call(attributes, key) && attributes[key] !== undefined && attributes[key] !== null) {
22769
- const value = String(attributes[key]);
22821
+ const value = encode2(String(attributes[key]));
22770
22822
  if (key === "id") {
22771
22823
  id = settings.preferShortcut !== false && shortcut.test(value) ? "#" + value : quoted("id", value, node, state);
22772
22824
  } else if (key === "class") {
22773
22825
  const list = value.split(/[\t\n\r ]+/);
22774
22826
  const classesFullList = [];
22775
22827
  const classesList = [];
22776
- let index = -1;
22777
- while (++index < list.length) {
22778
- (settings.preferShortcut !== false && shortcut.test(list[index]) ? classesList : classesFullList).push(list[index]);
22828
+ for (const item of list) {
22829
+ (settings.preferShortcut !== false && shortcut.test(item) ? classesList : classesFullList).push(item);
22779
22830
  }
22780
22831
  classesFull = classesFullList.length > 0 ? quoted("class", classesFullList.join(" "), node, state) : "";
22781
22832
  classes = classesList.length > 0 ? "." + classesList.join(".") : "";
@@ -22823,19 +22874,50 @@ function enter(type, token) {
22823
22874
  }
22824
22875
  function exitName(token) {
22825
22876
  const node = this.stack[this.stack.length - 1];
22877
+ ok(node, "expected `node`");
22826
22878
  ok(node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective");
22827
22879
  node.name = this.sliceSerialize(token);
22880
+ openingEnd(node, token);
22828
22881
  }
22829
22882
  function enterContainerLabel(token) {
22830
22883
  this.enter({ type: "paragraph", data: { directiveLabel: true }, children: [] }, token);
22831
22884
  }
22832
22885
  function exitContainerLabel(token) {
22833
22886
  this.exit(token);
22887
+ const node = this.stack[this.stack.length - 1];
22888
+ ok(node, "expected `node`");
22889
+ ok(node.type === "containerDirective");
22890
+ openingEnd(node, token);
22891
+ }
22892
+ function exitLabel(token) {
22893
+ const node = this.stack[this.stack.length - 1];
22894
+ ok(node, "expected `node`");
22895
+ ok(node.type === "leafDirective" || node.type === "textDirective");
22896
+ openingEnd(node, token);
22834
22897
  }
22835
22898
  function enterAttributes() {
22899
+ const node = this.stack[this.stack.length - 1];
22900
+ ok(node, "expected `node`");
22901
+ ok(node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective");
22902
+ if (node.data && node.data.position) {
22903
+ this.data.directiveAttributePositions = {};
22904
+ }
22836
22905
  this.data.directiveAttributes = [];
22837
22906
  this.buffer();
22838
22907
  }
22908
+ function exitAttributeShortcut(token) {
22909
+ const positions = this.data.directiveAttributePositions;
22910
+ if (positions) {
22911
+ const list = this.data.directiveAttributes;
22912
+ ok(list, "expected `directiveAttributes`");
22913
+ const tail = list[list.length - 1];
22914
+ ok(tail, "expected attribute");
22915
+ positions[tail[0]] = { start: point3(token.start), end: point3(token.end) };
22916
+ }
22917
+ }
22918
+ function exitAttributeValueLiteral(token) {
22919
+ attributeEnd(this, token);
22920
+ }
22839
22921
  function exitAttributeIdValue(token) {
22840
22922
  const list = this.data.directiveAttributes;
22841
22923
  ok(list, "expected `directiveAttributes`");
@@ -22855,33 +22937,67 @@ function exitAttributeClassValue(token) {
22855
22937
  function exitAttributeValue(token) {
22856
22938
  const list = this.data.directiveAttributes;
22857
22939
  ok(list, "expected `directiveAttributes`");
22858
- list[list.length - 1][1] = parseEntities(this.sliceSerialize(token), {
22859
- attribute: true
22860
- });
22940
+ const tail = list[list.length - 1];
22941
+ ok(tail, "expected attribute");
22942
+ tail[1] = parseEntities(this.sliceSerialize(token), { attribute: true });
22943
+ attributeEnd(this, token);
22861
22944
  }
22862
22945
  function exitAttributeName(token) {
22863
22946
  const list = this.data.directiveAttributes;
22864
22947
  ok(list, "expected `directiveAttributes`");
22865
- list.push([this.sliceSerialize(token), ""]);
22948
+ const name = this.sliceSerialize(token);
22949
+ list.push([name, ""]);
22950
+ const positions = this.data.directiveAttributePositions;
22951
+ if (positions) {
22952
+ positions[name] = { start: point3(token.start), end: point3(token.end) };
22953
+ }
22866
22954
  }
22867
- function exitAttributes() {
22955
+ function exitAttributes(token) {
22868
22956
  const list = this.data.directiveAttributes;
22869
22957
  ok(list, "expected `directiveAttributes`");
22870
22958
  const cleaned = {};
22871
- let index = -1;
22872
- while (++index < list.length) {
22873
- const attribute = list[index];
22959
+ for (const attribute of list) {
22874
22960
  if (attribute[0] === "class" && cleaned.class) {
22875
22961
  cleaned.class += " " + attribute[1];
22876
22962
  } else {
22877
22963
  cleaned[attribute[0]] = attribute[1];
22878
22964
  }
22879
22965
  }
22966
+ const positions = this.data.directiveAttributePositions;
22967
+ this.data.directiveAttributePositions = undefined;
22880
22968
  this.data.directiveAttributes = undefined;
22881
22969
  this.resume();
22882
22970
  const node = this.stack[this.stack.length - 1];
22971
+ ok(node, "expected `node`");
22883
22972
  ok(node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective");
22884
22973
  node.attributes = cleaned;
22974
+ if (positions) {
22975
+ ok(node.data && node.data.position, "expected `position`");
22976
+ node.data.position.attributes = positions;
22977
+ }
22978
+ openingEnd(node, token);
22979
+ }
22980
+ function openingEnd(node, token) {
22981
+ if (node.data && node.data.position) {
22982
+ const { opening } = node.data.position;
22983
+ ok(opening, "expected `opening`");
22984
+ opening.end = point3(token.end);
22985
+ }
22986
+ }
22987
+ function attributeEnd(context, token) {
22988
+ const positions = context.data.directiveAttributePositions;
22989
+ if (positions) {
22990
+ const list = context.data.directiveAttributes;
22991
+ ok(list, "expected `directiveAttributes`");
22992
+ const tail = list[list.length - 1];
22993
+ ok(tail, "expected attribute");
22994
+ const position = positions[tail[0]];
22995
+ ok(position, "expected position");
22996
+ position.end = point3(token.end);
22997
+ }
22998
+ }
22999
+ function point3(d) {
23000
+ return { line: d.line, column: d.column, offset: d.offset };
22885
23001
  }
22886
23002
  function exit3(token) {
22887
23003
  this.exit(token);
@@ -22889,26 +23005,28 @@ function exit3(token) {
22889
23005
  function peekDirective() {
22890
23006
  return ":";
22891
23007
  }
23008
+ function encode2(value) {
23009
+ const result = [];
23010
+ let start = 0;
23011
+ let index = value.indexOf("&");
23012
+ while (index !== -1) {
23013
+ const code = value.charCodeAt(index + 1);
23014
+ if (code === 35 || asciiAlpha(code)) {
23015
+ result.push(value.slice(start, index), "&#x26;");
23016
+ start = index + 1;
23017
+ }
23018
+ index = value.indexOf("&", index + 1);
23019
+ }
23020
+ result.push(value.slice(start));
23021
+ return result.join("");
23022
+ }
22892
23023
  function inlineDirectiveLabel(node) {
22893
23024
  return Boolean(node && node.type === "paragraph" && node.data && node.data.directiveLabel);
22894
23025
  }
22895
- function fence3(node) {
23026
+ function fence3(node, longest) {
22896
23027
  let size = 0;
22897
23028
  if (node.type === "containerDirective") {
22898
- visitParents3(node, function(node, parents) {
22899
- if (node.type === "containerDirective") {
22900
- let index = parents.length;
22901
- let nesting = 0;
22902
- while (index--) {
22903
- if (parents[index].type === "containerDirective") {
22904
- nesting++;
22905
- }
22906
- }
22907
- if (nesting > size)
22908
- size = nesting;
22909
- }
22910
- });
22911
- size += 3;
23029
+ size = Math.max(3, longest + 1);
22912
23030
  } else if (node.type === "leafDirective") {
22913
23031
  size = 2;
22914
23032
  } else {
@@ -22916,14 +23034,40 @@ function fence3(node) {
22916
23034
  }
22917
23035
  return ":".repeat(size);
22918
23036
  }
22919
- var own9, emptyOptions4, shortcut, unquoted;
22920
- var init_lib25 = __esm(() => {
23037
+ function longestColonLine(value) {
23038
+ let longest = 0;
23039
+ let index = 0;
23040
+ while (index < value.length) {
23041
+ let size = 0;
23042
+ let code = value.charCodeAt(index);
23043
+ while (code === 9 || code === 32) {
23044
+ code = value.charCodeAt(++index);
23045
+ }
23046
+ while (code === 58) {
23047
+ size++;
23048
+ code = value.charCodeAt(++index);
23049
+ }
23050
+ while (code === 9 || code === 32) {
23051
+ code = value.charCodeAt(++index);
23052
+ }
23053
+ while (!(code === 10 || code === 13 || Number.isNaN(code))) {
23054
+ size = 0;
23055
+ code = value.charCodeAt(++index);
23056
+ }
23057
+ if (size > longest)
23058
+ longest = size;
23059
+ index++;
23060
+ }
23061
+ return longest;
23062
+ }
23063
+ var own9, emptyFromMarkdownOptions, emptyOptions4, shortcut, unquoted;
23064
+ var init_lib24 = __esm(() => {
22921
23065
  init_development();
22922
23066
  init_dev4();
22923
23067
  init_parse_entities();
22924
23068
  init_stringify_entities();
22925
- init_unist_util_visit_parents3();
22926
23069
  own9 = {}.hasOwnProperty;
23070
+ emptyFromMarkdownOptions = {};
22927
23071
  emptyOptions4 = {};
22928
23072
  shortcut = /^[^\t\n\r "#'.<=>`}]+$/;
22929
23073
  unquoted = /^[^\t\n\r "'<=>`}]+$/;
@@ -22931,7 +23075,7 @@ var init_lib25 = __esm(() => {
22931
23075
 
22932
23076
  // ../../node_modules/mdast-util-directive/index.js
22933
23077
  var init_mdast_util_directive = __esm(() => {
22934
- init_lib25();
23078
+ init_lib24();
22935
23079
  });
22936
23080
 
22937
23081
  // ../../node_modules/micromark-extension-directive/dev/lib/factory-attributes.js
@@ -23547,14 +23691,14 @@ function remarkDirective() {
23547
23691
  fromMarkdownExtensions.push(directiveFromMarkdown());
23548
23692
  toMarkdownExtensions.push(directiveToMarkdown());
23549
23693
  }
23550
- var init_lib26 = __esm(() => {
23694
+ var init_lib25 = __esm(() => {
23551
23695
  init_mdast_util_directive();
23552
23696
  init_dev22();
23553
23697
  });
23554
23698
 
23555
23699
  // ../../node_modules/remark-directive/index.js
23556
23700
  var init_remark_directive = __esm(() => {
23557
- init_lib26();
23701
+ init_lib25();
23558
23702
  });
23559
23703
 
23560
23704
  // ../../node_modules/property-information/lib/util/schema.js
@@ -24814,13 +24958,13 @@ function parseSelector(selector, defaultTagName) {
24814
24958
  };
24815
24959
  }
24816
24960
  var search2;
24817
- var init_lib27 = __esm(() => {
24961
+ var init_lib26 = __esm(() => {
24818
24962
  search2 = /[#.]/g;
24819
24963
  });
24820
24964
 
24821
24965
  // ../../node_modules/hast-util-parse-selector/index.js
24822
24966
  var init_hast_util_parse_selector = __esm(() => {
24823
- init_lib27();
24967
+ init_lib26();
24824
24968
  });
24825
24969
 
24826
24970
  // ../../node_modules/space-separated-tokens/index.js
@@ -24857,7 +25001,7 @@ function createH(schema, defaultTagName, caseSensitive) {
24857
25001
  for (const child of children) {
24858
25002
  addChild(node.children, child);
24859
25003
  }
24860
- if (node.type === "element" && node.tagName === "template") {
25004
+ if (node.type === "element" && node.tagName === "template" && schema.space === "html") {
24861
25005
  node.content = { type: "root", children: node.children };
24862
25006
  node.children = [];
24863
25007
  }
@@ -24892,10 +25036,10 @@ function isChild(value) {
24892
25036
  return false;
24893
25037
  }
24894
25038
  function addProperty(schema, properties, key, value) {
24895
- const info = find(schema, key);
24896
- let result;
24897
25039
  if (value === null || value === undefined)
24898
25040
  return;
25041
+ const info = find(schema, key);
25042
+ let result;
24899
25043
  if (typeof value === "number") {
24900
25044
  if (Number.isNaN(value))
24901
25045
  return;
@@ -24925,7 +25069,8 @@ function addProperty(schema, properties, key, value) {
24925
25069
  result = finalResult;
24926
25070
  }
24927
25071
  if (info.property === "className" && Array.isArray(properties.className)) {
24928
- result = properties.className.concat(result);
25072
+ const add = result;
25073
+ result = [...properties.className, ...Array.isArray(add) ? add : [add]];
24929
25074
  }
24930
25075
  properties[info.property] = result;
24931
25076
  }
@@ -25024,7 +25169,7 @@ var init_svg_case_sensitive_tag_names = __esm(() => {
25024
25169
 
25025
25170
  // ../../node_modules/hastscript/lib/index.js
25026
25171
  var h, s;
25027
- var init_lib28 = __esm(() => {
25172
+ var init_lib27 = __esm(() => {
25028
25173
  init_property_information();
25029
25174
  init_create_h();
25030
25175
  init_svg_case_sensitive_tag_names();
@@ -25034,7 +25179,7 @@ var init_lib28 = __esm(() => {
25034
25179
 
25035
25180
  // ../../node_modules/hastscript/index.js
25036
25181
  var init_hastscript = __esm(() => {
25037
- init_lib28();
25182
+ init_lib27();
25038
25183
  });
25039
25184
 
25040
25185
  // ../../node_modules/vfile-location/lib/index.js
@@ -25174,7 +25319,7 @@ function all2(state, nodes) {
25174
25319
  return results;
25175
25320
  }
25176
25321
  function element(state, node) {
25177
- const schema = state.schema;
25322
+ const { schema } = state;
25178
25323
  state.schema = node.namespaceURI === webNamespaces.svg ? svg2 : html3;
25179
25324
  let index = -1;
25180
25325
  const properties = {};
@@ -25189,15 +25334,20 @@ function element(state, node) {
25189
25334
  const result = x(node.tagName, properties, all2(state, node.childNodes));
25190
25335
  patch(state, node, result);
25191
25336
  if (result.tagName === "template") {
25192
- const reference = node;
25193
- const pos = reference.sourceCodeLocation;
25194
- const startTag = pos && pos.startTag && position2(pos.startTag);
25195
- const endTag = pos && pos.endTag && position2(pos.endTag);
25196
- const content = one2(state, reference.content);
25197
- if (startTag && endTag && state.file) {
25198
- content.position = { start: startTag.end, end: endTag.start };
25337
+ if (node.namespaceURI === webNamespaces.html) {
25338
+ const reference = node;
25339
+ const pos = reference.sourceCodeLocation;
25340
+ const startTag = pos && pos.startTag && position2(pos.startTag);
25341
+ const endTag = pos && pos.endTag && position2(pos.endTag);
25342
+ const content = one2(state, reference.content);
25343
+ if (startTag && endTag && state.file) {
25344
+ content.position = { start: startTag.end, end: endTag.start };
25345
+ }
25346
+ result.content = content;
25347
+ } else if (result.content) {
25348
+ result.children = result.content.children;
25349
+ delete result.content;
25199
25350
  }
25200
- result.content = content;
25201
25351
  }
25202
25352
  state.schema = schema;
25203
25353
  return result;
@@ -25241,23 +25391,23 @@ function createLocation(state, node, location) {
25241
25391
  return result;
25242
25392
  }
25243
25393
  function position2(loc) {
25244
- const start = point3({
25394
+ const start = point4({
25245
25395
  line: loc.startLine,
25246
25396
  column: loc.startCol,
25247
25397
  offset: loc.startOffset
25248
25398
  });
25249
- const end = point3({
25399
+ const end = point4({
25250
25400
  line: loc.endLine,
25251
25401
  column: loc.endCol,
25252
25402
  offset: loc.endOffset
25253
25403
  });
25254
25404
  return start || end ? { start, end } : undefined;
25255
25405
  }
25256
- function point3(point) {
25406
+ function point4(point) {
25257
25407
  return point.line && point.column ? point : undefined;
25258
25408
  }
25259
25409
  var own10, proto;
25260
- var init_lib29 = __esm(() => {
25410
+ var init_lib28 = __esm(() => {
25261
25411
  init_development();
25262
25412
  init_hastscript();
25263
25413
  init_property_information();
@@ -25269,7 +25419,7 @@ var init_lib29 = __esm(() => {
25269
25419
 
25270
25420
  // ../../node_modules/hast-util-from-parse5/index.js
25271
25421
  var init_hast_util_from_parse5 = __esm(() => {
25272
- init_lib29();
25422
+ init_lib28();
25273
25423
  });
25274
25424
 
25275
25425
  // ../../node_modules/parse5/dist/common/unicode.js
@@ -33162,7 +33312,7 @@ function visualizeCharacterCode(charCode) {
33162
33312
  return "0x" + charCode.toString(16).toUpperCase();
33163
33313
  }
33164
33314
  var base = "https://html.spec.whatwg.org/multipage/parsing.html#parse-error-", dashToCamelRe, formatCRe, formatXRe, fatalities, emptyOptions5;
33165
- var init_lib30 = __esm(() => {
33315
+ var init_lib29 = __esm(() => {
33166
33316
  init_development();
33167
33317
  init_hast_util_from_parse5();
33168
33318
  init_dist2();
@@ -33178,24 +33328,24 @@ var init_lib30 = __esm(() => {
33178
33328
 
33179
33329
  // ../../node_modules/hast-util-from-html/index.js
33180
33330
  var init_hast_util_from_html = __esm(() => {
33181
- init_lib30();
33331
+ init_lib29();
33182
33332
  });
33183
33333
 
33184
33334
  // ../../node_modules/hast-util-whitespace/lib/index.js
33185
33335
  function whitespace(thing) {
33186
- return typeof thing === "object" ? thing.type === "text" ? empty4(thing.value) : false : empty4(thing);
33336
+ return typeof thing === "object" ? thing.type === "text" ? empty3(thing.value) : false : empty3(thing);
33187
33337
  }
33188
- function empty4(value) {
33338
+ function empty3(value) {
33189
33339
  return value.replace(re, "") === "";
33190
33340
  }
33191
33341
  var re;
33192
- var init_lib31 = __esm(() => {
33342
+ var init_lib30 = __esm(() => {
33193
33343
  re = /[ \t\n\f\r]/g;
33194
33344
  });
33195
33345
 
33196
33346
  // ../../node_modules/hast-util-whitespace/index.js
33197
33347
  var init_hast_util_whitespace = __esm(() => {
33198
- init_lib31();
33348
+ init_lib30();
33199
33349
  });
33200
33350
 
33201
33351
  // ../../packages/markup/src/html-to-jx.ts