@mintlify/cli 4.0.1708 → 4.0.1709

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.
@@ -13727,6 +13727,189 @@ function mdxToPm(mdx, options) {
13727
13727
  return mdastToPm(mdast, mdx, options);
13728
13728
  }
13729
13729
 
13730
+ // ../editor/dist/converter/parse/md-to-mdast.js
13731
+ import { unwrapCurrencyMath as unwrapCurrencyMath2 } from "@mintlify/common";
13732
+ import { remark as remark2 } from "remark";
13733
+ import remarkFrontmatter2 from "remark-frontmatter";
13734
+ import remarkGfm2 from "remark-gfm";
13735
+ import remarkMath2 from "remark-math";
13736
+ import { visit as visit4 } from "unist-util-visit";
13737
+ var markdownRemark = remark2().use(remarkGfm2).use(remarkFrontmatter2, ["yaml", "toml"]).use(remarkMath2).freeze();
13738
+ var CONTAINER_TAG = /(<\/?(?:aside|details)\b[^>]*>|<summary\b[^>]*>[\s\S]*?<\/summary>)/i;
13739
+ var SUMMARY_TAG = /^<summary\b[^>]*>([\s\S]*?)<\/summary>$/i;
13740
+ var VOID_TAG = /<(area|br|col|embed|hr|img|input|source|track|wbr)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*\/?>/gi;
13741
+ var OPENING_TAG = /^<([a-z][\w-]*)\b[^>]*(?<!\/)>$/i;
13742
+ var ANY_TAG = /<\/?[a-z][^>]*>/gi;
13743
+ var PHRASING_PARENTS = /* @__PURE__ */ new Set([
13744
+ "paragraph",
13745
+ "heading",
13746
+ "tableCell",
13747
+ "emphasis",
13748
+ "strong",
13749
+ "delete",
13750
+ "link",
13751
+ "linkReference"
13752
+ ]);
13753
+ var isMarker = (item) => "open" in item || "close" in item || "summary" in item;
13754
+ var isSummary = (node) => ((node === null || node === void 0 ? void 0 : node.type) === "mdxJsxFlowElement" || (node === null || node === void 0 ? void 0 : node.type) === "mdxJsxTextElement") && node.name === "summary";
13755
+ var toElement = ({ tag, title, children }) => ({
13756
+ type: "mdxJsxFlowElement",
13757
+ name: tag === "aside" ? "Callout" : "Accordion",
13758
+ attributes: tag === "details" ? [{ type: "mdxJsxAttribute", name: "title", value: title !== null && title !== void 0 ? title : "" }] : [],
13759
+ children
13760
+ });
13761
+ function takeSummary(children) {
13762
+ const [first] = children;
13763
+ if (isSummary(first)) {
13764
+ children.shift();
13765
+ return extractTextFromNode(first).text.trim();
13766
+ }
13767
+ if ((first === null || first === void 0 ? void 0 : first.type) !== "paragraph" || !isSummary(first.children[0]))
13768
+ return void 0;
13769
+ const summary = first.children.shift();
13770
+ if (!extractTextFromNode(first).text.trim())
13771
+ children.shift();
13772
+ return extractTextFromNode(summary).text.trim();
13773
+ }
13774
+ function promoteHtmlContainers(root) {
13775
+ visit4(root, "mdxJsxFlowElement", (node, index, parent) => {
13776
+ if (!parent || index === void 0 || node.name !== "aside" && node.name !== "details")
13777
+ return;
13778
+ const children = node.children;
13779
+ const title = node.name === "details" ? takeSummary(children) : void 0;
13780
+ parent.children[index] = toElement({ tag: node.name, title, children });
13781
+ });
13782
+ }
13783
+ var JSX_COMMENT = /^\s*\/\*[\s\S]*\*\/\s*$/;
13784
+ function expressionsToText(root) {
13785
+ visit4(root, (node, index, parent) => {
13786
+ if (node.type !== "mdxTextExpression" && node.type !== "mdxFlowExpression")
13787
+ return;
13788
+ if (!parent || index === void 0 || JSX_COMMENT.test(node.value))
13789
+ return;
13790
+ const text = { type: "text", value: `{${node.value}}` };
13791
+ parent.children[index] = node.type === "mdxFlowExpression" ? { type: "paragraph", children: [text] } : text;
13792
+ });
13793
+ }
13794
+ function htmlToMdast(html) {
13795
+ try {
13796
+ return mdxToMdast(html.replace(VOID_TAG, "<$1$2 />")).children;
13797
+ } catch (_a) {
13798
+ const text = html.replace(ANY_TAG, "").trim();
13799
+ return text ? [{ type: "paragraph", children: [{ type: "text", value: text }] }] : [];
13800
+ }
13801
+ }
13802
+ function inlineHtml(html) {
13803
+ return htmlToMdast(html).flatMap((node) => {
13804
+ if (node.type === "paragraph")
13805
+ return node.children;
13806
+ if (node.type === "mdxJsxFlowElement")
13807
+ return [Object.assign(Object.assign({}, node), { type: "mdxJsxTextElement" })];
13808
+ return [];
13809
+ });
13810
+ }
13811
+ function blockHtml(html) {
13812
+ const parts = html.split(CONTAINER_TAG);
13813
+ if (parts.length === 1)
13814
+ return htmlToMdast(html);
13815
+ return parts.flatMap((part, i) => {
13816
+ var _a;
13817
+ if (i % 2 === 0)
13818
+ return part.trim() ? markdownToMdast(part).children : [];
13819
+ const summary = SUMMARY_TAG.exec(part);
13820
+ if (summary)
13821
+ return [{ summary: ((_a = summary[1]) !== null && _a !== void 0 ? _a : "").replace(ANY_TAG, "").trim() }];
13822
+ if (part.startsWith("</"))
13823
+ return [{ close: true }];
13824
+ return [{ open: /^<aside/i.test(part) ? "aside" : "details" }];
13825
+ });
13826
+ }
13827
+ function groupContainers(items) {
13828
+ const root = [];
13829
+ const stack = [];
13830
+ const current2 = () => {
13831
+ var _a, _b;
13832
+ return (_b = (_a = stack.at(-1)) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : root;
13833
+ };
13834
+ const close = () => {
13835
+ const frame = stack.pop();
13836
+ if (frame)
13837
+ current2().push(toElement(frame));
13838
+ };
13839
+ for (const item of items) {
13840
+ if (!isMarker(item))
13841
+ current2().push(item);
13842
+ else if ("open" in item)
13843
+ stack.push({ tag: item.open, children: [] });
13844
+ else if ("close" in item)
13845
+ close();
13846
+ else {
13847
+ const frame = stack.at(-1);
13848
+ if (frame)
13849
+ frame.title = item.summary;
13850
+ else
13851
+ root.push({ type: "paragraph", children: [{ type: "text", value: item.summary }] });
13852
+ }
13853
+ }
13854
+ while (stack.length > 0)
13855
+ close();
13856
+ return root;
13857
+ }
13858
+ function pairedInlineHtml(children, index, md) {
13859
+ var _a, _b, _c, _d;
13860
+ const open = children[index];
13861
+ const tag = (open === null || open === void 0 ? void 0 : open.type) === "html" ? (_a = OPENING_TAG.exec(open.value)) === null || _a === void 0 ? void 0 : _a[1] : void 0;
13862
+ const start = (_b = open === null || open === void 0 ? void 0 : open.position) === null || _b === void 0 ? void 0 : _b.start.offset;
13863
+ if (!tag || start === void 0)
13864
+ return void 0;
13865
+ const closeIndex = children.findIndex((child, i) => i > index && child.type === "html" && child.value.toLowerCase() === `</${tag}>`.toLowerCase());
13866
+ const end = (_d = (_c = children[closeIndex]) === null || _c === void 0 ? void 0 : _c.position) === null || _d === void 0 ? void 0 : _d.end.offset;
13867
+ if (closeIndex === -1 || end === void 0)
13868
+ return void 0;
13869
+ return { nodes: inlineHtml(md.slice(start, end)), skip: closeIndex - index };
13870
+ }
13871
+ function normalizeHtml(parent, md) {
13872
+ var _a, _b;
13873
+ const phrasing = PHRASING_PARENTS.has(parent.type);
13874
+ const items = [];
13875
+ for (let i = 0; i < parent.children.length; i++) {
13876
+ const child = parent.children[i];
13877
+ if (child.type !== "html") {
13878
+ if ("children" in child)
13879
+ normalizeHtml(child, md);
13880
+ items.push(child);
13881
+ } else if (!phrasing)
13882
+ items.push(...blockHtml(child.value));
13883
+ else {
13884
+ const paired = pairedInlineHtml(parent.children, i, md);
13885
+ items.push(...(_a = paired === null || paired === void 0 ? void 0 : paired.nodes) !== null && _a !== void 0 ? _a : inlineHtml(child.value));
13886
+ i += (_b = paired === null || paired === void 0 ? void 0 : paired.skip) !== null && _b !== void 0 ? _b : 0;
13887
+ }
13888
+ }
13889
+ parent.children = items.some(isMarker) ? groupContainers(items) : items;
13890
+ }
13891
+ function markdownToMdast(md) {
13892
+ const root = markdownRemark.parse(md);
13893
+ unwrapCurrencyMath2(root, md);
13894
+ normalizeHtml(root, md);
13895
+ return root;
13896
+ }
13897
+ function mdToMdast(md) {
13898
+ try {
13899
+ const root = mdxToMdast(md);
13900
+ promoteHtmlContainers(root);
13901
+ expressionsToText(root);
13902
+ return root;
13903
+ } catch (_a) {
13904
+ return markdownToMdast(md);
13905
+ }
13906
+ }
13907
+
13908
+ // ../editor/dist/converter/parse/md-to-pm.js
13909
+ function mdToPm(md, options) {
13910
+ return mdastToPm(mdToMdast(md), md, options);
13911
+ }
13912
+
13730
13913
  // ../editor/dist/converter/utils/frontmatter-filter.js
13731
13914
  import { decoratedPageSchema } from "@mintlify/validation";
13732
13915
  import yaml from "js-yaml";
@@ -13806,8 +13989,8 @@ function formatFrontmatterValue(key, value) {
13806
13989
 
13807
13990
  // ../editor/dist/converter/serialize/handlers/components.js
13808
13991
  import { titleMarkdownToText } from "@mintlify/common/title-markdown";
13809
- import remarkGfm2 from "remark-gfm";
13810
- import remarkMath2 from "remark-math";
13992
+ import remarkGfm3 from "remark-gfm";
13993
+ import remarkMath3 from "remark-math";
13811
13994
  import remarkMdx2 from "remark-mdx";
13812
13995
  import remarkStringify from "remark-stringify";
13813
13996
  import { unified } from "unified";
@@ -15317,7 +15500,7 @@ var stringifyHandlers = {
15317
15500
  };
15318
15501
  function stringifyMdxNode(children) {
15319
15502
  const wrapped = children.map((child) => (child === null || child === void 0 ? void 0 : child.type) === "mdxJsxTextElement" ? { type: "paragraph", children: [child] } : child);
15320
- const result = unified().use(remarkMdx2).use(remarkGfm2).use(remarkMath2).use(remarkStringify, { handlers: stringifyHandlers }).stringify({ type: "root", children: wrapped });
15503
+ const result = unified().use(remarkMdx2).use(remarkGfm3).use(remarkMath3).use(remarkStringify, { handlers: stringifyHandlers }).stringify({ type: "root", children: wrapped });
15321
15504
  return typeof result === "string" ? result : String(result);
15322
15505
  }
15323
15506
  function renderMermaidBlock(state, node) {
@@ -16966,13 +17149,13 @@ function pmJsonToMdast(_doc, _frontmatter) {
16966
17149
  }
16967
17150
 
16968
17151
  // ../editor/dist/converter/serialize/mdast-to-mdx.js
16969
- import remarkGfm3 from "remark-gfm";
16970
- import remarkMath3 from "remark-math";
17152
+ import remarkGfm4 from "remark-gfm";
17153
+ import remarkMath4 from "remark-math";
16971
17154
  import remarkMdx3 from "remark-mdx";
16972
17155
  import remarkStringify2 from "remark-stringify";
16973
17156
  import { unified as unified2 } from "unified";
16974
17157
  function mdastToMdx(mdast) {
16975
- const result = unified2().use(remarkMdx3).use(remarkGfm3).use(remarkMath3).use(remarkStringify2).stringify(mdast);
17158
+ const result = unified2().use(remarkMdx3).use(remarkGfm4).use(remarkMath4).use(remarkStringify2).stringify(mdast);
16976
17159
  return typeof result === "string" ? result : String(result);
16977
17160
  }
16978
17161
 
@@ -17501,6 +17684,7 @@ export {
17501
17684
  isDatabaseView,
17502
17685
  isJSXContent,
17503
17686
  isNonEmptyFrontmatterValue,
17687
+ mdToPm,
17504
17688
  mdastToMdx,
17505
17689
  mdastToPm,
17506
17690
  mdxToMdast,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/cli",
3
- "version": "4.0.1708",
3
+ "version": "4.0.1709",
4
4
  "description": "The Mintlify CLI",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -82,7 +82,7 @@
82
82
  "keytar": "7.9.0"
83
83
  },
84
84
  "devDependencies": {
85
- "@mintlify/editor": "0.0.557",
85
+ "@mintlify/editor": "0.0.558",
86
86
  "@mintlify/ts-config": "2.0.2",
87
87
  "@tsconfig/recommended": "1.0.2",
88
88
  "@types/detect-port": "1.3.2",
@@ -101,5 +101,5 @@
101
101
  "vitest": "2.1.9",
102
102
  "vitest-mock-process": "1.0.4"
103
103
  },
104
- "gitHead": "f93688d39cba2195bb011ef7001cfd32dcb2d868"
104
+ "gitHead": "f3c97950d24e7ac75a5bc1206301746d333e8fc0"
105
105
  }