@mintlify/cli 4.0.1463 → 4.0.1465

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.
@@ -829,7 +829,13 @@ var marks = {
829
829
  strike: {},
830
830
  code: {},
831
831
  link: {
832
- attrs: attrs({ href: null, title: null })
832
+ attrs: attrs({
833
+ href: null,
834
+ title: null,
835
+ referenceLabel: null,
836
+ mdxLinkAttributes: null,
837
+ mdxLinkId: null
838
+ })
833
839
  },
834
840
  underline: {},
835
841
  subscript: {},
@@ -847,9 +853,6 @@ function createSchema(extra) {
847
853
  import { Node } from "prosemirror-model";
848
854
  import { visit as visit2 } from "unist-util-visit";
849
855
 
850
- // ../editor/dist/converter/parse/handlers/flow-jsx.js
851
- import { parseTitleMarkdown } from "@mintlify/common/title-markdown";
852
-
853
856
  // ../editor/dist/converter/utils/mdx-attributes.js
854
857
  var EXPRESSION_ATTRS_KEY = "__expressionAttributes";
855
858
  var NAMED_EXPRESSION_ATTRS_KEY = "__namedExpressionAttributes";
@@ -997,6 +1000,9 @@ function partitionAttrs(parsed, known, consumed = []) {
997
1000
  return result;
998
1001
  }
999
1002
 
1003
+ // ../editor/dist/converter/parse/handlers/flow-jsx.js
1004
+ import { parseTitleMarkdown } from "@mintlify/common/title-markdown";
1005
+
1000
1006
  // ../editor/dist/converter/parse/parse-utils.js
1001
1007
  import { parse as parseYaml } from "yaml";
1002
1008
  function extractFrontmatter(mdast) {
@@ -2410,7 +2416,7 @@ function buildMarkdownTableCellContent(children, ctx, transformNode2) {
2410
2416
  flushInlineChildren();
2411
2417
  return cellContent;
2412
2418
  }
2413
- const isInlineOnly = children.every((child) => child.type === "text" || child.type === "emphasis" || child.type === "strong" || child.type === "link" || child.type === "inlineCode" || child.type === "delete" || child.type === "image" || child.type === "break" || child.type === "inlineMath" || child.type === "footnoteReference" || child.type === "mdxTextExpression" || child.type === "mdxJsxTextElement");
2419
+ const isInlineOnly = children.every((child) => child.type === "text" || child.type === "emphasis" || child.type === "strong" || child.type === "link" || child.type === "linkReference" || child.type === "inlineCode" || child.type === "delete" || child.type === "image" || child.type === "break" || child.type === "inlineMath" || child.type === "footnoteReference" || child.type === "mdxTextExpression" || child.type === "mdxJsxTextElement");
2414
2420
  if (isInlineOnly) {
2415
2421
  const paragraph = buildParagraphFromTableInlineChildren(children, ctx, transformNode2);
2416
2422
  return paragraph ? [paragraph] : [];
@@ -2422,7 +2428,7 @@ function handleParagraph(node, ctx, transformNode2, mapChildren2) {
2422
2428
  const schema2 = (_a = ctx.schema) !== null && _a !== void 0 ? _a : mintlifySchema;
2423
2429
  const hasImages = node.children.some((child) => child.type === "image" || child.type === "mdxJsxTextElement" && child.name === "img");
2424
2430
  if (hasImages) {
2425
- const hasTextContent = node.children.some((child) => child.type === "text" || child.type === "emphasis" || child.type === "strong" || child.type === "link" || child.type === "inlineCode" || child.type === "delete" || child.type === "mdxJsxTextElement" && child.name !== "img");
2431
+ const hasTextContent = node.children.some((child) => child.type === "text" || child.type === "emphasis" || child.type === "strong" || child.type === "link" || child.type === "linkReference" || child.type === "inlineCode" || child.type === "delete" || child.type === "mdxJsxTextElement" && child.name !== "img");
2426
2432
  if (hasTextContent) {
2427
2433
  const content2 = [];
2428
2434
  for (const child of node.children) {
@@ -2541,13 +2547,17 @@ function mdastToPm(mdast, source = "", options) {
2541
2547
  var _a, _b;
2542
2548
  const schema2 = (_a = options === null || options === void 0 ? void 0 : options.schema) !== null && _a !== void 0 ? _a : mintlifySchema;
2543
2549
  const frontmatter = extractFrontmatter(mdast);
2544
- const context = { source, frontmatter, schema: schema2 };
2550
+ const definitions = /* @__PURE__ */ new Map();
2545
2551
  visit2(mdast, (node) => {
2552
+ if (node.type === "definition" && !definitions.has(node.identifier)) {
2553
+ definitions.set(node.identifier, node);
2554
+ }
2546
2555
  const promptNeedsSourcePosition = node.type === "mdxJsxTextElement" && node.name === "Prompt";
2547
2556
  if (node.type !== "list" && node.type !== "mdxJsxFlowElement" && !promptNeedsSourcePosition) {
2548
2557
  delete node.position;
2549
2558
  }
2550
2559
  });
2560
+ const context = { source, frontmatter, schema: schema2, definitions };
2551
2561
  const content = transformNode(mdast, context);
2552
2562
  const rawJsonContent = Array.isArray(content) ? content : (_b = content.content) !== null && _b !== void 0 ? _b : [];
2553
2563
  const jsonContent = normalizeBlockContent(rawJsonContent, schema2);
@@ -2636,6 +2646,16 @@ function transformNode(node, ctx) {
2636
2646
  case "link":
2637
2647
  case "delete":
2638
2648
  return convertInlineContent(node.children, getMarks(node), ctx);
2649
+ case "linkReference": {
2650
+ const mark = getLinkReferenceMark(node, ctx);
2651
+ if (!mark) {
2652
+ return {
2653
+ type: BLOCK_TYPES.inlineUnknownTag,
2654
+ attrs: { mdxJsxNode: node }
2655
+ };
2656
+ }
2657
+ return convertInlineContent(node.children, [mark], ctx);
2658
+ }
2639
2659
  case "inlineCode": {
2640
2660
  const { text, marks: marks2 } = extractTextFromNode(node);
2641
2661
  return createTextNode(text, marks2);
@@ -2657,6 +2677,9 @@ function transformNode(node, ctx) {
2657
2677
  case "yaml":
2658
2678
  return [];
2659
2679
  case "mdxJsxTextElement": {
2680
+ const linkContent = convertLinkComponent(node, [], ctx);
2681
+ if (linkContent)
2682
+ return linkContent;
2660
2683
  if (!node.name || !STRUCTURED_FLOW_COMPONENTS.has(node.name) || isContainerOnlyComponent(node.name, (_d = ctx.schema) !== null && _d !== void 0 ? _d : mintlifySchema)) {
2661
2684
  return handleInlineJsx(node, ctx, mapChildren);
2662
2685
  }
@@ -2682,6 +2705,11 @@ function transformNode(node, ctx) {
2682
2705
  type: BLOCK_TYPES.inlineUnknownTag,
2683
2706
  attrs: { mdxJsxNode: node }
2684
2707
  };
2708
+ case "definition":
2709
+ return {
2710
+ type: BLOCK_TYPES.unknownTag,
2711
+ attrs: { mdxJsxNode: node, __isHidden: true }
2712
+ };
2685
2713
  default:
2686
2714
  return {
2687
2715
  type: BLOCK_TYPES.unknownTag,
@@ -2700,8 +2728,24 @@ function convertInlineContent(children, parentMarks, ctx) {
2700
2728
  results.push({ type: "hardBreak" });
2701
2729
  } else if (child.type === "inlineCode") {
2702
2730
  results.push(createTextNode(child.value || "", [...parentMarks, { type: "code" }]));
2731
+ } else if (child.type === "linkReference") {
2732
+ const mark = getLinkReferenceMark(child, ctx);
2733
+ if (mark) {
2734
+ results.push(...convertInlineContent(child.children, [...parentMarks, mark], ctx));
2735
+ } else {
2736
+ const converted = transformNode(child, ctx);
2737
+ results.push(...Array.isArray(converted) ? converted : [converted]);
2738
+ }
2703
2739
  } else if (child.type === "emphasis" || child.type === "strong" || child.type === "link" || child.type === "delete") {
2704
2740
  results.push(...convertInlineContent(child.children, [...parentMarks, ...getMarks(child)], ctx));
2741
+ } else if (child.type === "mdxJsxTextElement" && child.name === "Link") {
2742
+ const linkContent = convertLinkComponent(child, parentMarks, ctx);
2743
+ if (linkContent) {
2744
+ results.push(...linkContent);
2745
+ } else {
2746
+ const converted = transformNode(child, ctx);
2747
+ results.push(...Array.isArray(converted) ? converted : [converted]);
2748
+ }
2705
2749
  } else if (child.type === "mdxJsxTextElement" && (child.name === "u" || child.name === "sub" || child.name === "sup")) {
2706
2750
  results.push(...convertInlineContent(child.children, [...parentMarks, ...getMarks(child)], ctx));
2707
2751
  } else if (child.type === "mdxJsxTextElement" && child.name === "kbd") {
@@ -2723,6 +2767,62 @@ function convertInlineContent(children, parentMarks, ctx) {
2723
2767
  }
2724
2768
  return results;
2725
2769
  }
2770
+ function getLinkReferenceMark(node, ctx) {
2771
+ var _a, _b, _c, _d;
2772
+ const definition = (_a = ctx.definitions) === null || _a === void 0 ? void 0 : _a.get(node.identifier);
2773
+ if (!definition)
2774
+ return void 0;
2775
+ return {
2776
+ type: "link",
2777
+ attrs: {
2778
+ href: definition.url,
2779
+ title: (_b = definition.title) !== null && _b !== void 0 ? _b : void 0,
2780
+ referenceLabel: (_d = (_c = node.label) !== null && _c !== void 0 ? _c : definition.label) !== null && _d !== void 0 ? _d : node.identifier
2781
+ }
2782
+ };
2783
+ }
2784
+ function convertLinkComponent(node, parentMarks, ctx) {
2785
+ var _a;
2786
+ const mark = getLinkComponentMark(node, ctx);
2787
+ if (!mark)
2788
+ return void 0;
2789
+ const content = convertInlineContent(node.children, [...parentMarks, mark], ctx);
2790
+ const schema2 = (_a = ctx.schema) !== null && _a !== void 0 ? _a : mintlifySchema;
2791
+ const hasSerializableContent = content.every((child) => {
2792
+ var _a2, _b, _c, _d;
2793
+ if (!isInlineNode(child, schema2))
2794
+ return false;
2795
+ if (child.type !== "text" && child.type !== BLOCK_TYPES.inlineImage && child.type !== BLOCK_TYPES.inlineUnknownTag) {
2796
+ return false;
2797
+ }
2798
+ const linkMarks = (_b = (_a2 = child.marks) === null || _a2 === void 0 ? void 0 : _a2.filter((childMark) => childMark.type === "link")) !== null && _b !== void 0 ? _b : [];
2799
+ return linkMarks.length === 1 && ((_d = (_c = linkMarks[0]) === null || _c === void 0 ? void 0 : _c.attrs) === null || _d === void 0 ? void 0 : _d.mdxLinkAttributes) !== void 0;
2800
+ });
2801
+ return content.length > 0 && hasSerializableContent ? content : void 0;
2802
+ }
2803
+ function getLinkComponentMark(node, ctx) {
2804
+ var _a;
2805
+ if (node.name !== "Link")
2806
+ return void 0;
2807
+ if (node.attributes.some((attribute) => attribute.type === "mdxJsxExpressionAttribute")) {
2808
+ return void 0;
2809
+ }
2810
+ const hrefAttribute = node.attributes.find((attribute) => attribute.type === "mdxJsxAttribute" && attribute.name === "href");
2811
+ if (!hrefAttribute || typeof hrefAttribute.value !== "string")
2812
+ return void 0;
2813
+ const attributes = parseMdxAttributes(node.attributes);
2814
+ const mdxLinkId = (_a = ctx.nextMdxLinkId) !== null && _a !== void 0 ? _a : 0;
2815
+ ctx.nextMdxLinkId = mdxLinkId + 1;
2816
+ return {
2817
+ type: "link",
2818
+ attrs: {
2819
+ href: hrefAttribute.value,
2820
+ title: typeof attributes.title === "string" ? attributes.title : void 0,
2821
+ mdxLinkAttributes: attributes,
2822
+ mdxLinkId
2823
+ }
2824
+ };
2825
+ }
2726
2826
  function mapChildren(node, ctx) {
2727
2827
  const nodes2 = node.children.flatMap((child) => transformNode(child, ctx)).filter(Boolean);
2728
2828
  return mergeDarkLightImagePairs(nodes2);
@@ -10022,7 +10122,12 @@ function isWordChar(ch) {
10022
10122
  var SerializerState = class {
10023
10123
  constructor(options = {}) {
10024
10124
  var _a, _b, _c, _d;
10025
- this.out = "";
10125
+ this.chunks = [];
10126
+ this.chunkStarts = [];
10127
+ this.outLength = 0;
10128
+ this.tail = "";
10129
+ this.trailingSpaces = 0;
10130
+ this.topLevelLead = null;
10026
10131
  this.delim = "";
10027
10132
  this.closed = false;
10028
10133
  this.inTable = false;
@@ -10040,22 +10145,118 @@ var SerializerState = class {
10040
10145
  this.indentSize = this.options.indentSize;
10041
10146
  this.hasReferenceDefinitions = this.options.hasReferenceDefinitions;
10042
10147
  }
10148
+ /** The serialized output */
10149
+ get out() {
10150
+ var _a;
10151
+ if (this.chunks.length > 1) {
10152
+ const joined = this.chunks.join("");
10153
+ this.chunks = [joined];
10154
+ this.chunkStarts = [0];
10155
+ }
10156
+ return (_a = this.chunks[0]) !== null && _a !== void 0 ? _a : "";
10157
+ }
10158
+ set out(value) {
10159
+ this.chunks = [];
10160
+ this.chunkStarts = [];
10161
+ this.outLength = 0;
10162
+ this.tail = "";
10163
+ this.trailingSpaces = 0;
10164
+ this.append(value);
10165
+ }
10166
+ get length() {
10167
+ return this.outLength;
10168
+ }
10169
+ get trailingSpaceCount() {
10170
+ return this.trailingSpaces;
10171
+ }
10172
+ /** Output written at or after `offset`. */
10173
+ sliceFrom(offset) {
10174
+ var _a, _b;
10175
+ let lo = 0;
10176
+ let hi = this.chunkStarts.length - 1;
10177
+ while (lo < hi) {
10178
+ const mid = lo + hi + 1 >> 1;
10179
+ if (((_a = this.chunkStarts[mid]) !== null && _a !== void 0 ? _a : 0) <= offset)
10180
+ lo = mid;
10181
+ else
10182
+ hi = mid - 1;
10183
+ }
10184
+ const first = this.chunks[lo];
10185
+ if (first === void 0)
10186
+ return "";
10187
+ return first.slice(offset - ((_b = this.chunkStarts[lo]) !== null && _b !== void 0 ? _b : 0)) + this.chunks.slice(lo + 1).join("");
10188
+ }
10189
+ /** Drop the last `count` characters of the output. */
10190
+ truncate(count) {
10191
+ var _a, _b, _c;
10192
+ let remaining = count;
10193
+ while (remaining > 0 && this.chunks.length > 0) {
10194
+ const last = (_a = this.chunks[this.chunks.length - 1]) !== null && _a !== void 0 ? _a : "";
10195
+ if (last.length <= remaining) {
10196
+ remaining -= last.length;
10197
+ this.chunks.pop();
10198
+ this.chunkStarts.pop();
10199
+ } else {
10200
+ this.chunks[this.chunks.length - 1] = last.slice(0, last.length - remaining);
10201
+ remaining = 0;
10202
+ }
10203
+ }
10204
+ this.outLength -= count - remaining;
10205
+ this.tail = "";
10206
+ this.trailingSpaces = 0;
10207
+ for (let i = this.chunks.length - 1; i >= 0 && this.tail.length < 2; i--) {
10208
+ this.tail = (((_b = this.chunks[i]) !== null && _b !== void 0 ? _b : "") + this.tail).slice(-2);
10209
+ }
10210
+ for (let i = this.chunks.length - 1; i >= 0; i--) {
10211
+ const chunk = (_c = this.chunks[i]) !== null && _c !== void 0 ? _c : "";
10212
+ let j = chunk.length;
10213
+ while (j > 0 && chunk.charCodeAt(j - 1) === 32)
10214
+ j--;
10215
+ this.trailingSpaces += chunk.length - j;
10216
+ if (j > 0)
10217
+ break;
10218
+ }
10219
+ }
10220
+ append(content) {
10221
+ if (content.length === 0)
10222
+ return;
10223
+ this.chunkStarts.push(this.outLength);
10224
+ this.chunks.push(content);
10225
+ this.outLength += content.length;
10226
+ this.tail = (this.tail + content).slice(-2);
10227
+ let i = content.length;
10228
+ while (i > 0 && content.charCodeAt(i - 1) === 32)
10229
+ i--;
10230
+ this.trailingSpaces = i === 0 ? this.trailingSpaces + content.length : content.length - i;
10231
+ const lead = this.topLevelLead;
10232
+ if (lead && !lead.content) {
10233
+ let j = 0;
10234
+ while (j < content.length && content.charCodeAt(j) === 10)
10235
+ j++;
10236
+ lead.lead += j;
10237
+ if (j < content.length)
10238
+ lead.content = true;
10239
+ }
10240
+ }
10043
10241
  beginBlock(index) {
10044
10242
  if (!this.sourceMap)
10045
10243
  return 0;
10046
10244
  this.nodePath.push(index);
10047
- return this.out.length;
10245
+ if (this.nodePath.length === 1)
10246
+ this.topLevelLead = { lead: 0, content: false };
10247
+ return this.outLength;
10048
10248
  }
10049
10249
  endBlock(start) {
10050
10250
  var _a, _b;
10051
10251
  if (!this.sourceMap)
10052
10252
  return;
10053
10253
  if (this.nodePath.length === 1) {
10054
- const lead = (_b = (_a = /^\n+/.exec(this.out.slice(start))) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
10254
+ const lead = (_b = (_a = this.topLevelLead) === null || _a === void 0 ? void 0 : _a.lead) !== null && _b !== void 0 ? _b : 0;
10255
+ this.topLevelLead = null;
10055
10256
  this.sourceMap.push({
10056
10257
  path: [...this.nodePath],
10057
10258
  start: start + lead,
10058
- end: this.out.length,
10259
+ end: this.outLength,
10059
10260
  kind: "block"
10060
10261
  });
10061
10262
  }
@@ -10066,8 +10267,8 @@ var SerializerState = class {
10066
10267
  return;
10067
10268
  this.sourceMap.push({
10068
10269
  path: [...this.nodePath, index],
10069
- start: this.out.length - length,
10070
- end: this.out.length,
10270
+ start: this.outLength - length,
10271
+ end: this.outLength,
10071
10272
  kind: "text",
10072
10273
  pmStart,
10073
10274
  pmEnd
@@ -10077,7 +10278,7 @@ var SerializerState = class {
10077
10278
  if (!this.sourceMap || length === 0)
10078
10279
  return null;
10079
10280
  const entry = this.sourceMap.at(-1);
10080
- if ((entry === null || entry === void 0 ? void 0 : entry.kind) !== "text" || entry.end !== this.out.length || entry.end - entry.start < length || entry.pmEnd - entry.pmStart < length) {
10281
+ if ((entry === null || entry === void 0 ? void 0 : entry.kind) !== "text" || entry.end !== this.outLength || entry.end - entry.start < length || entry.pmEnd - entry.pmStart < length) {
10081
10282
  return null;
10082
10283
  }
10083
10284
  const mapping = Object.assign({ path: [...entry.path], kind: "text", pmStart: entry.pmEnd - length, pmEnd: entry.pmEnd }, entry.offsetEncoding && { offsetEncoding: entry.offsetEncoding });
@@ -10129,24 +10330,24 @@ var SerializerState = class {
10129
10330
  */
10130
10331
  write(content) {
10131
10332
  if (this.closed) {
10132
- this.out += "\n";
10333
+ this.append("\n");
10133
10334
  this.closed = false;
10134
10335
  }
10135
- if (this.delim && this.out.endsWith("\n") && content.length > 0 && content[0] !== "\n") {
10136
- this.out += this.delim;
10336
+ if (this.delim && this.tail.endsWith("\n") && content.length > 0 && content[0] !== "\n") {
10337
+ this.append(this.delim);
10137
10338
  }
10138
- this.out += content;
10339
+ this.append(content);
10139
10340
  }
10140
10341
  ensureNewLine() {
10141
- if (!this.out.endsWith("\n")) {
10142
- this.out += "\n";
10342
+ if (!this.tail.endsWith("\n")) {
10343
+ this.append("\n");
10143
10344
  }
10144
10345
  }
10145
10346
  ensureBlankLine() {
10146
- if (this.out.endsWith("\n\n")) {
10347
+ if (this.tail.endsWith("\n\n")) {
10147
10348
  return;
10148
10349
  }
10149
- this.out += this.out.endsWith("\n") ? "\n" : "\n\n";
10350
+ this.append(this.tail.endsWith("\n") ? "\n" : "\n\n");
10150
10351
  }
10151
10352
  /**
10152
10353
  * Marks the current block as closed. Appropriate spacing will be added on the next write().
@@ -10391,7 +10592,7 @@ function renderBlockquote(state, node, renderNode2) {
10391
10592
  for (let j = 0; j < lines.length; j++) {
10392
10593
  const line = (_a = lines[j]) !== null && _a !== void 0 ? _a : "";
10393
10594
  state.write(line.length > 0 ? "> " : ">");
10394
- parentContentStarts.push(state.out.length);
10595
+ parentContentStarts.push(state.length);
10395
10596
  state.write(line);
10396
10597
  state.ensureNewLine();
10397
10598
  }
@@ -10423,18 +10624,18 @@ function renderList(state, node, ordered, renderContent2) {
10423
10624
  const line = (_a = lines[j]) !== null && _a !== void 0 ? _a : "";
10424
10625
  if (j === 0) {
10425
10626
  state.write(prefix);
10426
- parentContentStarts.push(state.out.length);
10627
+ parentContentStarts.push(state.length);
10427
10628
  state.write(line);
10428
10629
  } else if (line.length > 0) {
10429
10630
  state.ensureNewLine();
10430
10631
  state.write(indent);
10431
- parentContentStarts.push(state.out.length);
10632
+ parentContentStarts.push(state.length);
10432
10633
  state.write(line);
10433
10634
  } else if (!isTight && j < lines.length - 1) {
10434
10635
  state.ensureBlankLine();
10435
- parentContentStarts.push(state.out.length);
10636
+ parentContentStarts.push(state.length);
10436
10637
  } else {
10437
- parentContentStarts.push(state.out.length);
10638
+ parentContentStarts.push(state.length);
10438
10639
  }
10439
10640
  }
10440
10641
  state.importTextEntries((_b = itemState.sourceMap) !== null && _b !== void 0 ? _b : [], [i], offsetMapperForLines(itemOutput, parentContentStarts));
@@ -10696,20 +10897,21 @@ function renderTitledComponent(state, node, name, renderContent2, renderInline2,
10696
10897
  }
10697
10898
  const titleAttribute = isJSXContent(title) ? title.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;") : title;
10698
10899
  const extractedAttrs = titleAttribute ? Object.assign({ title: titleAttribute }, node.attrs) : Object.assign({}, node.attrs);
10699
- const outputStart = state.out.length;
10900
+ const outputStart = state.length;
10700
10901
  renderComponentWithAttrs(state, node, name, extractedAttrs, renderContent2, excludeAttrs);
10701
10902
  const titleText = titleChild === null || titleChild === void 0 ? void 0 : titleChild.firstChild;
10702
10903
  if (!(titleText === null || titleText === void 0 ? void 0 : titleText.isText) || titleText.text !== title)
10703
10904
  return;
10704
- const openingStart = state.out.indexOf(`<${name}`, outputStart);
10705
- const openingEnd = state.out.indexOf("\n", openingStart);
10706
- const attributeStart = state.out.indexOf("title=", openingStart);
10707
- const valueStart = state.out.indexOf(title, attributeStart + "title=".length);
10905
+ const rendered = state.sliceFrom(outputStart);
10906
+ const openingStart = rendered.indexOf(`<${name}`);
10907
+ const openingEnd = rendered.indexOf("\n", openingStart);
10908
+ const attributeStart = rendered.indexOf("title=", openingStart);
10909
+ const valueStart = rendered.indexOf(title, attributeStart + "title=".length);
10708
10910
  if (openingStart < 0 || openingEnd < 0 || attributeStart < 0 || valueStart < 0)
10709
10911
  return;
10710
10912
  if (attributeStart >= openingEnd || valueStart + title.length > openingEnd)
10711
10913
  return;
10712
- state.recordLiteralTextRange([0, 0], valueStart, valueStart + title.length);
10914
+ state.recordLiteralTextRange([0, 0], outputStart + valueStart, outputStart + valueStart + title.length);
10713
10915
  }
10714
10916
  function renderGenericComponent(state, node, name, renderContent2, excludeAttrs = []) {
10715
10917
  renderComponentWithAttrs(state, node, name, node.attrs, renderContent2, excludeAttrs);
@@ -11167,11 +11369,11 @@ function renderInline(state, node, renderNode2, inlineRenderers2) {
11167
11369
  return m !== void 0 && usesFlanking(m);
11168
11370
  });
11169
11371
  if (closingFlanking) {
11170
- const match = state.out.match(/ +$/);
11171
- if (match) {
11172
- trailingSpace = match[0];
11173
- trailingTextMapping = state.takeTextSuffix(trailingSpace.length);
11174
- state.out = state.out.slice(0, -trailingSpace.length);
11372
+ const spaces = state.trailingSpaceCount;
11373
+ if (spaces > 0) {
11374
+ trailingSpace = " ".repeat(spaces);
11375
+ trailingTextMapping = state.takeTextSuffix(spaces);
11376
+ state.truncate(spaces);
11175
11377
  }
11176
11378
  }
11177
11379
  for (let i = active.length - 1; i >= earliestClose; i--) {
@@ -11190,10 +11392,10 @@ function renderInline(state, node, renderNode2, inlineRenderers2) {
11190
11392
  }
11191
11393
  active = active.slice(0, earliestClose);
11192
11394
  if (trailingSpace) {
11193
- const trailingStart = state.out.length;
11395
+ const trailingStart = state.length;
11194
11396
  state.write(trailingSpace);
11195
11397
  if (trailingTextMapping) {
11196
- state.recordTextRange(trailingTextMapping, trailingStart, state.out.length);
11398
+ state.recordTextRange(trailingTextMapping, trailingStart, state.length);
11197
11399
  }
11198
11400
  }
11199
11401
  for (const mark of continuing) {
@@ -11319,6 +11521,9 @@ function renderTextNode(state, node) {
11319
11521
  state.text(text);
11320
11522
  }
11321
11523
  }
11524
+ function escapeReferenceLabel(label) {
11525
+ return label.replace(/\\(?=[\u0021-\u002F\u003A-\u0040\u005B-\u0060\u007B-\u007E]|$)/g, "\\\\").replace(/[\[\]]/g, "\\$&");
11526
+ }
11322
11527
  function getMarkStrings(mark) {
11323
11528
  switch (mark.type.name) {
11324
11529
  case "bold":
@@ -11330,6 +11535,13 @@ function getMarkStrings(mark) {
11330
11535
  case "code":
11331
11536
  return { open: "`", close: "`" };
11332
11537
  case "link": {
11538
+ const componentLink = getLinkComponentMarkStrings(mark);
11539
+ if (componentLink)
11540
+ return componentLink;
11541
+ const referenceLabel = mark.attrs.referenceLabel;
11542
+ if (typeof referenceLabel === "string" && referenceLabel) {
11543
+ return { open: "[", close: `][${escapeReferenceLabel(referenceLabel)}]` };
11544
+ }
11333
11545
  const href = mark.attrs.href || "";
11334
11546
  const title = mark.attrs.title;
11335
11547
  const titleStr = title ? ` "${title}"` : "";
@@ -11350,6 +11562,27 @@ function getMarkStrings(mark) {
11350
11562
  return { open: "", close: "" };
11351
11563
  }
11352
11564
  }
11565
+ function getLinkComponentMarkStrings(mark) {
11566
+ const storedAttributes = mark.attrs.mdxLinkAttributes;
11567
+ const href = mark.attrs.href;
11568
+ if (!isAttributeRecord3(storedAttributes) || typeof href !== "string")
11569
+ return void 0;
11570
+ const attributes = Object.assign(Object.assign({}, storedAttributes), { href });
11571
+ if (mark.attrs.title === null || mark.attrs.title === void 0) {
11572
+ delete attributes.title;
11573
+ } else {
11574
+ attributes.title = mark.attrs.title;
11575
+ }
11576
+ const namedAttributes = Object.entries(attributes).filter(([key]) => key !== NAMED_EXPRESSION_ATTRS_KEY).map(([key, value]) => serializeJsxAttribute(attributes, key, value)).filter((attribute) => attribute !== null);
11577
+ const serializedAttributes = namedAttributes.join(" ");
11578
+ return {
11579
+ open: `<Link${serializedAttributes ? ` ${serializedAttributes}` : ""}>`,
11580
+ close: "</Link>"
11581
+ };
11582
+ }
11583
+ function isAttributeRecord3(value) {
11584
+ return typeof value === "object" && value !== null && !Array.isArray(value);
11585
+ }
11353
11586
 
11354
11587
  // ../editor/dist/converter/serialize/pm-to-mdx.js
11355
11588
  var __rest2 = function(s, e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/cli",
3
- "version": "4.0.1463",
3
+ "version": "4.0.1465",
4
4
  "description": "The Mintlify CLI",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -86,7 +86,7 @@
86
86
  "keytar": "7.9.0"
87
87
  },
88
88
  "devDependencies": {
89
- "@mintlify/editor": "0.0.351",
89
+ "@mintlify/editor": "0.0.353",
90
90
  "@mintlify/ts-config": "2.0.2",
91
91
  "@tsconfig/recommended": "1.0.2",
92
92
  "@types/detect-port": "1.3.2",
@@ -105,5 +105,5 @@
105
105
  "vitest": "2.1.9",
106
106
  "vitest-mock-process": "1.0.4"
107
107
  },
108
- "gitHead": "f828b446b1bcec7e17b0b2b4b8a76cbf9f8d9eef"
108
+ "gitHead": "bb95119b1199b11ce94c9acec5108238b8eea1a9"
109
109
  }