@mintlify/msft-sdk 1.1.46 → 1.1.48
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/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/index.js +3 -2
- package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/index.js.map +1 -1
- package/dist/components/Api/Markdown.js +36 -40
- package/dist/components/Api/Markdown.js.map +1 -1
- package/dist/components/content-components/all-components.js +25 -23
- package/dist/components/content-components/all-components.js.map +1 -1
- package/dist/components/content-components/callouts.js +12 -5
- package/dist/components/content-components/callouts.js.map +1 -1
- package/dist/components/content-components/heading.js +7 -7
- package/dist/components/content-components/heading.js.map +1 -1
- package/dist/components/content-components/latex.js +30 -0
- package/dist/components/content-components/latex.js.map +1 -0
- package/dist/components/content-components/table/index.js +6 -6
- package/dist/components/content-components/table/index.js.map +1 -1
- package/dist/components/mdx-renderer.js +1 -9
- package/dist/components/mdx-renderer.js.map +1 -1
- package/dist/components/nav-tree/index.js +80 -67
- package/dist/components/nav-tree/index.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +59 -55
- package/dist/index.js.map +1 -1
- package/dist/parser/convert-html-to-mdx.js +17 -16
- package/dist/parser/convert-html-to-mdx.js.map +1 -1
- package/dist/parser/serialize-mdx.js +17 -15
- package/dist/parser/serialize-mdx.js.map +1 -1
- package/dist/plugins/sanitize/rehype-latex.js +31 -0
- package/dist/plugins/sanitize/rehype-latex.js.map +1 -0
- package/dist/plugins/sanitize/rehype-pre-to-mdx-fence.js +13 -13
- package/dist/plugins/sanitize/rehype-pre-to-mdx-fence.js.map +1 -1
- package/dist/plugins/sanitize/rehype-remark.js +4 -3
- package/dist/plugins/sanitize/rehype-remark.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -5,14 +5,14 @@ import { PlainTextPage as n } from "./components/plain-text-page.js";
|
|
|
5
5
|
import { createDefaultComponents as l, defaultComponents as i } from "./components/content-components/default-components.js";
|
|
6
6
|
import { ComponentsProvider as s, useComponents as C } from "./context/components-context.js";
|
|
7
7
|
import { NavTree as P } from "./components/nav-tree/index.js";
|
|
8
|
-
import { useApiReference as
|
|
8
|
+
import { useApiReference as y } from "./components/Api/ApiReferenceProvider.js";
|
|
9
9
|
import { ApiReferenceContext as T, ApiReferenceContext2 as b, ApiReferenceProvider as v, ApiReferenceProvider2 as A, DeploymentMetadataContext as H, DeploymentMetadataProvider as h, DocsConfigContext as D, DocsConfigProvider as R, PageContext as M, PageProvider as k } from "./contexts/ConfigContext.js";
|
|
10
10
|
import { TableOfContents as w } from "./components/toc/index.js";
|
|
11
|
-
import { PivotAwareTOC as
|
|
12
|
-
import { PageContextMenu as
|
|
11
|
+
import { PivotAwareTOC as L } from "./components/toc/pivot-aware-toc.js";
|
|
12
|
+
import { PageContextMenu as N } from "./components/page-context-menu.js";
|
|
13
13
|
import { copyMarkdownToClipboard as O, getPageMarkdown as Z, useMarkdownCopy as z } from "./hooks/useMarkdownCopy.js";
|
|
14
|
-
import { generateLlmsFullTxt as
|
|
15
|
-
import { getNodeText as
|
|
14
|
+
import { generateLlmsFullTxt as X, generateLlmsTxt as q } from "./utils/generate-llms-txt.js";
|
|
15
|
+
import { getNodeText as J } from "./utils/get-node-text.js";
|
|
16
16
|
import { capitalize as j } from "./utils/string.js";
|
|
17
17
|
import { cn as Q } from "./utils/cn.js";
|
|
18
18
|
import { getClassNames as V, getTextContent as Y, isElement as _ } from "./utils/rehype.js";
|
|
@@ -25,19 +25,19 @@ import { OperationPage as ie } from "./api-playground-2/OperationPage.js";
|
|
|
25
25
|
import { SchemaPage as se } from "./api-playground-2/SchemaPage.js";
|
|
26
26
|
import { ApiExamples as ge } from "./api-playground-2/ApiExamples.js";
|
|
27
27
|
import { ApiFields as ue } from "./api-playground-2/ApiFields.js";
|
|
28
|
-
import { Playground as
|
|
28
|
+
import { Playground as ce } from "./api-playground-2/Playground.js";
|
|
29
29
|
import { EndpointHeader as be } from "./api-playground-2/EndpointHeader.js";
|
|
30
30
|
import { ApiPlaygroundContext as Ae } from "./api-playground-2/contexts/ApiPlaygroundContext.js";
|
|
31
31
|
import { usePlaygroundInputsStore as he, useSelectedSecurityOption as De } from "./api-playground-2/hooks/usePlaygroundInputsStore.js";
|
|
32
32
|
import { useSendPlaygroundRequest as Me } from "./api-playground-2/hooks/useSendPlaygroundRequest.js";
|
|
33
33
|
import { useInitializeInputs as Se } from "./api-playground-2/hooks/useInitializeInputs.js";
|
|
34
34
|
import { useCopyPathWithInputs as Fe } from "./api-playground-2/hooks/useCopyPathWithInputs.js";
|
|
35
|
-
import { addApiReferenceDataFromMdxAndDocsConfig as
|
|
36
|
-
import { processSecurityOptions as
|
|
35
|
+
import { addApiReferenceDataFromMdxAndDocsConfig as Ie } from "./api-playground-2/schemaGraph/addApiReferenceDataFromMdxAndDocsConfig.js";
|
|
36
|
+
import { processSecurityOptions as Ee } from "./api-playground-2/schemaGraph/processSecurityOptions.js";
|
|
37
37
|
import { getApiReferenceDataFromGraph as Ze } from "./api-playground-2/schemaGraph/getApiReferenceDataFromGraph.js";
|
|
38
38
|
import { ApiPlayground as Be } from "./api-playground/ApiPlayground/index.js";
|
|
39
|
-
import { ApiPlaygroundContext as
|
|
40
|
-
import { default as
|
|
39
|
+
import { ApiPlaygroundContext as qe } from "./api-playground/ApiPlayground/ApiPlaygroundContext.js";
|
|
40
|
+
import { default as Je } from "./api-playground/EndpointFields/index.js";
|
|
41
41
|
import { CodeBlock as je } from "./components/content-components/code-block.js";
|
|
42
42
|
import { Heading as Qe } from "./components/content-components/heading.js";
|
|
43
43
|
import { Link as Ve } from "./components/content-components/link.js";
|
|
@@ -50,28 +50,30 @@ import { ParamName as no } from "./components/content-components/param-name.js";
|
|
|
50
50
|
import { Tabs as lo } from "./components/content-components/tabs/tabs.js";
|
|
51
51
|
import { Tab as so } from "./components/content-components/tabs/tab.js";
|
|
52
52
|
import { Details as go, Summary as Po } from "./components/content-components/details/details.js";
|
|
53
|
-
import { Table as
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
53
|
+
import { Table as yo, TableBody as co, TableCaption as To, TableCell as bo, TableFooter as vo, TableHead as Ao, TableHeader as Ho, TableRow as ho } from "./components/content-components/table/index.js";
|
|
54
|
+
import { LaTeX as Ro } from "./components/content-components/latex.js";
|
|
55
|
+
import { allComponents as ko } from "./components/content-components/all-components.js";
|
|
56
|
+
import { Home as wo } from "./components/content-components/home.js";
|
|
57
|
+
import { MobileNavTree as Lo } from "./components/nav-tree/mobile-nav.js";
|
|
58
|
+
import { rehypeCodeblocks as No } from "./plugins/rehype/rehype-code-blocks.js";
|
|
59
|
+
import { remarkHeadingIds as Oo } from "./plugins/remark/remark-heading-ids.js";
|
|
60
|
+
import { sanitizePreTags as zo } from "./plugins/sanitize/rehype-pre-to-mdx-fence.js";
|
|
61
|
+
import { rehypeCallouts as Xo } from "./plugins/sanitize/rehype-callouts.js";
|
|
62
|
+
import { rehypeParamName as Go } from "./plugins/sanitize/rehype-param-name.js";
|
|
63
|
+
import { rehypeTabs as Wo } from "./plugins/sanitize/rehype-tabs.js";
|
|
64
|
+
import { rehypeDetails as Ko } from "./plugins/sanitize/rehype-details.js";
|
|
65
|
+
import { rehypeHeadingIds as Uo } from "./plugins/sanitize/rehype-heading-ids.js";
|
|
66
|
+
import { rehypeZonePivots as Yo } from "./plugins/sanitize/rehype-zone-pivots.js";
|
|
67
|
+
import { mdxJsxFlowElementHandler as $o, rehypeRemark as er } from "./plugins/sanitize/rehype-remark.js";
|
|
68
|
+
import { rehypeLatex as rr } from "./plugins/sanitize/rehype-latex.js";
|
|
69
|
+
import { tableCellHandler as pr, tableHandler as mr, tableRowHandler as ar } from "./plugins/sanitize/rehype-table-align.js";
|
|
68
70
|
export {
|
|
69
71
|
fe as Api,
|
|
70
72
|
ge as ApiExamples,
|
|
71
73
|
ue as ApiFields,
|
|
72
74
|
Be as ApiPlayground,
|
|
73
75
|
Ae as ApiPlaygroundContext,
|
|
74
|
-
|
|
76
|
+
qe as ApiPlaygroundContextLegacy,
|
|
75
77
|
T as ApiReferenceContext,
|
|
76
78
|
b as ApiReferenceContext2,
|
|
77
79
|
v as ApiReferenceProvider,
|
|
@@ -86,27 +88,28 @@ export {
|
|
|
86
88
|
R as DocsConfigProvider,
|
|
87
89
|
p as DocsLayout,
|
|
88
90
|
r as DocsPage,
|
|
89
|
-
|
|
91
|
+
Je as EndpointFields,
|
|
90
92
|
be as EndpointHeader,
|
|
91
93
|
Qe as Heading,
|
|
92
|
-
|
|
94
|
+
wo as Home,
|
|
95
|
+
Ro as LaTeX,
|
|
93
96
|
Ve as Link,
|
|
94
97
|
a as MDXRenderer,
|
|
95
|
-
|
|
98
|
+
Lo as MobileNavTree,
|
|
96
99
|
P as NavTree,
|
|
97
100
|
ie as OperationPage,
|
|
98
101
|
M as PageContext,
|
|
99
|
-
|
|
102
|
+
N as PageContextMenu,
|
|
100
103
|
k as PageProvider,
|
|
101
104
|
no as ParamName,
|
|
102
|
-
|
|
105
|
+
L as PivotAwareTOC,
|
|
103
106
|
n as PlainTextPage,
|
|
104
|
-
|
|
107
|
+
ce as Playground,
|
|
105
108
|
se as SchemaPage,
|
|
106
109
|
Po as Summary,
|
|
107
110
|
so as Tab,
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
yo as Table,
|
|
112
|
+
co as TableBody,
|
|
110
113
|
To as TableCaption,
|
|
111
114
|
bo as TableCell,
|
|
112
115
|
vo as TableFooter,
|
|
@@ -119,8 +122,8 @@ export {
|
|
|
119
122
|
po as ZonePivotProvider,
|
|
120
123
|
ao as ZonePivotSelector,
|
|
121
124
|
ro as ZoneTarget,
|
|
122
|
-
|
|
123
|
-
|
|
125
|
+
Ie as addApiReferenceDataFromMdxAndDocsConfig,
|
|
126
|
+
ko as allComponents,
|
|
124
127
|
j as capitalize,
|
|
125
128
|
Q as cn,
|
|
126
129
|
ee as convertHtmlToMdx,
|
|
@@ -128,33 +131,34 @@ export {
|
|
|
128
131
|
l as createDefaultComponents,
|
|
129
132
|
i as defaultComponents,
|
|
130
133
|
pe as extractHeadings,
|
|
131
|
-
|
|
132
|
-
|
|
134
|
+
X as generateLlmsFullTxt,
|
|
135
|
+
q as generateLlmsTxt,
|
|
133
136
|
Ze as getApiReferenceDataFromGraph,
|
|
134
137
|
V as getClassNames,
|
|
135
|
-
|
|
138
|
+
J as getNodeText,
|
|
136
139
|
Z as getPageMarkdown,
|
|
137
140
|
Y as getTextContent,
|
|
138
141
|
_ as isElement,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
$o as mdxJsxFlowElementHandler,
|
|
143
|
+
Ee as processSecurityOptions,
|
|
144
|
+
Xo as rehypeCallouts,
|
|
145
|
+
No as rehypeCodeblocks,
|
|
146
|
+
Ko as rehypeDetails,
|
|
147
|
+
Uo as rehypeHeadingIds,
|
|
148
|
+
rr as rehypeLatex,
|
|
149
|
+
Go as rehypeParamName,
|
|
150
|
+
er as rehypeRemark,
|
|
147
151
|
ae as rehypeRemoveHtmlComments,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
152
|
+
Wo as rehypeTabs,
|
|
153
|
+
Yo as rehypeZonePivots,
|
|
154
|
+
Oo as remarkHeadingIds,
|
|
151
155
|
xe as removeHtmlComments,
|
|
152
|
-
|
|
156
|
+
zo as sanitizePreTags,
|
|
153
157
|
re as serializeMdx,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
pr as tableCellHandler,
|
|
159
|
+
mr as tableHandler,
|
|
160
|
+
ar as tableRowHandler,
|
|
161
|
+
y as useApiReference,
|
|
158
162
|
C as useComponents,
|
|
159
163
|
Fe as useCopyPathWithInputs,
|
|
160
164
|
Se as useInitializeInputs,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import p from "
|
|
1
|
+
import s from "rehype-parse";
|
|
2
|
+
import p from "remark-gfm";
|
|
3
3
|
import i from "remark-mdx";
|
|
4
|
-
import a from "remark-
|
|
5
|
-
import f from "
|
|
4
|
+
import a from "remark-stringify";
|
|
5
|
+
import { unified as f } from "unified";
|
|
6
6
|
import { rehypeRemoveHtmlComments as u } from "../plugins/sanitize/remove-html-comments.js";
|
|
7
|
-
import {
|
|
7
|
+
import { rehypeLatex as n } from "../plugins/sanitize/rehype-latex.js";
|
|
8
|
+
import { sanitizePreTags as y } from "../plugins/sanitize/rehype-pre-to-mdx-fence.js";
|
|
8
9
|
import { rehypeCallouts as c } from "../plugins/sanitize/rehype-callouts.js";
|
|
9
|
-
import { rehypeParamName as
|
|
10
|
-
import { rehypeTabs as
|
|
10
|
+
import { rehypeParamName as h } from "../plugins/sanitize/rehype-param-name.js";
|
|
11
|
+
import { rehypeTabs as x } from "../plugins/sanitize/rehype-tabs.js";
|
|
11
12
|
import { rehypeDetails as d } from "../plugins/sanitize/rehype-details.js";
|
|
12
|
-
import { rehypeHeadingIds as
|
|
13
|
-
import { rehypeUnwrapImageLinks as
|
|
14
|
-
import { rehypeImageUrls as
|
|
15
|
-
import { rehypeZonePivots as
|
|
16
|
-
import { rehypeRemark as
|
|
17
|
-
async function
|
|
13
|
+
import { rehypeHeadingIds as l } from "../plugins/sanitize/rehype-heading-ids.js";
|
|
14
|
+
import { rehypeUnwrapImageLinks as g } from "../plugins/sanitize/rehype-unwrap-image-links.js";
|
|
15
|
+
import { rehypeImageUrls as k } from "../plugins/sanitize/rehype-image-urls.js";
|
|
16
|
+
import { rehypeZonePivots as v } from "../plugins/sanitize/rehype-zone-pivots.js";
|
|
17
|
+
import { rehypeRemark as P } from "../plugins/sanitize/rehype-remark.js";
|
|
18
|
+
async function j(m, r = {}) {
|
|
18
19
|
const e = r.mdxExtracts || {}, o = {
|
|
19
20
|
...r,
|
|
20
21
|
mdxExtracts: e
|
|
21
|
-
},
|
|
22
|
+
}, t = await f().use(s).use(u).use(n).use(y).use(c).use(h).use(x).use(d).use(l).use(g).use(k, o).use(v, o).use(P).use(p).use(i).use(a).process(m);
|
|
22
23
|
return {
|
|
23
|
-
mdx: String(
|
|
24
|
+
mdx: String(t),
|
|
24
25
|
mdxExtracts: e
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
28
|
export {
|
|
28
|
-
|
|
29
|
+
j as convertHtmlToMdx
|
|
29
30
|
};
|
|
30
31
|
//# sourceMappingURL=convert-html-to-mdx.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-html-to-mdx.js","sources":["../../src/parser/convert-html-to-mdx.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"convert-html-to-mdx.js","sources":["../../src/parser/convert-html-to-mdx.ts"],"sourcesContent":["import rehypeParse from 'rehype-parse';\nimport remarkGfm from 'remark-gfm';\nimport remarkMath from 'remark-math';\nimport remarkMdx from 'remark-mdx';\nimport remarkStringify from 'remark-stringify';\nimport { unified } from 'unified';\n\nimport {\n sanitizePreTags,\n rehypeCallouts,\n rehypeParamName,\n rehypeTabs,\n rehypeDetails,\n rehypeHeadingIds,\n rehypeZonePivots,\n rehypeRemark,\n rehypeImageUrls,\n rehypeUnwrapImageLinks,\n rehypeLatex,\n} from '../plugins';\nimport { rehypeRemoveHtmlComments } from '../plugins/sanitize/remove-html-comments';\nimport type { ConvertOptions, MdxExtracts } from '../types';\n\nexport async function convertHtmlToMdx(\n html: string,\n options: ConvertOptions = {}\n): Promise<{ mdx: string; mdxExtracts: MdxExtracts }> {\n const mdxExtracts: MdxExtracts = options.mdxExtracts || {};\n\n const convertOptions: ConvertOptions = {\n ...options,\n mdxExtracts,\n };\n\n const processor = unified()\n .use(rehypeParse)\n .use(rehypeRemoveHtmlComments)\n .use(rehypeLatex)\n .use(sanitizePreTags)\n .use(rehypeCallouts)\n .use(rehypeParamName)\n .use(rehypeTabs)\n .use(rehypeDetails)\n .use(rehypeHeadingIds)\n .use(rehypeUnwrapImageLinks)\n .use(rehypeImageUrls, convertOptions)\n .use(rehypeZonePivots, convertOptions)\n .use(rehypeRemark)\n .use(remarkGfm)\n .use(remarkMdx)\n .use(remarkStringify);\n\n const result = await processor.process(html);\n\n return {\n mdx: String(result),\n mdxExtracts,\n };\n}\n"],"names":["convertHtmlToMdx","html","options","mdxExtracts","convertOptions","result","unified","rehypeParse","rehypeRemoveHtmlComments","rehypeLatex","sanitizePreTags","rehypeCallouts","rehypeParamName","rehypeTabs","rehypeDetails","rehypeHeadingIds","rehypeUnwrapImageLinks","rehypeImageUrls","rehypeZonePivots","rehypeRemark","remarkGfm","remarkMdx","remarkStringify"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,eAAsBA,EACpBC,GACAC,IAA0B,IAC0B;AACpD,QAAMC,IAA2BD,EAAQ,eAAe,CAAA,GAElDE,IAAiC;AAAA,IACrC,GAAGF;AAAA,IACH,aAAAC;AAAA,EAAA,GAqBIE,IAAS,MAlBGC,IACf,IAAIC,CAAW,EACf,IAAIC,CAAwB,EAC5B,IAAIC,CAAW,EACf,IAAIC,CAAe,EACnB,IAAIC,CAAc,EAClB,IAAIC,CAAe,EACnB,IAAIC,CAAU,EACd,IAAIC,CAAa,EACjB,IAAIC,CAAgB,EACpB,IAAIC,CAAsB,EAC1B,IAAIC,GAAiBb,CAAc,EACnC,IAAIc,GAAkBd,CAAc,EACpC,IAAIe,CAAY,EAChB,IAAIC,CAAS,EACb,IAAIC,CAAS,EACb,IAAIC,CAAe,EAES,QAAQrB,CAAI;AAE3C,SAAO;AAAA,IACL,KAAK,OAAOI,CAAM;AAAA,IAClB,aAAAF;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
import * as a from "react/jsx-runtime";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { compile as
|
|
2
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
3
|
+
import { compile as s, run as c } from "@mdx-js/mdx";
|
|
4
|
+
import f from "rehype-katex";
|
|
4
5
|
import d from "remark-gfm";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
6
|
+
import l from "remark-math";
|
|
7
|
+
import { extractHeadings as u } from "../plugins/extract-headings.js";
|
|
8
|
+
import { rehypeCodeblocks as g } from "../plugins/rehype/rehype-code-blocks.js";
|
|
9
|
+
import { remarkHeadingIds as h } from "../plugins/remark/remark-heading-ids.js";
|
|
10
|
+
import { defaultComponents as x } from "../components/content-components/default-components.js";
|
|
11
|
+
async function z(t) {
|
|
10
12
|
var r;
|
|
11
13
|
try {
|
|
12
|
-
const o = await
|
|
14
|
+
const o = await s(t, {
|
|
13
15
|
outputFormat: "function-body",
|
|
14
|
-
remarkPlugins: [d,
|
|
15
|
-
rehypePlugins: [
|
|
16
|
-
}),
|
|
16
|
+
remarkPlugins: [d, l, h, u],
|
|
17
|
+
rehypePlugins: [f, g]
|
|
18
|
+
}), e = String(o), n = ((r = o.data) == null ? void 0 : r.headings) || [], { default: m } = await c(e, {
|
|
17
19
|
...a
|
|
18
20
|
});
|
|
19
21
|
return {
|
|
20
|
-
Content: (i) => /* @__PURE__ */
|
|
22
|
+
Content: (i) => /* @__PURE__ */ p(
|
|
21
23
|
m,
|
|
22
24
|
{
|
|
23
25
|
...i,
|
|
24
26
|
components: {
|
|
25
|
-
...
|
|
27
|
+
...x
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
),
|
|
29
|
-
headings:
|
|
31
|
+
headings: n
|
|
30
32
|
};
|
|
31
33
|
} catch (o) {
|
|
32
34
|
throw console.error(
|
|
@@ -36,6 +38,6 @@ async function H(t) {
|
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
export {
|
|
39
|
-
|
|
41
|
+
z as serializeMdx
|
|
40
42
|
};
|
|
41
43
|
//# sourceMappingURL=serialize-mdx.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize-mdx.js","sources":["../../src/parser/serialize-mdx.tsx"],"sourcesContent":["import { compile } from
|
|
1
|
+
{"version":3,"file":"serialize-mdx.js","sources":["../../src/parser/serialize-mdx.tsx"],"sourcesContent":["import { compile } from '@mdx-js/mdx';\nimport { run } from '@mdx-js/mdx';\nimport React from 'react';\nimport * as runtime from 'react/jsx-runtime';\nimport rehypeKatex from 'rehype-katex';\nimport remarkGfm from 'remark-gfm';\nimport remarkMath from 'remark-math';\n\nimport { defaultComponents } from '../components';\nimport { rehypeCodeblocks, remarkHeadingIds } from '../plugins';\nimport { extractHeadings } from '../plugins/extract-headings';\nimport type { TocItem } from '../types';\n\nexport interface SerializeMdxResult {\n Content: React.ComponentType;\n headings: TocItem[];\n}\n\nexport async function serializeMdx(mdxString: string): Promise<SerializeMdxResult> {\n try {\n const compiled = await compile(mdxString, {\n outputFormat: 'function-body',\n remarkPlugins: [remarkGfm, remarkMath, remarkHeadingIds, extractHeadings],\n rehypePlugins: [rehypeKatex, rehypeCodeblocks],\n });\n\n const compiledMdx = String(compiled);\n\n const headings = (compiled.data?.headings as TocItem[]) || [];\n\n const { default: Content } = await run(compiledMdx, {\n ...runtime,\n });\n\n const Component = (props: Record<string, unknown>) => (\n <Content\n {...props}\n components={{\n ...defaultComponents,\n }}\n />\n );\n\n return {\n Content: Component,\n headings,\n };\n } catch (error) {\n console.error(\n 'MDX compilation failed:',\n error instanceof Error ? error.message : String(error)\n );\n throw error;\n }\n}\n"],"names":["serializeMdx","mdxString","compiled","compile","remarkGfm","remarkMath","remarkHeadingIds","extractHeadings","rehypeKatex","rehypeCodeblocks","compiledMdx","headings","_a","Content","run","runtime","props","jsx","defaultComponents","error"],"mappings":";;;;;;;;;;AAkBA,eAAsBA,EAAaC,GAAgD;;AACjF,MAAI;AACF,UAAMC,IAAW,MAAMC,EAAQF,GAAW;AAAA,MACxC,cAAc;AAAA,MACd,eAAe,CAACG,GAAWC,GAAYC,GAAkBC,CAAe;AAAA,MACxE,eAAe,CAACC,GAAaC,CAAgB;AAAA,IAAA,CAC9C,GAEKC,IAAc,OAAOR,CAAQ,GAE7BS,MAAYC,IAAAV,EAAS,SAAT,gBAAAU,EAAe,aAA0B,CAAA,GAErD,EAAE,SAASC,EAAA,IAAY,MAAMC,EAAIJ,GAAa;AAAA,MAClD,GAAGK;AAAA,IAAA,CACJ;AAWD,WAAO;AAAA,MACL,SAVgB,CAACC,MACjB,gBAAAC;AAAA,QAACJ;AAAA,QAAA;AAAA,UACE,GAAGG;AAAA,UACJ,YAAY;AAAA,YACV,GAAGE;AAAA,UAAA;AAAA,QACL;AAAA,MAAA;AAAA,MAMF,UAAAP;AAAA,IAAA;AAAA,EAEJ,SAASQ,GAAO;AACd,kBAAQ;AAAA,MACN;AAAA,MACAA,aAAiB,QAAQA,EAAM,UAAU,OAAOA,CAAK;AAAA,IAAA,GAEjDA;AAAA,EACR;AACF;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { visit as a } from "unist-util-visit";
|
|
2
|
+
import { isElement as l, getTextContent as s } from "../../utils/rehype.js";
|
|
3
|
+
function c(r) {
|
|
4
|
+
return r.replace(/\\\$/g, "$").replace(/\\\{/g, "{").replace(/\\\}/g, "}");
|
|
5
|
+
}
|
|
6
|
+
function i(r) {
|
|
7
|
+
return r.includes("$") || r.includes("$$");
|
|
8
|
+
}
|
|
9
|
+
function p(r) {
|
|
10
|
+
let e = r.replace(/^\$\$\s*/, "").replace(/\s*\$\$$/, "");
|
|
11
|
+
return e = e.replace(new RegExp("(?<!\\\\)#", "g"), "\\#").replace(new RegExp("(?<!\\\\)\\$", "g"), "\\$").replace(new RegExp("(?<!\\\\)%", "g"), "\\%").replace(new RegExp("(?<!\\\\)&", "g"), "\\&"), e;
|
|
12
|
+
}
|
|
13
|
+
const $ = () => (r) => {
|
|
14
|
+
a(r, (e) => {
|
|
15
|
+
if (e.type === "text") {
|
|
16
|
+
const t = e;
|
|
17
|
+
typeof t.value == "string" && (t.value.includes("\\$") || t.value.includes("\\{")) && (t.value = c(t.value));
|
|
18
|
+
}
|
|
19
|
+
if (l(e) && e.tagName === "p") {
|
|
20
|
+
const t = s(e).trim();
|
|
21
|
+
i(t) && t.match(/^\$\$[\s\S]*\$\$/) && (console.log(JSON.stringify(e, null, 2)), e.tagName = "LaTeX", e.properties = {
|
|
22
|
+
latex: p(t),
|
|
23
|
+
...e.properties
|
|
24
|
+
}, delete e.properties.className);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
$ as rehypeLatex
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=rehype-latex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rehype-latex.js","sources":["../../../src/plugins/sanitize/rehype-latex.ts"],"sourcesContent":["import type { Node, Text } from 'hast';\nimport type { Plugin } from 'unified';\nimport { visit } from 'unist-util-visit';\n\nimport { isElement, getTextContent } from '../../utils/rehype';\n\nfunction unescapeLatexDelimiters(text: string): string {\n return text.replace(/\\\\\\$/g, '$').replace(/\\\\\\{/g, '{').replace(/\\\\\\}/g, '}');\n}\n\nfunction hasLatexContent(text: string): boolean {\n return text.includes('$') || text.includes('$$');\n}\n\nfunction processLatexContent(text: string): string {\n // Remove $$ delimiters\n let processed = text.replace(/^\\$\\$\\s*/, '').replace(/\\s*\\$\\$$/, '');\n\n // Escape special characters for KaTeX (unless already escaped)\n // These are characters that have special meaning in LaTeX but might appear as literals in text\n processed = processed\n .replace(/(?<!\\\\)#/g, '\\\\#') // # in text like \"# training tokens\"\n .replace(/(?<!\\\\)\\$/g, '\\\\$') // $ in text like \"$1422.00\"\n .replace(/(?<!\\\\)%/g, '\\\\%') // % in text like \"50%\"\n .replace(/(?<!\\\\)&/g, '\\\\&'); // & in text like \"A & B\"\n\n return processed;\n}\n\nexport const rehypeLatex: Plugin<[], Node> = () => {\n return (tree) => {\n visit(tree, (node) => {\n if (node.type === 'text') {\n const textNode = node as Text;\n if (\n typeof textNode.value === 'string' &&\n (textNode.value.includes('\\\\$') || textNode.value.includes('\\\\{'))\n ) {\n textNode.value = unescapeLatexDelimiters(textNode.value);\n }\n }\n\n if (isElement(node) && node.tagName === 'p') {\n const textContent = getTextContent(node).trim();\n\n if (hasLatexContent(textContent) && textContent.match(/^\\$\\$[\\s\\S]*\\$\\$/)) {\n console.log(JSON.stringify(node, null, 2));\n\n node.tagName = 'LaTeX';\n node.properties = {\n latex: processLatexContent(textContent),\n ...node.properties,\n };\n delete node.properties.className;\n }\n }\n });\n };\n};\n"],"names":["unescapeLatexDelimiters","text","hasLatexContent","processLatexContent","processed","rehypeLatex","tree","visit","node","textNode","isElement","textContent","getTextContent"],"mappings":";;AAMA,SAASA,EAAwBC,GAAsB;AACrD,SAAOA,EAAK,QAAQ,SAAS,GAAG,EAAE,QAAQ,SAAS,GAAG,EAAE,QAAQ,SAAS,GAAG;AAC9E;AAEA,SAASC,EAAgBD,GAAuB;AAC9C,SAAOA,EAAK,SAAS,GAAG,KAAKA,EAAK,SAAS,IAAI;AACjD;AAEA,SAASE,EAAoBF,GAAsB;AAEjD,MAAIG,IAAYH,EAAK,QAAQ,YAAY,EAAE,EAAE,QAAQ,YAAY,EAAE;AAInE,SAAAG,IAAYA,EACT,QAAQ,WAAA,cAAA,GAAA,GAAa,KAAK,EAC1B,QAAQ,WAAA,gBAAA,GAAA,GAAc,KAAK,EAC3B,QAAQ,WAAA,cAAA,GAAA,GAAa,KAAK,EAC1B,QAAQ,WAAA,cAAA,MAAa,KAAK,GAEtBA;AACT;AAEO,MAAMC,IAAgC,MACpC,CAACC,MAAS;AACf,EAAAC,EAAMD,GAAM,CAACE,MAAS;AACpB,QAAIA,EAAK,SAAS,QAAQ;AACxB,YAAMC,IAAWD;AACjB,MACE,OAAOC,EAAS,SAAU,aACzBA,EAAS,MAAM,SAAS,KAAK,KAAKA,EAAS,MAAM,SAAS,KAAK,OAEhEA,EAAS,QAAQT,EAAwBS,EAAS,KAAK;AAAA,IAE3D;AAEA,QAAIC,EAAUF,CAAI,KAAKA,EAAK,YAAY,KAAK;AAC3C,YAAMG,IAAcC,EAAeJ,CAAI,EAAE,KAAA;AAEzC,MAAIN,EAAgBS,CAAW,KAAKA,EAAY,MAAM,kBAAkB,MACtE,QAAQ,IAAI,KAAK,UAAUH,GAAM,MAAM,CAAC,CAAC,GAEzCA,EAAK,UAAU,SACfA,EAAK,aAAa;AAAA,QAChB,OAAOL,EAAoBQ,CAAW;AAAA,QACtC,GAAGH,EAAK;AAAA,MAAA,GAEV,OAAOA,EAAK,WAAW;AAAA,IAE3B;AAAA,EACF,CAAC;AACH;"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { visit as
|
|
1
|
+
import { visit as l } from "unist-util-visit";
|
|
2
2
|
import { isElement as t } from "../../utils/rehype.js";
|
|
3
|
-
const c = () => (
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
if (!t(
|
|
3
|
+
const c = () => (i) => {
|
|
4
|
+
console.log("sanitizePreTags", JSON.stringify(i, null, 2)), l(i, (s) => {
|
|
5
|
+
var n;
|
|
6
|
+
if (!t(s) || !t(s, "tagName", "pre"))
|
|
7
7
|
return;
|
|
8
|
-
const e =
|
|
8
|
+
const e = s.children[0];
|
|
9
9
|
if (!e || !t(e, "tagName", "code"))
|
|
10
10
|
return;
|
|
11
|
-
const
|
|
12
|
-
if (Array.isArray(
|
|
13
|
-
for (const r of
|
|
11
|
+
const o = (n = e.properties) == null ? void 0 : n.className;
|
|
12
|
+
if (Array.isArray(o)) {
|
|
13
|
+
for (const r of o)
|
|
14
14
|
if (typeof r == "string" && r.startsWith("lang-")) {
|
|
15
|
-
const
|
|
16
|
-
e.properties || (e.properties = {}), e.properties.className = [`language-${
|
|
15
|
+
const a = r.replace(/^lang-/, "");
|
|
16
|
+
e.properties || (e.properties = {}), e.properties.className = [`language-${a}`];
|
|
17
17
|
break;
|
|
18
18
|
} else if (typeof r == "string" && r.startsWith("language-")) {
|
|
19
|
-
const
|
|
20
|
-
e.properties || (e.properties = {}), e.properties.className = [`language-${
|
|
19
|
+
const a = r.replace(/^language-/, "");
|
|
20
|
+
e.properties || (e.properties = {}), e.properties.className = [`language-${a}`];
|
|
21
21
|
break;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rehype-pre-to-mdx-fence.js","sources":["../../../src/plugins/sanitize/rehype-pre-to-mdx-fence.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"rehype-pre-to-mdx-fence.js","sources":["../../../src/plugins/sanitize/rehype-pre-to-mdx-fence.ts"],"sourcesContent":["import { Node, Element } from 'hast';\nimport { Plugin } from 'unified';\nimport { visit } from 'unist-util-visit';\n\nimport { isElement } from '../../utils/rehype';\n\nexport const sanitizePreTags: Plugin<[], Node> = () => {\n return (tree) => {\n console.log('sanitizePreTags', JSON.stringify(tree, null, 2));\n\n visit(tree, (node) => {\n if (!isElement(node) || !isElement(node, 'tagName', 'pre')) {\n return;\n }\n\n const code = node.children[0] as Element | undefined;\n if (!code || !isElement(code, 'tagName', 'code')) {\n return;\n }\n\n const className = code.properties?.className;\n if (Array.isArray(className)) {\n for (const cls of className) {\n if (typeof cls === 'string' && cls.startsWith('lang-')) {\n const lang = cls.replace(/^lang-/, '');\n if (!code.properties) code.properties = {};\n code.properties.className = [`language-${lang}`];\n break;\n } else if (typeof cls === 'string' && cls.startsWith('language-')) {\n const lang = cls.replace(/^language-/, '');\n if (!code.properties) code.properties = {};\n code.properties.className = [`language-${lang}`];\n break;\n }\n }\n }\n });\n };\n};\n"],"names":["sanitizePreTags","tree","visit","node","isElement","code","className","_a","cls","lang"],"mappings":";;AAMO,MAAMA,IAAoC,MACxC,CAACC,MAAS;AACf,UAAQ,IAAI,mBAAmB,KAAK,UAAUA,GAAM,MAAM,CAAC,CAAC,GAE5DC,EAAMD,GAAM,CAACE,MAAS;;AACpB,QAAI,CAACC,EAAUD,CAAI,KAAK,CAACC,EAAUD,GAAM,WAAW,KAAK;AACvD;AAGF,UAAME,IAAOF,EAAK,SAAS,CAAC;AAC5B,QAAI,CAACE,KAAQ,CAACD,EAAUC,GAAM,WAAW,MAAM;AAC7C;AAGF,UAAMC,KAAYC,IAAAF,EAAK,eAAL,gBAAAE,EAAiB;AACnC,QAAI,MAAM,QAAQD,CAAS;AACzB,iBAAWE,KAAOF;AAChB,YAAI,OAAOE,KAAQ,YAAYA,EAAI,WAAW,OAAO,GAAG;AACtD,gBAAMC,IAAOD,EAAI,QAAQ,UAAU,EAAE;AACrC,UAAKH,EAAK,eAAYA,EAAK,aAAa,CAAA,IACxCA,EAAK,WAAW,YAAY,CAAC,YAAYI,CAAI,EAAE;AAC/C;AAAA,QACF,WAAW,OAAOD,KAAQ,YAAYA,EAAI,WAAW,WAAW,GAAG;AACjE,gBAAMC,IAAOD,EAAI,QAAQ,cAAc,EAAE;AACzC,UAAKH,EAAK,eAAYA,EAAK,aAAa,CAAA,IACxCA,EAAK,WAAW,YAAY,CAAC,YAAYI,CAAI,EAAE;AAC/C;AAAA,QACF;AAAA;AAAA,EAGN,CAAC;AACH;"}
|
|
@@ -18,7 +18,8 @@ const d = [
|
|
|
18
18
|
"Tabs",
|
|
19
19
|
"Tab",
|
|
20
20
|
"Details",
|
|
21
|
-
"Summary"
|
|
21
|
+
"Summary",
|
|
22
|
+
"LaTeX"
|
|
22
23
|
], f = [...d, ...u];
|
|
23
24
|
function o(e, t) {
|
|
24
25
|
const a = t.children ? e.all(t) : [];
|
|
@@ -33,7 +34,7 @@ function o(e, t) {
|
|
|
33
34
|
children: a
|
|
34
35
|
};
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
+
function b() {
|
|
37
38
|
const e = { ...m };
|
|
38
39
|
for (const t of f)
|
|
39
40
|
e[t] = o;
|
|
@@ -45,6 +46,6 @@ function x() {
|
|
|
45
46
|
}
|
|
46
47
|
export {
|
|
47
48
|
o as mdxJsxFlowElementHandler,
|
|
48
|
-
|
|
49
|
+
b as rehypeRemark
|
|
49
50
|
};
|
|
50
51
|
//# sourceMappingURL=rehype-remark.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rehype-remark.js","sources":["../../../src/plugins/sanitize/rehype-remark.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"rehype-remark.js","sources":["../../../src/plugins/sanitize/rehype-remark.ts"],"sourcesContent":["import type { Root as HastRoot, Element } from 'hast';\nimport { toMdast, defaultHandlers } from 'hast-util-to-mdast';\nimport type { State, Handle } from 'hast-util-to-mdast';\nimport type { Root as MdastRoot } from 'mdast';\nimport type { BlockContent, DefinitionContent } from 'mdast';\nimport { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';\n\nimport { tableHandler, tableRowHandler, tableCellHandler } from './rehype-table-align';\n\nconst HTML_TAGS = [\n 'iframe',\n 'video',\n 'audio',\n 'svg',\n 'figure',\n 'figcaption',\n 'canvas',\n 'form',\n 'input',\n];\nconst COMPONENT_NAMES = [\n 'Callout',\n 'ZonePivot',\n 'ZoneTarget',\n 'ParamName',\n 'Tabs',\n 'Tab',\n 'Details',\n 'Summary',\n 'LaTeX',\n];\nconst ALLOWED_COMPONENTS = [...HTML_TAGS, ...COMPONENT_NAMES];\n\nexport function mdxJsxFlowElementHandler(state: State, node: Element): MdxJsxFlowElement {\n const children = node.children\n ? (state.all(node) as Array<BlockContent | DefinitionContent>)\n : [];\n\n return {\n type: 'mdxJsxFlowElement',\n name: node.tagName,\n attributes: Object.entries(node.properties ?? {}).map(([key, value]) => ({\n type: 'mdxJsxAttribute',\n name: key,\n value: Array.isArray(value) ? value.join(' ') : (value as string),\n })),\n children,\n };\n}\n\nexport function rehypeRemark() {\n const handlers: Record<string, Handle> = { ...defaultHandlers };\n\n for (const name of ALLOWED_COMPONENTS) {\n handlers[name] = mdxJsxFlowElementHandler;\n }\n handlers.mdxJsxFlowElement = mdxJsxFlowElementHandler;\n\n handlers.table = tableHandler;\n handlers.tr = tableRowHandler;\n handlers.th = tableCellHandler;\n handlers.td = tableCellHandler;\n\n return function (tree: HastRoot) {\n const newTree = toMdast(tree, {\n handlers,\n }) as MdastRoot;\n return newTree;\n };\n}\n"],"names":["HTML_TAGS","COMPONENT_NAMES","ALLOWED_COMPONENTS","mdxJsxFlowElementHandler","state","node","children","key","value","rehypeRemark","handlers","defaultHandlers","name","tableHandler","tableRowHandler","tableCellHandler","tree","toMdast"],"mappings":";;AASA,MAAMA,IAAY;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GACMC,IAAkB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GACMC,IAAqB,CAAC,GAAGF,GAAW,GAAGC,CAAe;AAErD,SAASE,EAAyBC,GAAcC,GAAkC;AACvF,QAAMC,IAAWD,EAAK,WACjBD,EAAM,IAAIC,CAAI,IACf,CAAA;AAEJ,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAMA,EAAK;AAAA,IACX,YAAY,OAAO,QAAQA,EAAK,cAAc,EAAE,EAAE,IAAI,CAAC,CAACE,GAAKC,CAAK,OAAO;AAAA,MACvE,MAAM;AAAA,MACN,MAAMD;AAAA,MACN,OAAO,MAAM,QAAQC,CAAK,IAAIA,EAAM,KAAK,GAAG,IAAKA;AAAA,IAAA,EACjD;AAAA,IACF,UAAAF;AAAA,EAAA;AAEJ;AAEO,SAASG,IAAe;AAC7B,QAAMC,IAAmC,EAAE,GAAGC,EAAA;AAE9C,aAAWC,KAAQV;AACjB,IAAAQ,EAASE,CAAI,IAAIT;AAEnB,SAAAO,EAAS,oBAAoBP,GAE7BO,EAAS,QAAQG,GACjBH,EAAS,KAAKI,GACdJ,EAAS,KAAKK,GACdL,EAAS,KAAKK,GAEP,SAAUC,GAAgB;AAI/B,WAHgBC,EAAQD,GAAM;AAAA,MAC5B,UAAAN;AAAA,IAAA,CACD;AAAA,EAEH;AACF;"}
|