@mintlify/cli 4.0.1484 → 4.0.1486
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 +128 -19
- package/package.json +9 -9
package/bin/vendor/converter.js
CHANGED
|
@@ -588,11 +588,11 @@ var nodes = {
|
|
|
588
588
|
},
|
|
589
589
|
tableHeader: {
|
|
590
590
|
content: "block*",
|
|
591
|
-
attrs: attrs({ align: null })
|
|
591
|
+
attrs: attrs({ align: null, colwidth: null })
|
|
592
592
|
},
|
|
593
593
|
tableCell: {
|
|
594
594
|
content: "block*",
|
|
595
|
-
attrs: attrs({ align: null })
|
|
595
|
+
attrs: attrs({ align: null, colwidth: null })
|
|
596
596
|
},
|
|
597
597
|
[BLOCK_TYPES.codeBlock]: {
|
|
598
598
|
content: "text*",
|
|
@@ -1923,13 +1923,15 @@ function handleHtmlTable(node, ctx, transformNode2, mapJsxChildren2) {
|
|
|
1923
1923
|
if (rows.length === 0) {
|
|
1924
1924
|
return { type: "table", content: [] };
|
|
1925
1925
|
}
|
|
1926
|
+
const colWidths = collectColWidths(node);
|
|
1926
1927
|
const tableContent = rows.map((row, rowIndex) => {
|
|
1927
1928
|
const cells = collectTableCellJsxNodes(row);
|
|
1928
1929
|
return {
|
|
1929
1930
|
type: "tableRow",
|
|
1930
|
-
content: cells.map((cell) => {
|
|
1931
|
+
content: cells.map((cell, cellIndex) => {
|
|
1931
1932
|
var _a;
|
|
1932
1933
|
const isHeader = cell.name === "th" || rowIndex === 0;
|
|
1934
|
+
const colwidth = colWidths[cellIndex];
|
|
1933
1935
|
const attrs2 = parseMdxAttributes(cell.attributes);
|
|
1934
1936
|
const style = attrs2.style;
|
|
1935
1937
|
const styleString = typeof style === "string" ? style : style && typeof style === "object" ? Object.entries(style).map(([key, value]) => `${key}: ${String(value)}`).join("; ") : "";
|
|
@@ -1937,7 +1939,7 @@ function handleHtmlTable(node, ctx, transformNode2, mapJsxChildren2) {
|
|
|
1937
1939
|
const content = convertHtmlTableCellChildren(cell, ctx, transformNode2, mapJsxChildren2);
|
|
1938
1940
|
return {
|
|
1939
1941
|
type: isHeader ? "tableHeader" : "tableCell",
|
|
1940
|
-
attrs: { align: (_a = alignMatch === null || alignMatch === void 0 ? void 0 : alignMatch[1]) !== null && _a !== void 0 ? _a : null },
|
|
1942
|
+
attrs: { align: (_a = alignMatch === null || alignMatch === void 0 ? void 0 : alignMatch[1]) !== null && _a !== void 0 ? _a : null, colwidth: colwidth ? [colwidth] : null },
|
|
1941
1943
|
content: content.length > 0 ? content : [{ type: "paragraph" }]
|
|
1942
1944
|
};
|
|
1943
1945
|
})
|
|
@@ -1945,6 +1947,48 @@ function handleHtmlTable(node, ctx, transformNode2, mapJsxChildren2) {
|
|
|
1945
1947
|
});
|
|
1946
1948
|
return { type: "table", content: tableContent };
|
|
1947
1949
|
}
|
|
1950
|
+
function isJsxElementNamed(node, name) {
|
|
1951
|
+
return (node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") && node.name === name;
|
|
1952
|
+
}
|
|
1953
|
+
function collectJsxElementsNamed(children, name) {
|
|
1954
|
+
const found = [];
|
|
1955
|
+
for (const child of children) {
|
|
1956
|
+
if (isJsxElementNamed(child, name)) {
|
|
1957
|
+
found.push(child);
|
|
1958
|
+
} else if (child.type === "paragraph") {
|
|
1959
|
+
for (const paragraphChild of child.children) {
|
|
1960
|
+
if (isJsxElementNamed(paragraphChild, name))
|
|
1961
|
+
found.push(paragraphChild);
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
return found;
|
|
1966
|
+
}
|
|
1967
|
+
function parseColWidth(col) {
|
|
1968
|
+
var _a, _b;
|
|
1969
|
+
const attrs2 = parseMdxAttributes(col.attributes);
|
|
1970
|
+
const style = attrs2.style;
|
|
1971
|
+
const styleWidth = typeof style === "string" ? (_a = style.match(/(?:^|;)\s*width:\s*([^;]+)/i)) === null || _a === void 0 ? void 0 : _a[1] : style && typeof style === "object" ? style.width : void 0;
|
|
1972
|
+
const raw = (_b = attrs2.width) !== null && _b !== void 0 ? _b : styleWidth;
|
|
1973
|
+
if (typeof raw === "number")
|
|
1974
|
+
return raw > 0 ? raw : null;
|
|
1975
|
+
if (typeof raw !== "string")
|
|
1976
|
+
return null;
|
|
1977
|
+
const match = raw.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/);
|
|
1978
|
+
const width = (match === null || match === void 0 ? void 0 : match[1]) ? Number(match[1]) : NaN;
|
|
1979
|
+
return width > 0 ? width : null;
|
|
1980
|
+
}
|
|
1981
|
+
function parseColSpan(col) {
|
|
1982
|
+
const span = Number(parseMdxAttributes(col.attributes).span);
|
|
1983
|
+
return Number.isInteger(span) && span > 0 ? span : 1;
|
|
1984
|
+
}
|
|
1985
|
+
function collectColWidths(table) {
|
|
1986
|
+
const cols = collectJsxElementsNamed(table.children, "col");
|
|
1987
|
+
for (const colgroup of collectJsxElementsNamed(table.children, "colgroup")) {
|
|
1988
|
+
cols.push(...collectJsxElementsNamed(colgroup.children, "col"));
|
|
1989
|
+
}
|
|
1990
|
+
return cols.flatMap((col) => Array(parseColSpan(col)).fill(parseColWidth(col)));
|
|
1991
|
+
}
|
|
1948
1992
|
function flattenPmContent(content) {
|
|
1949
1993
|
return Array.isArray(content) ? content.filter(Boolean) : [content];
|
|
1950
1994
|
}
|
|
@@ -10135,6 +10179,7 @@ var SerializerState = class {
|
|
|
10135
10179
|
this.delim = "";
|
|
10136
10180
|
this.closed = false;
|
|
10137
10181
|
this.inTable = false;
|
|
10182
|
+
this.inHtmlTable = false;
|
|
10138
10183
|
this.inCodeSection = false;
|
|
10139
10184
|
this.hasReferenceDefinitions = false;
|
|
10140
10185
|
this.indentSize = 2;
|
|
@@ -10369,8 +10414,11 @@ var SerializerState = class {
|
|
|
10369
10414
|
}
|
|
10370
10415
|
this.write(str2);
|
|
10371
10416
|
}
|
|
10417
|
+
get escapesPipes() {
|
|
10418
|
+
return this.inTable && !this.inHtmlTable;
|
|
10419
|
+
}
|
|
10372
10420
|
escCodeText(str2) {
|
|
10373
|
-
return this.
|
|
10421
|
+
return this.escapesPipes ? str2.replace(/\|/g, "\\|") : str2;
|
|
10374
10422
|
}
|
|
10375
10423
|
/** Escapes special Markdown characters in the input string. */
|
|
10376
10424
|
esc(str2, options = {}) {
|
|
@@ -10395,7 +10443,7 @@ var SerializerState = class {
|
|
|
10395
10443
|
return true;
|
|
10396
10444
|
switch (ch) {
|
|
10397
10445
|
case "|":
|
|
10398
|
-
return this.
|
|
10446
|
+
return this.escapesPipes;
|
|
10399
10447
|
case "_":
|
|
10400
10448
|
return !(isWordChar(prev) && isWordChar(next));
|
|
10401
10449
|
case "[":
|
|
@@ -10657,6 +10705,13 @@ function renderTable(state, node, renderInline2, renderNode2) {
|
|
|
10657
10705
|
state.inTable = false;
|
|
10658
10706
|
return;
|
|
10659
10707
|
}
|
|
10708
|
+
if (getColumnWidths(node).some((width) => width !== null)) {
|
|
10709
|
+
state.inHtmlTable = true;
|
|
10710
|
+
renderHtmlTable(state, node, renderInline2, renderNode2);
|
|
10711
|
+
state.inHtmlTable = false;
|
|
10712
|
+
state.inTable = false;
|
|
10713
|
+
return;
|
|
10714
|
+
}
|
|
10660
10715
|
for (let rowIndex = 0; rowIndex < node.childCount; rowIndex++) {
|
|
10661
10716
|
const row = node.child(rowIndex);
|
|
10662
10717
|
state.write("|");
|
|
@@ -10686,48 +10741,102 @@ function renderTable(state, node, renderInline2, renderNode2) {
|
|
|
10686
10741
|
state.closeBlock();
|
|
10687
10742
|
state.inTable = false;
|
|
10688
10743
|
}
|
|
10689
|
-
function
|
|
10744
|
+
function getColumnWidths(table) {
|
|
10745
|
+
var _a;
|
|
10746
|
+
const widths = [];
|
|
10747
|
+
(_a = table.firstChild) === null || _a === void 0 ? void 0 : _a.forEach((cell) => {
|
|
10748
|
+
var _a2;
|
|
10749
|
+
const colwidth = cell.attrs.colwidth;
|
|
10750
|
+
const colspan = (_a2 = cell.attrs.colspan) !== null && _a2 !== void 0 ? _a2 : 1;
|
|
10751
|
+
for (let i = 0; i < colspan; i++) {
|
|
10752
|
+
const width = colwidth === null || colwidth === void 0 ? void 0 : colwidth[i];
|
|
10753
|
+
widths.push(typeof width === "number" && width > 0 ? width : null);
|
|
10754
|
+
}
|
|
10755
|
+
});
|
|
10756
|
+
return widths;
|
|
10757
|
+
}
|
|
10758
|
+
function renderHtmlTable(state, node, renderInline2, renderNode2) {
|
|
10759
|
+
const writeLine = (line) => {
|
|
10760
|
+
state.write(line);
|
|
10761
|
+
state.ensureNewLine();
|
|
10762
|
+
};
|
|
10763
|
+
const writeRow = (row, indent) => {
|
|
10764
|
+
writeLine(`${indent}<tr>`);
|
|
10765
|
+
row.forEach((cell) => {
|
|
10766
|
+
const tag = cell.type.name === "tableHeader" ? "th" : "td";
|
|
10767
|
+
const align = cell.attrs.align;
|
|
10768
|
+
const attrs2 = align && align !== "left" ? ` style={{ textAlign: "${align}" }}` : "";
|
|
10769
|
+
const content = renderTableCellContent(cell, state.options, renderInline2, renderNode2, true);
|
|
10770
|
+
writeLine(`${indent} <${tag}${attrs2}>${content}</${tag}>`);
|
|
10771
|
+
});
|
|
10772
|
+
writeLine(`${indent}</tr>`);
|
|
10773
|
+
};
|
|
10774
|
+
writeLine("<table>");
|
|
10775
|
+
writeLine(" <colgroup>");
|
|
10776
|
+
for (const width of getColumnWidths(node)) {
|
|
10777
|
+
writeLine(width === null ? " <col />" : ` <col width="${Math.round(width)}" />`);
|
|
10778
|
+
}
|
|
10779
|
+
writeLine(" </colgroup>");
|
|
10780
|
+
const headerRow = node.firstChild;
|
|
10781
|
+
if (headerRow) {
|
|
10782
|
+
writeLine(" <thead>");
|
|
10783
|
+
writeRow(headerRow, " ");
|
|
10784
|
+
writeLine(" </thead>");
|
|
10785
|
+
}
|
|
10786
|
+
if (node.childCount > 1) {
|
|
10787
|
+
writeLine(" <tbody>");
|
|
10788
|
+
for (let rowIndex = 1; rowIndex < node.childCount; rowIndex++) {
|
|
10789
|
+
writeRow(node.child(rowIndex), " ");
|
|
10790
|
+
}
|
|
10791
|
+
writeLine(" </tbody>");
|
|
10792
|
+
}
|
|
10793
|
+
writeLine("</table>");
|
|
10794
|
+
state.closeBlock();
|
|
10795
|
+
}
|
|
10796
|
+
function renderTableCellContent(cell, options, renderInline2, renderNode2, htmlTable = false) {
|
|
10690
10797
|
const parts = [];
|
|
10691
10798
|
cell.forEach((child) => {
|
|
10692
10799
|
if (child.type.name === "paragraph") {
|
|
10693
|
-
const text = renderTableInlineContent(child, options, renderInline2);
|
|
10800
|
+
const text = renderTableInlineContent(child, options, renderInline2, htmlTable);
|
|
10694
10801
|
if (text)
|
|
10695
10802
|
parts.push(text);
|
|
10696
10803
|
return;
|
|
10697
10804
|
}
|
|
10698
10805
|
if (child.type.name === "heading") {
|
|
10699
|
-
const text = renderTableInlineContent(child, options, renderInline2);
|
|
10806
|
+
const text = renderTableInlineContent(child, options, renderInline2, htmlTable);
|
|
10700
10807
|
const level = child.attrs.level || 1;
|
|
10701
10808
|
if (text)
|
|
10702
10809
|
parts.push(`<h${level}>${text}</h${level}>`);
|
|
10703
10810
|
return;
|
|
10704
10811
|
}
|
|
10705
|
-
const block = renderTableBlockContent(child, options, renderInline2, renderNode2);
|
|
10812
|
+
const block = renderTableBlockContent(child, options, renderInline2, renderNode2, htmlTable);
|
|
10706
10813
|
if (block)
|
|
10707
10814
|
parts.push(block);
|
|
10708
10815
|
});
|
|
10709
10816
|
return parts.join(" ");
|
|
10710
10817
|
}
|
|
10711
|
-
function renderTableInlineContent(node, options, renderInline2) {
|
|
10818
|
+
function renderTableInlineContent(node, options, renderInline2, htmlTable = false) {
|
|
10712
10819
|
const childState = new SerializerState(options);
|
|
10713
10820
|
childState.inTable = true;
|
|
10821
|
+
childState.inHtmlTable = htmlTable;
|
|
10714
10822
|
renderInline2(childState, node);
|
|
10715
10823
|
return childState.out.replace(/\n/g, " ").trim();
|
|
10716
10824
|
}
|
|
10717
|
-
function renderTableNodeContent(node, options, renderNode2) {
|
|
10825
|
+
function renderTableNodeContent(node, options, renderNode2, htmlTable = false) {
|
|
10718
10826
|
const childState = new SerializerState(options);
|
|
10719
10827
|
childState.inTable = true;
|
|
10828
|
+
childState.inHtmlTable = htmlTable;
|
|
10720
10829
|
renderNode2(childState, node, node, 0);
|
|
10721
10830
|
return childState.out.replace(/\n+/g, " ").replace(/\s+/g, " ").trim();
|
|
10722
10831
|
}
|
|
10723
|
-
function renderTableBlockContent(node, options, renderInline2, renderNode2) {
|
|
10832
|
+
function renderTableBlockContent(node, options, renderInline2, renderNode2, htmlTable = false) {
|
|
10724
10833
|
if (node.type.name === "image" || node.type.name === BLOCK_TYPES.image) {
|
|
10725
10834
|
return renderImageInTableCell(node);
|
|
10726
10835
|
}
|
|
10727
10836
|
if (node.type.name === BLOCK_TYPES.frame) {
|
|
10728
10837
|
const innerParts = [];
|
|
10729
10838
|
node.forEach((frameChild) => {
|
|
10730
|
-
const rendered = renderTableBlockContent(frameChild, options, renderInline2, renderNode2);
|
|
10839
|
+
const rendered = renderTableBlockContent(frameChild, options, renderInline2, renderNode2, htmlTable);
|
|
10731
10840
|
if (rendered)
|
|
10732
10841
|
innerParts.push(rendered);
|
|
10733
10842
|
});
|
|
@@ -10743,19 +10852,19 @@ function renderTableBlockContent(node, options, renderInline2, renderNode2) {
|
|
|
10743
10852
|
const itemParts = [];
|
|
10744
10853
|
listItem.forEach((itemChild) => {
|
|
10745
10854
|
if (itemChild.type.name === "paragraph") {
|
|
10746
|
-
const text = renderTableInlineContent(itemChild, options, renderInline2);
|
|
10855
|
+
const text = renderTableInlineContent(itemChild, options, renderInline2, htmlTable);
|
|
10747
10856
|
if (text)
|
|
10748
10857
|
itemParts.push(text);
|
|
10749
10858
|
return;
|
|
10750
10859
|
}
|
|
10751
10860
|
if (itemChild.type.name === "heading") {
|
|
10752
|
-
const text = renderTableInlineContent(itemChild, options, renderInline2);
|
|
10861
|
+
const text = renderTableInlineContent(itemChild, options, renderInline2, htmlTable);
|
|
10753
10862
|
const level = itemChild.attrs.level || 1;
|
|
10754
10863
|
if (text)
|
|
10755
10864
|
itemParts.push(`<h${level}>${text}</h${level}>`);
|
|
10756
10865
|
return;
|
|
10757
10866
|
}
|
|
10758
|
-
const block = renderTableBlockContent(itemChild, options, renderInline2, renderNode2);
|
|
10867
|
+
const block = renderTableBlockContent(itemChild, options, renderInline2, renderNode2, htmlTable);
|
|
10759
10868
|
if (block)
|
|
10760
10869
|
itemParts.push(block);
|
|
10761
10870
|
});
|
|
@@ -10763,7 +10872,7 @@ function renderTableBlockContent(node, options, renderInline2, renderNode2) {
|
|
|
10763
10872
|
});
|
|
10764
10873
|
return `<${tag}>${items.join("")}</${tag}>`;
|
|
10765
10874
|
}
|
|
10766
|
-
return renderTableNodeContent(node, options, renderNode2);
|
|
10875
|
+
return renderTableNodeContent(node, options, renderNode2, htmlTable);
|
|
10767
10876
|
}
|
|
10768
10877
|
function renderImageInTableCell(node) {
|
|
10769
10878
|
var _a;
|
|
@@ -11025,7 +11134,7 @@ function renderTooltip(state, node, renderInline2) {
|
|
|
11025
11134
|
function renderStaticHTML(state, node, renderContent2) {
|
|
11026
11135
|
var _a;
|
|
11027
11136
|
const inline = state.inTable || node.type.name === BLOCK_TYPES.inlineStaticHTML;
|
|
11028
|
-
const escapeTablePipes = (value) => state.
|
|
11137
|
+
const escapeTablePipes = (value) => state.escapesPipes ? value.replace(/\|/g, "|") : value;
|
|
11029
11138
|
const mdxJsxNode = node.attrs.mdxJsxNode;
|
|
11030
11139
|
if (mdxJsxNode) {
|
|
11031
11140
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/cli",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1486",
|
|
4
4
|
"description": "The Mintlify CLI",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@inquirer/prompts": "7.9.0",
|
|
48
|
-
"@mintlify/common": "1.0.
|
|
49
|
-
"@mintlify/link-rot": "3.0.
|
|
50
|
-
"@mintlify/models": "0.0.
|
|
51
|
-
"@mintlify/prebuild": "1.0.
|
|
52
|
-
"@mintlify/previewing": "4.0.
|
|
53
|
-
"@mintlify/validation": "0.1.
|
|
48
|
+
"@mintlify/common": "1.0.1137",
|
|
49
|
+
"@mintlify/link-rot": "3.0.1339",
|
|
50
|
+
"@mintlify/models": "0.0.354",
|
|
51
|
+
"@mintlify/prebuild": "1.0.1291",
|
|
52
|
+
"@mintlify/previewing": "4.0.1363",
|
|
53
|
+
"@mintlify/validation": "0.1.851",
|
|
54
54
|
"adm-zip": "0.6.0",
|
|
55
55
|
"chalk": "5.2.0",
|
|
56
56
|
"color": "4.2.3",
|
|
@@ -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.370",
|
|
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": "b5aaa27069f02a73c2029bbf0f8340de6b4bb149"
|
|
109
109
|
}
|