@mintlify/cli 4.0.1462 → 4.0.1463
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/bin/vendor/converter.js +265 -84
- package/package.json +3 -3
package/bin/vendor/converter.js
CHANGED
|
@@ -1520,6 +1520,33 @@ function partitionForBlockType(parsed, blockType) {
|
|
|
1520
1520
|
var _a;
|
|
1521
1521
|
return partitionAttrs(parsed, (_a = BLOCK_TYPE_KNOWN_ATTRS[blockType]) !== null && _a !== void 0 ? _a : []);
|
|
1522
1522
|
}
|
|
1523
|
+
var STRUCTURED_FLOW_COMPONENTS = /* @__PURE__ */ new Map([
|
|
1524
|
+
[BLOCK_TYPES.callout, true],
|
|
1525
|
+
[BLOCK_TYPES.column, true],
|
|
1526
|
+
[BLOCK_TYPES.expandable, true],
|
|
1527
|
+
[BLOCK_TYPES.frame, true],
|
|
1528
|
+
[BLOCK_TYPES.paramField, true],
|
|
1529
|
+
["Prompt", false],
|
|
1530
|
+
[BLOCK_TYPES.responseField, true],
|
|
1531
|
+
[BLOCK_TYPES.tab, true],
|
|
1532
|
+
[BLOCK_TYPES.update, true],
|
|
1533
|
+
[BLOCK_TYPES.visibility, false],
|
|
1534
|
+
[BLOCK_TYPES.accordion, false],
|
|
1535
|
+
[BLOCK_TYPES.accordionGroup, false],
|
|
1536
|
+
[BLOCK_TYPES.card, false],
|
|
1537
|
+
[BLOCK_TYPES.codeGroup, false],
|
|
1538
|
+
[BLOCK_TYPES.columns, false],
|
|
1539
|
+
[BLOCK_TYPES.requestExample, false],
|
|
1540
|
+
[BLOCK_TYPES.responseExample, false],
|
|
1541
|
+
[BLOCK_TYPES.steps, false],
|
|
1542
|
+
[BLOCK_TYPES.tabs, false]
|
|
1543
|
+
]);
|
|
1544
|
+
function isContainerOnlyComponent(name, schema2) {
|
|
1545
|
+
var _a;
|
|
1546
|
+
const type2 = schema2.nodes[name];
|
|
1547
|
+
return !!type2 && !type2.isInline && !((_a = type2.spec.group) !== null && _a !== void 0 ? _a : "").split(" ").includes("block");
|
|
1548
|
+
}
|
|
1549
|
+
var withRequiredContent = (nodeType, content) => STRUCTURED_FLOW_COMPONENTS.get(nodeType) && content.length === 0 ? [{ type: "paragraph" }] : content;
|
|
1523
1550
|
function handleFlowJsx(node, ctx, transformNode2, mapJsxChildren2) {
|
|
1524
1551
|
if (!node.name)
|
|
1525
1552
|
return [];
|
|
@@ -1530,7 +1557,7 @@ function handleFlowJsx(node, ctx, transformNode2, mapJsxChildren2) {
|
|
|
1530
1557
|
}
|
|
1531
1558
|
}
|
|
1532
1559
|
function handleFlowJsxInner(node, ctx, transformNode2, mapJsxChildren2) {
|
|
1533
|
-
var _a;
|
|
1560
|
+
var _a, _b;
|
|
1534
1561
|
if (!node.name)
|
|
1535
1562
|
return [];
|
|
1536
1563
|
if (/^h[1-6]$/.test(node.name)) {
|
|
@@ -1558,7 +1585,7 @@ function handleFlowJsxInner(node, ctx, transformNode2, mapJsxChildren2) {
|
|
|
1558
1585
|
return {
|
|
1559
1586
|
type: BLOCK_TYPES.frame,
|
|
1560
1587
|
attrs: partitionAttrs(frameAttrs, FRAME_ATTRS),
|
|
1561
|
-
content: mapJsxChildren2(node, ctx)
|
|
1588
|
+
content: withRequiredContent(BLOCK_TYPES.frame, mapJsxChildren2(node, ctx))
|
|
1562
1589
|
};
|
|
1563
1590
|
}
|
|
1564
1591
|
const isCallout = CALLOUT_TYPES.includes(node.name);
|
|
@@ -1596,13 +1623,13 @@ function handleFlowJsxInner(node, ctx, transformNode2, mapJsxChildren2) {
|
|
|
1596
1623
|
if (node.name === BLOCK_TYPES.tree) {
|
|
1597
1624
|
return handleTree(node);
|
|
1598
1625
|
}
|
|
1599
|
-
|
|
1600
|
-
|
|
1626
|
+
const targetType = isCallout ? BLOCK_TYPES.callout : node.name;
|
|
1627
|
+
if ((isCallout || node.name !== BLOCK_TYPES.step && Object.values(BLOCK_TYPES).includes(node.name)) && (ctx.hasGroupParent || !isContainerOnlyComponent(targetType, (_b = ctx.schema) !== null && _b !== void 0 ? _b : mintlifySchema))) {
|
|
1601
1628
|
const parsedAttrs = parseMdxAttributes(node.attributes);
|
|
1602
1629
|
return {
|
|
1603
1630
|
type: targetType,
|
|
1604
1631
|
attrs: Object.assign(Object.assign({}, isCallout ? parseCalloutAttrs(node.name, parsedAttrs) : partitionForBlockType(parsedAttrs, targetType)), ctx.hasGroupParent && { __hasGroupParent: true }),
|
|
1605
|
-
content: mapJsxChildren2(node, ctx)
|
|
1632
|
+
content: withRequiredContent(targetType, mapJsxChildren2(node, ctx))
|
|
1606
1633
|
};
|
|
1607
1634
|
}
|
|
1608
1635
|
if (node.name === "table" && !hasSpannedCell(node) && !hasTableClass(node)) {
|
|
@@ -1659,28 +1686,42 @@ function createTitleNode(type2, title, ctx, transformNode2) {
|
|
|
1659
1686
|
return Object.assign({ type: type2 }, content.length > 0 ? { content } : {});
|
|
1660
1687
|
}
|
|
1661
1688
|
function handleSteps(node, ctx, transformNode2, mapJsxChildren2) {
|
|
1662
|
-
const
|
|
1663
|
-
const
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
};
|
|
1677
|
-
});
|
|
1689
|
+
const children = flattenJsxParagraphs(node).children;
|
|
1690
|
+
const stepChildren = [];
|
|
1691
|
+
for (const child of children) {
|
|
1692
|
+
if (child.type === "text" && child.value.trim() === "")
|
|
1693
|
+
continue;
|
|
1694
|
+
if (child.type !== "mdxJsxFlowElement" || child.name !== BLOCK_TYPES.step) {
|
|
1695
|
+
return { type: BLOCK_TYPES.unknownTag, attrs: { mdxJsxNode: node } };
|
|
1696
|
+
}
|
|
1697
|
+
stepChildren.push(child);
|
|
1698
|
+
}
|
|
1699
|
+
const pmStepChildren = stepChildren.map((stepChild, index) => handleStep(stepChild, ctx, transformNode2, mapJsxChildren2, {
|
|
1700
|
+
index,
|
|
1701
|
+
isLast: index === stepChildren.length - 1
|
|
1702
|
+
}));
|
|
1678
1703
|
return {
|
|
1679
1704
|
type: BLOCK_TYPES.steps,
|
|
1680
1705
|
attrs: Object.assign(Object.assign({}, partitionAttrs(parseMdxAttributes(node.attributes), [])), ctx.hasGroupParent && { __hasGroupParent: true }),
|
|
1681
1706
|
content: pmStepChildren
|
|
1682
1707
|
};
|
|
1683
1708
|
}
|
|
1709
|
+
function handleStep(node, ctx, transformNode2, mapJsxChildren2, groupPosition) {
|
|
1710
|
+
const stepAttrs = parseMdxAttributes(node.attributes);
|
|
1711
|
+
const titleText = stepAttrs.title;
|
|
1712
|
+
const bodyContent = mapJsxChildren2(node, ctx);
|
|
1713
|
+
return {
|
|
1714
|
+
type: BLOCK_TYPES.step,
|
|
1715
|
+
attrs: Object.assign(Object.assign(Object.assign({}, partitionAttrs(stepAttrs, STEP_ATTRS, ["title"])), ctx.hasGroupParent && { __hasGroupParent: true }), { __childIndex: groupPosition.index, __isLastInGroup: groupPosition.isLast }),
|
|
1716
|
+
content: [
|
|
1717
|
+
createTitleNode(BLOCK_TYPES.stepTitle, titleText, ctx, transformNode2),
|
|
1718
|
+
{
|
|
1719
|
+
type: BLOCK_TYPES.stepBody,
|
|
1720
|
+
content: bodyContent.length > 0 ? bodyContent : [{ type: "paragraph" }]
|
|
1721
|
+
}
|
|
1722
|
+
]
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1684
1725
|
function handleAccordion(node, ctx, transformNode2, mapJsxChildren2) {
|
|
1685
1726
|
const attrs2 = parseMdxAttributes(node.attributes);
|
|
1686
1727
|
const titleText = attrs2.title;
|
|
@@ -1740,7 +1781,7 @@ function handleToggleContent(node, ctx, transformNode2, mapJsxChildren2) {
|
|
|
1740
1781
|
type: childType,
|
|
1741
1782
|
attrs: Object.assign(Object.assign({}, partitionChild(parseMdxAttributes(child.attributes))), { __isHidden: index !== 0, __hasGroupParent: true }),
|
|
1742
1783
|
// We should only set isHidden to false for <Tab />, not the children inside the tab
|
|
1743
|
-
content: mapJsxChildren2(child, Object.assign(Object.assign({}, ctx), { hasGroupParent: node.name !== BLOCK_TYPES.tabs, isHidden: node.name === BLOCK_TYPES.tabs ? false : index !== 0 }))
|
|
1784
|
+
content: withRequiredContent(childType, mapJsxChildren2(child, Object.assign(Object.assign({}, ctx), { hasGroupParent: node.name !== BLOCK_TYPES.tabs, isHidden: node.name === BLOCK_TYPES.tabs ? false : index !== 0 })))
|
|
1744
1785
|
}));
|
|
1745
1786
|
return {
|
|
1746
1787
|
type: (_d = node.name) !== null && _d !== void 0 ? _d : BLOCK_TYPES.tabs,
|
|
@@ -1748,6 +1789,12 @@ function handleToggleContent(node, ctx, transformNode2, mapJsxChildren2) {
|
|
|
1748
1789
|
content: pmChildren
|
|
1749
1790
|
};
|
|
1750
1791
|
}
|
|
1792
|
+
if (mapJsxChildren2(node, ctx).length > 0) {
|
|
1793
|
+
return {
|
|
1794
|
+
type: BLOCK_TYPES.unknownTag,
|
|
1795
|
+
attrs: { mdxJsxNode: node }
|
|
1796
|
+
};
|
|
1797
|
+
}
|
|
1751
1798
|
return {
|
|
1752
1799
|
type: (_e = node.name) !== null && _e !== void 0 ? _e : BLOCK_TYPES.tabs,
|
|
1753
1800
|
attrs: partitionWrapper(parseMdxAttributes(node.attributes)),
|
|
@@ -1756,25 +1803,14 @@ function handleToggleContent(node, ctx, transformNode2, mapJsxChildren2) {
|
|
|
1756
1803
|
}
|
|
1757
1804
|
function handleColumns(node, ctx, mapJsxChildren2) {
|
|
1758
1805
|
const attrs2 = partitionAttrs(parseMdxAttributes(node.attributes), COLUMNS_ATTRS);
|
|
1759
|
-
const
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
return {
|
|
1764
|
-
type: BLOCK_TYPES.column,
|
|
1765
|
-
content: content.length > 0 ? content : [{ type: "paragraph" }]
|
|
1766
|
-
};
|
|
1767
|
-
});
|
|
1768
|
-
return {
|
|
1769
|
-
type: BLOCK_TYPES.columns,
|
|
1770
|
-
attrs: Object.assign(Object.assign({}, attrs2), ctx.hasGroupParent && { __hasGroupParent: true }),
|
|
1771
|
-
content: pmChildren
|
|
1772
|
-
};
|
|
1773
|
-
}
|
|
1806
|
+
const content = mapJsxChildren2(node, Object.assign(Object.assign({}, ctx), { hasGroupParent: true })).map((child) => {
|
|
1807
|
+
var _a;
|
|
1808
|
+
return child.type === BLOCK_TYPES.column ? Object.assign(Object.assign({}, child), { content: withRequiredContent(BLOCK_TYPES.column, (_a = child.content) !== null && _a !== void 0 ? _a : []) }) : child;
|
|
1809
|
+
});
|
|
1774
1810
|
return {
|
|
1775
1811
|
type: BLOCK_TYPES.columns,
|
|
1776
|
-
attrs: attrs2,
|
|
1777
|
-
content
|
|
1812
|
+
attrs: Object.assign(Object.assign({}, attrs2), ctx.hasGroupParent && { __hasGroupParent: true }),
|
|
1813
|
+
content
|
|
1778
1814
|
};
|
|
1779
1815
|
}
|
|
1780
1816
|
function parseColorItemNode(node) {
|
|
@@ -2382,20 +2418,8 @@ function buildMarkdownTableCellContent(children, ctx, transformNode2) {
|
|
|
2382
2418
|
return children.flatMap((child) => flattenNodeContent(transformNode2(child, ctx)));
|
|
2383
2419
|
}
|
|
2384
2420
|
function handleParagraph(node, ctx, transformNode2, mapChildren2) {
|
|
2385
|
-
var _a
|
|
2386
|
-
|
|
2387
|
-
const result = transformNode2(node.children[0], ctx);
|
|
2388
|
-
const nodes2 = flattenNodeContent(result);
|
|
2389
|
-
const schema3 = (_c = ctx.schema) !== null && _c !== void 0 ? _c : mintlifySchema;
|
|
2390
|
-
const allInline = nodes2.length > 0 && nodes2.every((child) => {
|
|
2391
|
-
var _a2;
|
|
2392
|
-
return ((_a2 = schema3.nodes[child.type]) === null || _a2 === void 0 ? void 0 : _a2.isInline) === true;
|
|
2393
|
-
});
|
|
2394
|
-
if (allInline) {
|
|
2395
|
-
return { type: "paragraph", content: nodes2 };
|
|
2396
|
-
}
|
|
2397
|
-
return result;
|
|
2398
|
-
}
|
|
2421
|
+
var _a;
|
|
2422
|
+
const schema2 = (_a = ctx.schema) !== null && _a !== void 0 ? _a : mintlifySchema;
|
|
2399
2423
|
const hasImages = node.children.some((child) => child.type === "image" || child.type === "mdxJsxTextElement" && child.name === "img");
|
|
2400
2424
|
if (hasImages) {
|
|
2401
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");
|
|
@@ -2415,7 +2439,7 @@ function handleParagraph(node, ctx, transformNode2, mapChildren2) {
|
|
|
2415
2439
|
}
|
|
2416
2440
|
}
|
|
2417
2441
|
}
|
|
2418
|
-
return
|
|
2442
|
+
return splitParagraphAroundBlocks(content2, schema2);
|
|
2419
2443
|
}
|
|
2420
2444
|
const blocks = [];
|
|
2421
2445
|
for (const child of node.children) {
|
|
@@ -2430,7 +2454,6 @@ function handleParagraph(node, ctx, transformNode2, mapChildren2) {
|
|
|
2430
2454
|
return blocks.length > 0 ? blocks : [];
|
|
2431
2455
|
}
|
|
2432
2456
|
const content = mapChildren2(node, ctx);
|
|
2433
|
-
const schema2 = (_d = ctx.schema) !== null && _d !== void 0 ? _d : mintlifySchema;
|
|
2434
2457
|
if (content.every((child) => isInlineNode(child, schema2))) {
|
|
2435
2458
|
return { type: "paragraph", content };
|
|
2436
2459
|
}
|
|
@@ -2443,15 +2466,15 @@ function splitParagraphAroundBlocks(content, schema2) {
|
|
|
2443
2466
|
});
|
|
2444
2467
|
}
|
|
2445
2468
|
function trimParagraph(paragraph) {
|
|
2446
|
-
var _a;
|
|
2469
|
+
var _a, _b, _c;
|
|
2447
2470
|
const content = [...(_a = paragraph.content) !== null && _a !== void 0 ? _a : []];
|
|
2448
2471
|
const first = content[0];
|
|
2449
|
-
if ((first === null || first === void 0 ? void 0 : first.type) === "text" && first.text) {
|
|
2472
|
+
if ((first === null || first === void 0 ? void 0 : first.type) === "text" && first.text && !((_b = first.marks) === null || _b === void 0 ? void 0 : _b.some((mark) => mark.type === "code"))) {
|
|
2450
2473
|
content[0] = Object.assign(Object.assign({}, first), { text: first.text.replace(/^\s+/, "") });
|
|
2451
2474
|
}
|
|
2452
2475
|
const lastIndex = content.length - 1;
|
|
2453
2476
|
const last = content[lastIndex];
|
|
2454
|
-
if ((last === null || last === void 0 ? void 0 : last.type) === "text" && last.text) {
|
|
2477
|
+
if ((last === null || last === void 0 ? void 0 : last.type) === "text" && last.text && !((_c = last.marks) === null || _c === void 0 ? void 0 : _c.some((mark) => mark.type === "code"))) {
|
|
2455
2478
|
content[lastIndex] = Object.assign(Object.assign({}, last), { text: last.text.replace(/\s+$/, "") });
|
|
2456
2479
|
}
|
|
2457
2480
|
return Object.assign(Object.assign({}, paragraph), { content: content.filter((n) => n.type !== "text" || n.text !== "") });
|
|
@@ -2520,7 +2543,8 @@ function mdastToPm(mdast, source = "", options) {
|
|
|
2520
2543
|
const frontmatter = extractFrontmatter(mdast);
|
|
2521
2544
|
const context = { source, frontmatter, schema: schema2 };
|
|
2522
2545
|
visit2(mdast, (node) => {
|
|
2523
|
-
|
|
2546
|
+
const promptNeedsSourcePosition = node.type === "mdxJsxTextElement" && node.name === "Prompt";
|
|
2547
|
+
if (node.type !== "list" && node.type !== "mdxJsxFlowElement" && !promptNeedsSourcePosition) {
|
|
2524
2548
|
delete node.position;
|
|
2525
2549
|
}
|
|
2526
2550
|
});
|
|
@@ -2535,7 +2559,7 @@ function mdastToPm(mdast, source = "", options) {
|
|
|
2535
2559
|
return { doc, frontmatter };
|
|
2536
2560
|
}
|
|
2537
2561
|
function transformNode(node, ctx) {
|
|
2538
|
-
var _a, _b, _c;
|
|
2562
|
+
var _a, _b, _c, _d;
|
|
2539
2563
|
if (!node)
|
|
2540
2564
|
return [];
|
|
2541
2565
|
switch (node.type) {
|
|
@@ -2632,8 +2656,14 @@ function transformNode(node, ctx) {
|
|
|
2632
2656
|
};
|
|
2633
2657
|
case "yaml":
|
|
2634
2658
|
return [];
|
|
2635
|
-
case "mdxJsxTextElement":
|
|
2636
|
-
|
|
2659
|
+
case "mdxJsxTextElement": {
|
|
2660
|
+
if (!node.name || !STRUCTURED_FLOW_COMPONENTS.has(node.name) || isContainerOnlyComponent(node.name, (_d = ctx.schema) !== null && _d !== void 0 ? _d : mintlifySchema)) {
|
|
2661
|
+
return handleInlineJsx(node, ctx, mapChildren);
|
|
2662
|
+
}
|
|
2663
|
+
const flowResult = handleFlowJsx(Object.assign(Object.assign({}, node), { type: "mdxJsxFlowElement", children: node.children.length > 0 ? [{ type: "paragraph", children: node.children }] : [] }), ctx, transformNode, mapJsxChildren);
|
|
2664
|
+
const flowNodes = Array.isArray(flowResult) ? flowResult : [flowResult];
|
|
2665
|
+
return flowNodes.length > 0 ? flowResult : handleInlineJsx(node, ctx, mapChildren);
|
|
2666
|
+
}
|
|
2637
2667
|
case "mdxJsxFlowElement":
|
|
2638
2668
|
return handleFlowJsx(node, ctx, transformNode, mapJsxChildren);
|
|
2639
2669
|
case "mdxjsEsm":
|
|
@@ -9999,6 +10029,8 @@ var SerializerState = class {
|
|
|
9999
10029
|
this.inCodeSection = false;
|
|
10000
10030
|
this.hasReferenceDefinitions = false;
|
|
10001
10031
|
this.indentSize = 2;
|
|
10032
|
+
this.sourceMap = null;
|
|
10033
|
+
this.nodePath = [];
|
|
10002
10034
|
this.options = {
|
|
10003
10035
|
tightLists: (_a = options.tightLists) !== null && _a !== void 0 ? _a : false,
|
|
10004
10036
|
indentSize: (_b = options.indentSize) !== null && _b !== void 0 ? _b : 2,
|
|
@@ -10008,6 +10040,90 @@ var SerializerState = class {
|
|
|
10008
10040
|
this.indentSize = this.options.indentSize;
|
|
10009
10041
|
this.hasReferenceDefinitions = this.options.hasReferenceDefinitions;
|
|
10010
10042
|
}
|
|
10043
|
+
beginBlock(index) {
|
|
10044
|
+
if (!this.sourceMap)
|
|
10045
|
+
return 0;
|
|
10046
|
+
this.nodePath.push(index);
|
|
10047
|
+
return this.out.length;
|
|
10048
|
+
}
|
|
10049
|
+
endBlock(start) {
|
|
10050
|
+
var _a, _b;
|
|
10051
|
+
if (!this.sourceMap)
|
|
10052
|
+
return;
|
|
10053
|
+
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;
|
|
10055
|
+
this.sourceMap.push({
|
|
10056
|
+
path: [...this.nodePath],
|
|
10057
|
+
start: start + lead,
|
|
10058
|
+
end: this.out.length,
|
|
10059
|
+
kind: "block"
|
|
10060
|
+
});
|
|
10061
|
+
}
|
|
10062
|
+
this.nodePath.pop();
|
|
10063
|
+
}
|
|
10064
|
+
recordTextSuffix(index, length, pmStart, pmEnd) {
|
|
10065
|
+
if (!this.sourceMap || this.inTable)
|
|
10066
|
+
return;
|
|
10067
|
+
this.sourceMap.push({
|
|
10068
|
+
path: [...this.nodePath, index],
|
|
10069
|
+
start: this.out.length - length,
|
|
10070
|
+
end: this.out.length,
|
|
10071
|
+
kind: "text",
|
|
10072
|
+
pmStart,
|
|
10073
|
+
pmEnd
|
|
10074
|
+
});
|
|
10075
|
+
}
|
|
10076
|
+
takeTextSuffix(length) {
|
|
10077
|
+
if (!this.sourceMap || length === 0)
|
|
10078
|
+
return null;
|
|
10079
|
+
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) {
|
|
10081
|
+
return null;
|
|
10082
|
+
}
|
|
10083
|
+
const mapping = Object.assign({ path: [...entry.path], kind: "text", pmStart: entry.pmEnd - length, pmEnd: entry.pmEnd }, entry.offsetEncoding && { offsetEncoding: entry.offsetEncoding });
|
|
10084
|
+
entry.end -= length;
|
|
10085
|
+
entry.pmEnd -= length;
|
|
10086
|
+
if (entry.start === entry.end)
|
|
10087
|
+
this.sourceMap.pop();
|
|
10088
|
+
return mapping;
|
|
10089
|
+
}
|
|
10090
|
+
recordTextRange(mapping, start, end) {
|
|
10091
|
+
if (!this.sourceMap || this.inTable)
|
|
10092
|
+
return;
|
|
10093
|
+
this.sourceMap.push(Object.assign(Object.assign({}, mapping), { start, end }));
|
|
10094
|
+
}
|
|
10095
|
+
withNodePath(index, render) {
|
|
10096
|
+
if (!this.sourceMap)
|
|
10097
|
+
return render();
|
|
10098
|
+
this.nodePath.push(index);
|
|
10099
|
+
try {
|
|
10100
|
+
return render();
|
|
10101
|
+
} finally {
|
|
10102
|
+
this.nodePath.pop();
|
|
10103
|
+
}
|
|
10104
|
+
}
|
|
10105
|
+
recordLiteralTextRange(path, start, end) {
|
|
10106
|
+
if (!this.sourceMap || this.inTable)
|
|
10107
|
+
return;
|
|
10108
|
+
this.sourceMap.push({
|
|
10109
|
+
path: [...this.nodePath, ...path],
|
|
10110
|
+
start,
|
|
10111
|
+
end,
|
|
10112
|
+
kind: "text",
|
|
10113
|
+
pmStart: 0,
|
|
10114
|
+
pmEnd: end - start,
|
|
10115
|
+
offsetEncoding: "identity"
|
|
10116
|
+
});
|
|
10117
|
+
}
|
|
10118
|
+
importTextEntries(entries, pathPrefix, mapOffset) {
|
|
10119
|
+
if (!this.sourceMap)
|
|
10120
|
+
return;
|
|
10121
|
+
for (const entry of entries) {
|
|
10122
|
+
if (entry.kind !== "text")
|
|
10123
|
+
continue;
|
|
10124
|
+
this.sourceMap.push(Object.assign({ path: [...this.nodePath, ...pathPrefix, ...entry.path], start: mapOffset(entry.start), end: mapOffset(entry.end), kind: "text", pmStart: entry.pmStart, pmEnd: entry.pmEnd }, entry.offsetEncoding && { offsetEncoding: entry.offsetEncoding }));
|
|
10125
|
+
}
|
|
10126
|
+
}
|
|
10011
10127
|
/**
|
|
10012
10128
|
* Writes content to the output, handling closed blocks and current delimiters.
|
|
10013
10129
|
*/
|
|
@@ -10245,18 +10361,41 @@ function writeJsxAttributesInline(state, attrs2) {
|
|
|
10245
10361
|
}
|
|
10246
10362
|
|
|
10247
10363
|
// ../editor/dist/converter/serialize/handlers/markdown.js
|
|
10364
|
+
var offsetMapperForLines = (source, parentContentStarts) => {
|
|
10365
|
+
const sourceLineStarts = [0];
|
|
10366
|
+
for (let index = 0; index < source.length; index++) {
|
|
10367
|
+
if (source[index] === "\n")
|
|
10368
|
+
sourceLineStarts.push(index + 1);
|
|
10369
|
+
}
|
|
10370
|
+
return (offset) => {
|
|
10371
|
+
var _a, _b, _c, _d;
|
|
10372
|
+
const clamped = Math.min(Math.max(offset, 0), source.length);
|
|
10373
|
+
let lineIndex = sourceLineStarts.length - 1;
|
|
10374
|
+
while (lineIndex > 0 && ((_a = sourceLineStarts[lineIndex]) !== null && _a !== void 0 ? _a : 0) > clamped)
|
|
10375
|
+
lineIndex--;
|
|
10376
|
+
const sourceLineStart = (_b = sourceLineStarts[lineIndex]) !== null && _b !== void 0 ? _b : 0;
|
|
10377
|
+
const parentLineStart = (_d = (_c = parentContentStarts[lineIndex]) !== null && _c !== void 0 ? _c : parentContentStarts.at(-1)) !== null && _d !== void 0 ? _d : 0;
|
|
10378
|
+
return parentLineStart + clamped - sourceLineStart;
|
|
10379
|
+
};
|
|
10380
|
+
};
|
|
10248
10381
|
function renderBlockquote(state, node, renderNode2) {
|
|
10249
|
-
var _a;
|
|
10382
|
+
var _a, _b;
|
|
10250
10383
|
for (let i = 0; i < node.childCount; i++) {
|
|
10251
10384
|
const child = node.child(i);
|
|
10252
10385
|
const childState = new SerializerState(state.options);
|
|
10386
|
+
childState.sourceMap = state.sourceMap ? [] : null;
|
|
10253
10387
|
renderNode2(childState, child, node, i);
|
|
10254
|
-
const
|
|
10388
|
+
const childOutput = childState.out.replace(/\n+$/, "");
|
|
10389
|
+
const lines = childOutput.split("\n");
|
|
10390
|
+
const parentContentStarts = [];
|
|
10255
10391
|
for (let j = 0; j < lines.length; j++) {
|
|
10256
10392
|
const line = (_a = lines[j]) !== null && _a !== void 0 ? _a : "";
|
|
10257
|
-
state.write(line.length > 0 ?
|
|
10393
|
+
state.write(line.length > 0 ? "> " : ">");
|
|
10394
|
+
parentContentStarts.push(state.out.length);
|
|
10395
|
+
state.write(line);
|
|
10258
10396
|
state.ensureNewLine();
|
|
10259
10397
|
}
|
|
10398
|
+
state.importTextEntries((_b = childState.sourceMap) !== null && _b !== void 0 ? _b : [], [i], offsetMapperForLines(childOutput, parentContentStarts));
|
|
10260
10399
|
if (i < node.childCount - 1) {
|
|
10261
10400
|
state.write(">");
|
|
10262
10401
|
state.ensureNewLine();
|
|
@@ -10265,7 +10404,7 @@ function renderBlockquote(state, node, renderNode2) {
|
|
|
10265
10404
|
state.closeBlock();
|
|
10266
10405
|
}
|
|
10267
10406
|
function renderList(state, node, ordered, renderContent2) {
|
|
10268
|
-
var _a;
|
|
10407
|
+
var _a, _b;
|
|
10269
10408
|
const start = node.attrs.start || 1;
|
|
10270
10409
|
const isTight = typeof node.attrs.tight === "boolean" ? node.attrs.tight : state.options.tightLists;
|
|
10271
10410
|
for (let i = 0; i < node.childCount; i++) {
|
|
@@ -10275,19 +10414,30 @@ function renderList(state, node, ordered, renderContent2) {
|
|
|
10275
10414
|
const prefix = (ordered ? `${start + i}. ` : "- ") + taskMarker;
|
|
10276
10415
|
const indent = " ".repeat(prefix.length);
|
|
10277
10416
|
const itemState = new SerializerState(state.options);
|
|
10417
|
+
itemState.sourceMap = state.sourceMap ? [] : null;
|
|
10278
10418
|
renderContent2(itemState, child);
|
|
10279
|
-
const
|
|
10419
|
+
const itemOutput = itemState.out;
|
|
10420
|
+
const lines = itemOutput.split("\n");
|
|
10421
|
+
const parentContentStarts = [];
|
|
10280
10422
|
for (let j = 0; j < lines.length; j++) {
|
|
10281
10423
|
const line = (_a = lines[j]) !== null && _a !== void 0 ? _a : "";
|
|
10282
10424
|
if (j === 0) {
|
|
10283
|
-
state.write(prefix
|
|
10425
|
+
state.write(prefix);
|
|
10426
|
+
parentContentStarts.push(state.out.length);
|
|
10427
|
+
state.write(line);
|
|
10284
10428
|
} else if (line.length > 0) {
|
|
10285
10429
|
state.ensureNewLine();
|
|
10286
|
-
state.write(indent
|
|
10430
|
+
state.write(indent);
|
|
10431
|
+
parentContentStarts.push(state.out.length);
|
|
10432
|
+
state.write(line);
|
|
10287
10433
|
} else if (!isTight && j < lines.length - 1) {
|
|
10288
10434
|
state.ensureBlankLine();
|
|
10435
|
+
parentContentStarts.push(state.out.length);
|
|
10436
|
+
} else {
|
|
10437
|
+
parentContentStarts.push(state.out.length);
|
|
10289
10438
|
}
|
|
10290
10439
|
}
|
|
10440
|
+
state.importTextEntries((_b = itemState.sourceMap) !== null && _b !== void 0 ? _b : [], [i], offsetMapperForLines(itemOutput, parentContentStarts));
|
|
10291
10441
|
state.ensureNewLine();
|
|
10292
10442
|
}
|
|
10293
10443
|
state.closeBlock();
|
|
@@ -10546,7 +10696,20 @@ function renderTitledComponent(state, node, name, renderContent2, renderInline2,
|
|
|
10546
10696
|
}
|
|
10547
10697
|
const titleAttribute = isJSXContent(title) ? title.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">") : title;
|
|
10548
10698
|
const extractedAttrs = titleAttribute ? Object.assign({ title: titleAttribute }, node.attrs) : Object.assign({}, node.attrs);
|
|
10699
|
+
const outputStart = state.out.length;
|
|
10549
10700
|
renderComponentWithAttrs(state, node, name, extractedAttrs, renderContent2, excludeAttrs);
|
|
10701
|
+
const titleText = titleChild === null || titleChild === void 0 ? void 0 : titleChild.firstChild;
|
|
10702
|
+
if (!(titleText === null || titleText === void 0 ? void 0 : titleText.isText) || titleText.text !== title)
|
|
10703
|
+
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);
|
|
10708
|
+
if (openingStart < 0 || openingEnd < 0 || attributeStart < 0 || valueStart < 0)
|
|
10709
|
+
return;
|
|
10710
|
+
if (attributeStart >= openingEnd || valueStart + title.length > openingEnd)
|
|
10711
|
+
return;
|
|
10712
|
+
state.recordLiteralTextRange([0, 0], valueStart, valueStart + title.length);
|
|
10550
10713
|
}
|
|
10551
10714
|
function renderGenericComponent(state, node, name, renderContent2, excludeAttrs = []) {
|
|
10552
10715
|
renderComponentWithAttrs(state, node, name, node.attrs, renderContent2, excludeAttrs);
|
|
@@ -10943,6 +11106,10 @@ var MARK_PRESERVING_INLINE = /* @__PURE__ */ new Set([
|
|
|
10943
11106
|
BLOCK_TYPES.inlineImage,
|
|
10944
11107
|
BLOCK_TYPES.inlineUnknownTag
|
|
10945
11108
|
]);
|
|
11109
|
+
var serializableMarks = (marks2) => marks2.filter((mark) => {
|
|
11110
|
+
const { open, close } = getMarkStrings(mark);
|
|
11111
|
+
return open.length > 0 || close.length > 0;
|
|
11112
|
+
});
|
|
10946
11113
|
function reorderMarksForLink(marks2, parent, childIndex) {
|
|
10947
11114
|
if (marks2.length < 2)
|
|
10948
11115
|
return marks2;
|
|
@@ -10994,6 +11161,7 @@ function renderInline(state, node, renderNode2, inlineRenderers2) {
|
|
|
10994
11161
|
earliestClose = Math.min(earliestClose, codeIndex);
|
|
10995
11162
|
}
|
|
10996
11163
|
let trailingSpace = "";
|
|
11164
|
+
let trailingTextMapping = null;
|
|
10997
11165
|
const closingFlanking = [...closingIndices].some((idx) => {
|
|
10998
11166
|
const m = active[idx];
|
|
10999
11167
|
return m !== void 0 && usesFlanking(m);
|
|
@@ -11002,6 +11170,7 @@ function renderInline(state, node, renderNode2, inlineRenderers2) {
|
|
|
11002
11170
|
const match = state.out.match(/ +$/);
|
|
11003
11171
|
if (match) {
|
|
11004
11172
|
trailingSpace = match[0];
|
|
11173
|
+
trailingTextMapping = state.takeTextSuffix(trailingSpace.length);
|
|
11005
11174
|
state.out = state.out.slice(0, -trailingSpace.length);
|
|
11006
11175
|
}
|
|
11007
11176
|
}
|
|
@@ -11021,7 +11190,11 @@ function renderInline(state, node, renderNode2, inlineRenderers2) {
|
|
|
11021
11190
|
}
|
|
11022
11191
|
active = active.slice(0, earliestClose);
|
|
11023
11192
|
if (trailingSpace) {
|
|
11193
|
+
const trailingStart = state.out.length;
|
|
11024
11194
|
state.write(trailingSpace);
|
|
11195
|
+
if (trailingTextMapping) {
|
|
11196
|
+
state.recordTextRange(trailingTextMapping, trailingStart, state.out.length);
|
|
11197
|
+
}
|
|
11025
11198
|
}
|
|
11026
11199
|
for (const mark of continuing) {
|
|
11027
11200
|
if (mark.type.name === "code") {
|
|
@@ -11052,32 +11225,35 @@ function renderInline(state, node, renderNode2, inlineRenderers2) {
|
|
|
11052
11225
|
let text = child.text || "";
|
|
11053
11226
|
if (!text)
|
|
11054
11227
|
continue;
|
|
11055
|
-
const
|
|
11228
|
+
const textLength = text.length;
|
|
11229
|
+
let pmOffset = 0;
|
|
11230
|
+
const childMarks = serializableMarks(child.marks);
|
|
11231
|
+
const openingFlanking = childMarks.some((m) => usesFlanking(m) && !active.some((a) => a.eq(m)));
|
|
11056
11232
|
if (openingFlanking) {
|
|
11057
11233
|
const leadingMatch = text.match(/^( +)/);
|
|
11058
11234
|
if (leadingMatch) {
|
|
11059
11235
|
state.write(leadingMatch[0]);
|
|
11236
|
+
state.recordTextSuffix(i, leadingMatch[0].length, 0, leadingMatch[0].length);
|
|
11237
|
+
pmOffset = leadingMatch[0].length;
|
|
11060
11238
|
text = text.slice(leadingMatch[0].length);
|
|
11061
11239
|
if (!text)
|
|
11062
11240
|
continue;
|
|
11063
11241
|
}
|
|
11064
11242
|
}
|
|
11065
|
-
const marks2 = reorderMarksForLink(
|
|
11243
|
+
const marks2 = reorderMarksForLink(childMarks, node, i);
|
|
11066
11244
|
transitionMarks(marks2);
|
|
11067
|
-
|
|
11068
|
-
|
|
11069
|
-
|
|
11070
|
-
state.write(state.esc(text, { inLinkText: active.some((m) => m.type.name === "link") }));
|
|
11071
|
-
}
|
|
11245
|
+
const written = active.some((m) => m.type.name === "code") ? state.escCodeText(text) : state.esc(text, { inLinkText: active.some((m) => m.type.name === "link") });
|
|
11246
|
+
state.write(written);
|
|
11247
|
+
state.recordTextSuffix(i, written.length, pmOffset, textLength);
|
|
11072
11248
|
} else {
|
|
11073
11249
|
if (typeName === BLOCK_TYPES.inlineImage) {
|
|
11074
|
-
transitionMarks(reorderMarksForLink(child.marks, node, i));
|
|
11250
|
+
transitionMarks(reorderMarksForLink(serializableMarks(child.marks), node, i));
|
|
11075
11251
|
inlineRenderers2.renderInlineImage(state, child);
|
|
11076
11252
|
continue;
|
|
11077
11253
|
}
|
|
11078
11254
|
if (typeName === BLOCK_TYPES.inlineUnknownTag) {
|
|
11079
|
-
transitionMarks(reorderMarksForLink(child.marks, node, i));
|
|
11080
|
-
inlineRenderers2.renderUnknownTag(state, child);
|
|
11255
|
+
transitionMarks(reorderMarksForLink(serializableMarks(child.marks), node, i));
|
|
11256
|
+
state.withNodePath(i, () => inlineRenderers2.renderUnknownTag(state, child));
|
|
11081
11257
|
continue;
|
|
11082
11258
|
}
|
|
11083
11259
|
transitionMarks([]);
|
|
@@ -11088,7 +11264,7 @@ function renderInline(state, node, renderNode2, inlineRenderers2) {
|
|
|
11088
11264
|
} else if (typeName === BLOCK_TYPES.badge) {
|
|
11089
11265
|
inlineRenderers2.renderBadge(state, child);
|
|
11090
11266
|
} else if (typeName === BLOCK_TYPES.tooltip) {
|
|
11091
|
-
inlineRenderers2.renderTooltip(state, child);
|
|
11267
|
+
state.withNodePath(i, () => inlineRenderers2.renderTooltip(state, child));
|
|
11092
11268
|
} else if (typeName === BLOCK_TYPES.inlineMath) {
|
|
11093
11269
|
if (child.attrs.expression) {
|
|
11094
11270
|
state.write(`$$${child.attrs.expression}$$`);
|
|
@@ -11104,7 +11280,7 @@ function renderTextNode(state, node) {
|
|
|
11104
11280
|
const text = node.text || "";
|
|
11105
11281
|
if (!text)
|
|
11106
11282
|
return;
|
|
11107
|
-
const marks2 = node.marks;
|
|
11283
|
+
const marks2 = serializableMarks(node.marks);
|
|
11108
11284
|
let openMarks = "";
|
|
11109
11285
|
let closeMarks = "";
|
|
11110
11286
|
for (const mark of marks2) {
|
|
@@ -11242,8 +11418,12 @@ function hasReferenceDefinitions(doc) {
|
|
|
11242
11418
|
return found;
|
|
11243
11419
|
}
|
|
11244
11420
|
function pmToMdx(doc, options = {}) {
|
|
11421
|
+
return serializeDoc(doc, options, null).mdx;
|
|
11422
|
+
}
|
|
11423
|
+
function serializeDoc(doc, options, sourceMap) {
|
|
11245
11424
|
const { frontmatter } = options, serializerOptions = __rest2(options, ["frontmatter"]);
|
|
11246
11425
|
const state = new SerializerState(Object.assign(Object.assign({}, serializerOptions), { hasReferenceDefinitions: hasReferenceDefinitions(doc) }));
|
|
11426
|
+
state.sourceMap = sourceMap;
|
|
11247
11427
|
if (frontmatter && Object.keys(frontmatter).length > 0) {
|
|
11248
11428
|
const entries = Object.entries(filterFrontmatterRecord(frontmatter));
|
|
11249
11429
|
if (entries.length > 0) {
|
|
@@ -11260,19 +11440,20 @@ function pmToMdx(doc, options = {}) {
|
|
|
11260
11440
|
if (options.removeTrailingNewline !== false && result.endsWith("\n")) {
|
|
11261
11441
|
result = result.replace(/\n+$/, "");
|
|
11262
11442
|
}
|
|
11263
|
-
return result;
|
|
11443
|
+
return { mdx: result, sourceMap: sourceMap !== null && sourceMap !== void 0 ? sourceMap : [] };
|
|
11264
11444
|
}
|
|
11265
11445
|
function renderContent(state, node) {
|
|
11266
11446
|
for (let i = 0; i < node.childCount; i++) {
|
|
11267
11447
|
const child = node.child(i);
|
|
11268
11448
|
if (i > 0) {
|
|
11269
11449
|
state.ensureNewLine();
|
|
11270
|
-
|
|
11271
|
-
if (needsBlankLine(prev, child)) {
|
|
11450
|
+
if (needsBlankLine(node.child(i - 1), child)) {
|
|
11272
11451
|
state.ensureNewLine();
|
|
11273
11452
|
}
|
|
11274
11453
|
}
|
|
11454
|
+
const start = state.beginBlock(i);
|
|
11275
11455
|
renderNode(state, child, node, i);
|
|
11456
|
+
state.endBlock(start);
|
|
11276
11457
|
}
|
|
11277
11458
|
}
|
|
11278
11459
|
function needsBlankLine(prev, current) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/cli",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1463",
|
|
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.
|
|
89
|
+
"@mintlify/editor": "0.0.351",
|
|
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": "
|
|
108
|
+
"gitHead": "f828b446b1bcec7e17b0b2b4b8a76cbf9f8d9eef"
|
|
109
109
|
}
|