@mintlify/common 1.0.1330 → 1.0.1331
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/mdx/remark-core.js
CHANGED
|
@@ -6,6 +6,7 @@ import remarkMdx from 'remark-mdx';
|
|
|
6
6
|
import remarkStringify from 'remark-stringify';
|
|
7
7
|
import { preprocessCustomHeadingIds } from './preprocessCustomHeadingIds.js';
|
|
8
8
|
import { preprocessMdxFragmentCode } from './preprocessMdxFragmentCode.js';
|
|
9
|
+
import { remarkMdasticParse } from './remarkMdasticParse.js';
|
|
9
10
|
import { getJsxEsmTree } from './snippets/getJsxEsmTree.js';
|
|
10
11
|
import { isJsxOrTsx } from './snippets/isJsxOrTsx.js';
|
|
11
12
|
export const coreRemarkMdxPlugins = [
|
|
@@ -13,6 +14,7 @@ export const coreRemarkMdxPlugins = [
|
|
|
13
14
|
remarkGfm,
|
|
14
15
|
[remarkFrontmatter, ['yaml', 'toml']],
|
|
15
16
|
remarkMath,
|
|
17
|
+
remarkMdasticParse,
|
|
16
18
|
];
|
|
17
19
|
export const coreRemark = remark().use(coreRemarkMdxPlugins).freeze();
|
|
18
20
|
const agentRemarkMdxPlugins = [
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { parse } from 'mdastic';
|
|
2
|
+
import { frontmatter } from 'mdastic/frontmatter';
|
|
3
|
+
import { gfm } from 'mdastic/gfm';
|
|
4
|
+
import { math } from 'mdastic/math';
|
|
5
|
+
import { mdx } from 'mdastic/mdx';
|
|
6
|
+
import { visit } from 'unist-util-visit';
|
|
7
|
+
const syntax = [
|
|
8
|
+
gfm({ singleTilde: true }),
|
|
9
|
+
mdx({ estree: true }),
|
|
10
|
+
math({ singleDollarTextMath: true }),
|
|
11
|
+
frontmatter(['yaml', 'toml']),
|
|
12
|
+
];
|
|
13
|
+
export function remarkMdasticParse() {
|
|
14
|
+
var _a;
|
|
15
|
+
var _b;
|
|
16
|
+
const fallback = this.parser;
|
|
17
|
+
const extensions = (_b = (_a = this.data('micromarkExtensions')) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
18
|
+
if (!fallback)
|
|
19
|
+
return;
|
|
20
|
+
this.parser = (document, file) => {
|
|
21
|
+
var _a;
|
|
22
|
+
var _b;
|
|
23
|
+
if (((_b = (_a = this.data('micromarkExtensions')) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === extensions) {
|
|
24
|
+
const tree = parse(document, { syntax });
|
|
25
|
+
if (!(tree instanceof Error)) {
|
|
26
|
+
const root = tree;
|
|
27
|
+
visit(root, ['mdxJsxFlowElement', 'mdxJsxTextElement'], (node) => {
|
|
28
|
+
if ('attributes' in node)
|
|
29
|
+
for (const attribute of node.attributes)
|
|
30
|
+
delete attribute.position;
|
|
31
|
+
});
|
|
32
|
+
return root;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return fallback(document, file);
|
|
36
|
+
};
|
|
37
|
+
}
|