@mintlify/cli 4.0.1438 → 4.0.1440

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.
@@ -1808,6 +1808,11 @@ function handleHtmlTable(node, ctx, transformNode2, mapJsxChildren2) {
1808
1808
  for (const child of node.children) {
1809
1809
  if (isTableRowJsxNode(child)) {
1810
1810
  rows.push(child);
1811
+ } else if (child.type === "paragraph") {
1812
+ for (const paragraphChild of child.children) {
1813
+ if (isTableRowJsxNode(paragraphChild))
1814
+ rows.push(paragraphChild);
1815
+ }
1811
1816
  } else if (child.type === "mdxJsxFlowElement" && (child.name === "tbody" || child.name === "thead")) {
1812
1817
  for (const rowChild of child.children) {
1813
1818
  if (isTableRowJsxNode(rowChild)) {
@@ -1825,7 +1830,7 @@ function handleHtmlTable(node, ctx, transformNode2, mapJsxChildren2) {
1825
1830
  return { type: "table", content: [] };
1826
1831
  }
1827
1832
  const tableContent = rows.map((row, rowIndex) => {
1828
- const cells = row.children.filter(isTableCellJsxNode);
1833
+ const cells = collectTableCellJsxNodes(row);
1829
1834
  return {
1830
1835
  type: "tableRow",
1831
1836
  content: cells.map((cell) => {
@@ -1861,6 +1866,20 @@ function flattenPmContent(content) {
1861
1866
  function isTableRowJsxNode(node) {
1862
1867
  return (node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") && node.name === "tr";
1863
1868
  }
1869
+ function collectTableCellJsxNodes(row) {
1870
+ const cells = [];
1871
+ for (const child of row.children) {
1872
+ if (isTableCellJsxNode(child)) {
1873
+ cells.push(child);
1874
+ } else if (child.type === "paragraph") {
1875
+ for (const paragraphChild of child.children) {
1876
+ if (isTableCellJsxNode(paragraphChild))
1877
+ cells.push(paragraphChild);
1878
+ }
1879
+ }
1880
+ }
1881
+ return cells;
1882
+ }
1864
1883
  function isTableCellJsxNode(node) {
1865
1884
  return (node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") && (node.name === "td" || node.name === "th");
1866
1885
  }
@@ -3370,12 +3389,13 @@ function renderTooltip(state, node, renderInline2) {
3370
3389
  function renderStaticHTML(state, node, renderContent2) {
3371
3390
  var _a;
3372
3391
  const inline = state.inTable || node.type.name === BLOCK_TYPES.inlineStaticHTML;
3392
+ const escapeTablePipes = (value) => state.inTable ? value.replace(/\|/g, "|") : value;
3373
3393
  const mdxJsxNode = node.attrs.mdxJsxNode;
3374
3394
  if (mdxJsxNode) {
3375
3395
  try {
3376
3396
  const str = stringifyMdxNode([mdxJsxNode]);
3377
3397
  if (inline) {
3378
- state.write(str.replace(/\s*\n\s*/g, " ").trim());
3398
+ state.write(escapeTablePipes(str.replace(/\s*\n\s*/g, " ").trim()));
3379
3399
  } else {
3380
3400
  state.write(str);
3381
3401
  state.closeBlock();
@@ -3406,8 +3426,17 @@ function renderStaticHTML(state, node, renderContent2) {
3406
3426
  if (!inline)
3407
3427
  state.closeBlock();
3408
3428
  }
3429
+ var isMdxExpressionNode = (value) => typeof value === "object" && value !== null && (value.type === "mdxFlowExpression" || value.type === "mdxTextExpression") && typeof value.value === "string";
3409
3430
  function renderUnknownTag(state, node) {
3410
3431
  const mdxJsxNode = node.attrs.mdxJsxNode;
3432
+ if (isMdxExpressionNode(mdxJsxNode)) {
3433
+ const value = mdxJsxNode.value.split("\n").map((line, index) => index === 0 || line === "" ? line : ` ${line}`).join("\n");
3434
+ state.write(`{${value}}`);
3435
+ if (node.type.name === BLOCK_TYPES.unknownTag) {
3436
+ state.closeBlock();
3437
+ }
3438
+ return;
3439
+ }
3411
3440
  if (mdxJsxNode) {
3412
3441
  try {
3413
3442
  const str = stringifyMdxNode([mdxJsxNode]);
@@ -3858,6 +3887,11 @@ var __rest2 = function(s, e) {
3858
3887
  }
3859
3888
  return t;
3860
3889
  };
3890
+ var canonicalPmToMdxOptions = {
3891
+ tightLists: true,
3892
+ indentSize: 2,
3893
+ removeTrailingNewline: true
3894
+ };
3861
3895
  var BLOCK_LINE_TYPES = /* @__PURE__ */ new Set([
3862
3896
  "paragraph",
3863
3897
  "heading",
@@ -8966,6 +9000,7 @@ export {
8966
9000
  HTML_ELEMENTS,
8967
9001
  IMAGE_ALIGN_CLASSES,
8968
9002
  attrsEqual,
9003
+ canonicalPmToMdxOptions,
8969
9004
  createSchema,
8970
9005
  deepEqual,
8971
9006
  diffDocs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/cli",
3
- "version": "4.0.1438",
3
+ "version": "4.0.1440",
4
4
  "description": "The Mintlify CLI",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -45,11 +45,11 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@inquirer/prompts": "7.9.0",
48
- "@mintlify/common": "1.0.1111",
49
- "@mintlify/link-rot": "3.0.1313",
48
+ "@mintlify/common": "1.0.1112",
49
+ "@mintlify/link-rot": "3.0.1314",
50
50
  "@mintlify/models": "0.0.351",
51
- "@mintlify/prebuild": "1.0.1265",
52
- "@mintlify/previewing": "4.0.1337",
51
+ "@mintlify/prebuild": "1.0.1266",
52
+ "@mintlify/previewing": "4.0.1338",
53
53
  "@mintlify/validation": "0.1.842",
54
54
  "adm-zip": "0.6.0",
55
55
  "chalk": "5.2.0",
@@ -86,7 +86,7 @@
86
86
  "keytar": "7.9.0"
87
87
  },
88
88
  "devDependencies": {
89
- "@mintlify/editor": "0.0.328",
89
+ "@mintlify/editor": "0.0.330",
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": "a7aa8658185853553564a04b1132bbd9dec768d5"
108
+ "gitHead": "3f5b891252d91b608b74a6e584e371fa1a7081d1"
109
109
  }
package/src/format.tsx CHANGED
@@ -31,7 +31,7 @@ async function* walk(dir: string, ignores: string[]): AsyncGenerator<string> {
31
31
  }
32
32
 
33
33
  export const formatHandler = async (): Promise<void> => {
34
- const { mdxToPm, pmToMdx } = await import('./vendor/converter.js');
34
+ const { mdxToPm, pmToMdx, canonicalPmToMdxOptions } = await import('./vendor/converter.js');
35
35
  const ignores = [...(await getGitIgnore()), ...(await getMintIgnore(CMD_EXEC_PATH))];
36
36
  let total = 0;
37
37
  let changed = 0;
@@ -42,8 +42,18 @@ export const formatHandler = async (): Promise<void> => {
42
42
  const relative = path.relative(CMD_EXEC_PATH, file);
43
43
  try {
44
44
  const raw = await fs.readFile(file, 'utf-8');
45
- const { doc, frontmatter } = mdxToPm(raw, { singleDollarTextMath: false });
46
- const formatted = `${pmToMdx(doc, { frontmatter })}\n`;
45
+ let formatted = raw;
46
+ let originalFrontmatterKeys = 0;
47
+ for (let pass = 0; pass < 3; pass++) {
48
+ const { doc, frontmatter } = mdxToPm(formatted, { singleDollarTextMath: false });
49
+ if (pass === 0) originalFrontmatterKeys = Object.keys(frontmatter).length;
50
+ const next = `${pmToMdx(doc, { frontmatter, ...canonicalPmToMdxOptions })}\n`;
51
+ if (next === formatted) break;
52
+ formatted = next;
53
+ }
54
+ if (originalFrontmatterKeys > 0 && !formatted.startsWith('---')) {
55
+ throw new Error('formatting would remove frontmatter; file left untouched');
56
+ }
47
57
  if (formatted !== raw) {
48
58
  await fs.writeFile(file, formatted);
49
59
  changed++;