@mintlify/common 1.0.1324 → 1.0.1325
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.
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { parse } from 'mdastic';
|
|
2
|
+
import { gfm } from 'mdastic/gfm';
|
|
3
|
+
import { math } from 'mdastic/math';
|
|
4
|
+
import { mdx } from 'mdastic/mdx';
|
|
5
|
+
const syntax = [
|
|
6
|
+
gfm({ singleTilde: true }),
|
|
7
|
+
mdx({ estree: true }),
|
|
8
|
+
math({ singleDollarTextMath: true }),
|
|
9
|
+
];
|
|
10
|
+
export function remarkMdasticParser() {
|
|
11
|
+
this.parser = (document) => {
|
|
12
|
+
const tree = parse(document, { syntax });
|
|
13
|
+
if (tree instanceof Error)
|
|
14
|
+
throw tree;
|
|
15
|
+
return tree;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -17,6 +17,7 @@ import { PackageIslandsError, parsePackageIslands, preprocessPageContent, } from
|
|
|
17
17
|
import { preprocessCustomHeadingIds } from '../preprocessCustomHeadingIds.js';
|
|
18
18
|
import { preprocessMdxFragmentCode } from '../preprocessMdxFragmentCode.js';
|
|
19
19
|
import { replaceVariables } from '../replaceVariables.js';
|
|
20
|
+
import { remarkMdasticParser } from './getMdx/fastCompile.js';
|
|
20
21
|
import { createSnippetTreeMap } from './getMdx/snippets.js';
|
|
21
22
|
import { getSerializeExtras } from './getSerializeExtras.js';
|
|
22
23
|
const getPackageIslandOptions = (packageBuild, pagePath, processedContent) => {
|
|
@@ -231,6 +232,16 @@ function compileMdx(_a) {
|
|
|
231
232
|
};
|
|
232
233
|
});
|
|
233
234
|
}
|
|
235
|
+
function serializeFast(args) {
|
|
236
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
237
|
+
var _a;
|
|
238
|
+
var _b;
|
|
239
|
+
const result = yield serialize(Object.assign(Object.assign({}, args), { mdxOptions: Object.assign(Object.assign({}, args.mdxOptions), { remarkPlugins: [remarkMdasticParser, ...((_b = (_a = args.mdxOptions) === null || _a === void 0 ? void 0 : _a.remarkPlugins) !== null && _b !== void 0 ? _b : [])] }) })).catch(() => undefined);
|
|
240
|
+
if (!result || 'error' in result)
|
|
241
|
+
return serialize(args);
|
|
242
|
+
return result;
|
|
243
|
+
});
|
|
244
|
+
}
|
|
234
245
|
function getCompiledMdxWithFallback(_a) {
|
|
235
246
|
return __awaiter(this, arguments, void 0, function* ({ source, failure, scope, mdxOptions, fallbackMdxOptions = mdxOptions, codeStyling, path, traceFn, customLanguages, }) {
|
|
236
247
|
const themeOrThemes = codeStylingToThemeOrThemes(codeStyling);
|
|
@@ -238,7 +249,7 @@ function getCompiledMdxWithFallback(_a) {
|
|
|
238
249
|
if (failure)
|
|
239
250
|
throw failure;
|
|
240
251
|
const result = yield traceFn('getCompiledMdxWithFallback.serialize', () => __awaiter(this, void 0, void 0, function* () {
|
|
241
|
-
return
|
|
252
|
+
return serializeFast({
|
|
242
253
|
source,
|
|
243
254
|
path,
|
|
244
255
|
scope,
|