@docusaurus/mdx-loader 2.4.1 → 3.0.0-alpha.0

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.
Files changed (85) hide show
  1. package/README.md +13 -0
  2. package/lib/format.d.ts +12 -0
  3. package/lib/format.d.ts.map +1 -0
  4. package/lib/format.js +35 -0
  5. package/lib/format.js.map +1 -0
  6. package/lib/frontMatter.d.ts +12 -0
  7. package/lib/frontMatter.d.ts.map +1 -0
  8. package/lib/frontMatter.js +25 -0
  9. package/lib/frontMatter.js.map +1 -0
  10. package/lib/index.d.ts +5 -7
  11. package/lib/index.d.ts.map +1 -1
  12. package/lib/index.js.map +1 -1
  13. package/lib/loader.d.ts +5 -14
  14. package/lib/loader.d.ts.map +1 -1
  15. package/lib/loader.js +38 -81
  16. package/lib/loader.js.map +1 -1
  17. package/lib/preprocessor.d.ts +18 -0
  18. package/lib/preprocessor.d.ts.map +1 -0
  19. package/lib/preprocessor.js +34 -0
  20. package/lib/preprocessor.js.map +1 -0
  21. package/lib/processor.d.ts +36 -0
  22. package/lib/processor.d.ts.map +1 -0
  23. package/lib/processor.js +158 -0
  24. package/lib/processor.js.map +1 -0
  25. package/lib/remark/admonitions/index.d.ts +4 -9
  26. package/lib/remark/admonitions/index.d.ts.map +1 -1
  27. package/lib/remark/admonitions/index.js +70 -128
  28. package/lib/remark/admonitions/index.js.map +1 -1
  29. package/lib/remark/details/index.d.ts +9 -0
  30. package/lib/remark/details/index.d.ts.map +1 -0
  31. package/lib/remark/details/index.js +23 -0
  32. package/lib/remark/details/index.js.map +1 -0
  33. package/lib/remark/head/index.d.ts +9 -0
  34. package/lib/remark/head/index.d.ts.map +1 -0
  35. package/lib/remark/head/index.js +23 -0
  36. package/lib/remark/head/index.js.map +1 -0
  37. package/lib/remark/headings/index.d.ts.map +1 -1
  38. package/lib/remark/headings/index.js +3 -3
  39. package/lib/remark/headings/index.js.map +1 -1
  40. package/lib/remark/{unwrapMdxCodeBlocks/index.d.ts → mdx1Compat/codeCompatPlugin.d.ts} +2 -2
  41. package/lib/remark/mdx1Compat/codeCompatPlugin.d.ts.map +1 -0
  42. package/lib/remark/mdx1Compat/codeCompatPlugin.js +34 -0
  43. package/lib/remark/mdx1Compat/codeCompatPlugin.js.map +1 -0
  44. package/lib/remark/mermaid/index.d.ts.map +1 -1
  45. package/lib/remark/mermaid/index.js +1 -0
  46. package/lib/remark/mermaid/index.js.map +1 -1
  47. package/lib/remark/toc/index.d.ts +8 -2
  48. package/lib/remark/toc/index.d.ts.map +1 -1
  49. package/lib/remark/toc/index.js +53 -23
  50. package/lib/remark/toc/index.js.map +1 -1
  51. package/lib/remark/transformImage/index.d.ts +2 -1
  52. package/lib/remark/transformImage/index.d.ts.map +1 -1
  53. package/lib/remark/transformImage/index.js +42 -15
  54. package/lib/remark/transformImage/index.js.map +1 -1
  55. package/lib/remark/transformLinks/index.d.ts +2 -1
  56. package/lib/remark/transformLinks/index.d.ts.map +1 -1
  57. package/lib/remark/transformLinks/index.js +30 -11
  58. package/lib/remark/transformLinks/index.js.map +1 -1
  59. package/lib/remark/utils/index.d.ts +4 -2
  60. package/lib/remark/utils/index.d.ts.map +1 -1
  61. package/lib/remark/utils/index.js +68 -11
  62. package/lib/remark/utils/index.js.map +1 -1
  63. package/package.json +26 -18
  64. package/src/format.ts +40 -0
  65. package/src/frontMatter.ts +31 -0
  66. package/src/index.ts +6 -6
  67. package/src/loader.ts +62 -107
  68. package/src/preprocessor.ts +47 -0
  69. package/src/processor.ts +241 -0
  70. package/src/remark/admonitions/README.md +1 -1
  71. package/src/remark/admonitions/index.ts +92 -171
  72. package/src/remark/details/index.ts +25 -0
  73. package/src/remark/head/index.ts +25 -0
  74. package/src/remark/headings/index.ts +5 -3
  75. package/src/remark/mdx1Compat/codeCompatPlugin.ts +36 -0
  76. package/src/remark/mermaid/index.ts +2 -0
  77. package/src/remark/toc/index.ts +80 -26
  78. package/src/remark/transformImage/index.ts +54 -19
  79. package/src/remark/transformLinks/index.ts +44 -17
  80. package/src/remark/utils/index.ts +77 -9
  81. package/lib/remark/unwrapMdxCodeBlocks/index.d.ts.map +0 -1
  82. package/lib/remark/unwrapMdxCodeBlocks/index.js +0 -29
  83. package/lib/remark/unwrapMdxCodeBlocks/index.js.map +0 -1
  84. package/src/deps.d.ts +0 -31
  85. package/src/remark/unwrapMdxCodeBlocks/index.ts +0 -33
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/mdx-loader",
3
- "version": "2.4.1",
3
+ "version": "3.0.0-alpha.0",
4
4
  "description": "Docusaurus Loader for MDX",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -18,44 +18,52 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@babel/parser": "^7.18.8",
22
- "@babel/traverse": "^7.18.8",
23
- "@docusaurus/logger": "2.4.1",
24
- "@docusaurus/utils": "2.4.1",
25
- "@mdx-js/mdx": "^1.6.22",
21
+ "@babel/parser": "^7.21.2",
22
+ "@babel/traverse": "^7.21.2",
23
+ "@docusaurus/logger": "3.0.0-alpha.0",
24
+ "@docusaurus/utils": "3.0.0-alpha.0",
25
+ "@docusaurus/utils-validation": "3.0.0-alpha.0",
26
+ "@mdx-js/mdx": "^2.1.5",
26
27
  "escape-html": "^1.0.3",
28
+ "estree-util-value-to-estree": "^2.1.0",
27
29
  "file-loader": "^6.2.0",
28
- "fs-extra": "^10.1.0",
29
- "image-size": "^1.0.1",
30
- "mdast-util-to-string": "^2.0.0",
30
+ "fs-extra": "^11.1.0",
31
+ "hastscript": "^7.1.0",
32
+ "image-size": "^1.0.2",
33
+ "mdast-util-mdx": "^2.0.0",
34
+ "mdast-util-to-string": "^3.0.0",
35
+ "rehype-raw": "^6.1.1",
36
+ "remark-comment": "^1.0.0",
37
+ "remark-directive": "^2.0.1",
31
38
  "remark-emoji": "^2.2.0",
39
+ "remark-gfm": "^3.0.1",
32
40
  "stringify-object": "^3.3.0",
33
- "tslib": "^2.4.0",
34
- "unified": "^9.2.2",
41
+ "tslib": "^2.5.0",
42
+ "unified": "^10.1.2",
35
43
  "unist-util-visit": "^2.0.3",
36
44
  "url-loader": "^4.1.1",
37
- "webpack": "^5.73.0"
45
+ "webpack": "^5.76.0"
38
46
  },
39
47
  "devDependencies": {
40
- "@docusaurus/types": "2.4.1",
48
+ "@docusaurus/types": "3.0.0-alpha.0",
41
49
  "@types/escape-html": "^1.0.2",
42
50
  "@types/mdast": "^3.0.10",
43
51
  "@types/stringify-object": "^3.3.1",
44
52
  "@types/unist": "^2.0.6",
45
53
  "rehype-stringify": "^8.0.0",
46
- "remark": "^12.0.1",
47
- "remark-mdx": "^1.6.21",
54
+ "remark": "^14.0.2",
55
+ "remark-mdx": "^2.1.5",
48
56
  "remark-rehype": "^8.1.0",
49
57
  "to-vfile": "^6.1.0",
50
58
  "unist-builder": "^2.0.3",
51
59
  "unist-util-remove-position": "^3.0.0"
52
60
  },
53
61
  "peerDependencies": {
54
- "react": "^16.8.4 || ^17.0.0",
55
- "react-dom": "^16.8.4 || ^17.0.0"
62
+ "react": "^18.0.0",
63
+ "react-dom": "^18.0.0"
56
64
  },
57
65
  "engines": {
58
66
  "node": ">=16.14"
59
67
  },
60
- "gitHead": "60e657d8ae5a4a9ed1c2d777f9defd882cc12681"
68
+ "gitHead": "7327f7ff880ed97ad7855744e59c9c55d467a950"
61
69
  }
package/src/format.ts ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import path from 'path';
9
+ import type {MDXFrontMatter} from './frontMatter';
10
+
11
+ // Copied from https://mdxjs.com/packages/mdx/#optionsmdextensions
12
+ // Although we are likely to only use .md / .mdx anyway...
13
+ const mdFormatExtensions = [
14
+ '.md',
15
+ '.markdown',
16
+ '.mdown',
17
+ '.mkdn',
18
+ '.mkd',
19
+ '.mdwn',
20
+ '.mkdown',
21
+ '.ron',
22
+ ];
23
+
24
+ function isMDFormat(filepath: string) {
25
+ return mdFormatExtensions.includes(path.extname(filepath));
26
+ }
27
+
28
+ export function getFormat({
29
+ filePath,
30
+ frontMatterFormat,
31
+ }: {
32
+ filePath: string;
33
+ frontMatterFormat: MDXFrontMatter['format'];
34
+ }): 'md' | 'mdx' {
35
+ if (frontMatterFormat !== 'detect') {
36
+ return frontMatterFormat;
37
+ }
38
+ // Bias toward mdx if unknown extension
39
+ return isMDFormat(filePath) ? 'md' : 'mdx';
40
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import {
9
+ JoiFrontMatter as Joi,
10
+ validateFrontMatter,
11
+ } from '@docusaurus/utils-validation';
12
+
13
+ export type MDXFrontMatter = {
14
+ format: 'md' | 'mdx' | 'detect';
15
+ };
16
+
17
+ export const DefaultMDXFrontMatter: MDXFrontMatter = {
18
+ format: 'detect',
19
+ };
20
+
21
+ const MDXFrontMatterSchema = Joi.object<MDXFrontMatter>({
22
+ format: Joi.string()
23
+ .equal('md', 'mdx', 'detect')
24
+ .default(DefaultMDXFrontMatter.format),
25
+ }).default(DefaultMDXFrontMatter);
26
+
27
+ export function validateMDXFrontMatter(frontMatter: unknown): MDXFrontMatter {
28
+ return validateFrontMatter(frontMatter, MDXFrontMatterSchema, {
29
+ allowUnknown: false,
30
+ });
31
+ }
package/src/index.ts CHANGED
@@ -7,13 +7,11 @@
7
7
 
8
8
  import {mdxLoader} from './loader';
9
9
 
10
+ import type {TOCItem as TOCItemImported} from './remark/toc';
11
+
10
12
  export default mdxLoader;
11
13
 
12
- export type TOCItem = {
13
- readonly value: string;
14
- readonly id: string;
15
- readonly level: number;
16
- };
14
+ export type TOCItem = TOCItemImported;
17
15
 
18
16
  export type LoadedMDXContent<FrontMatter, Metadata, Assets = undefined> = {
19
17
  /** As verbatim declared in the MDX document. */
@@ -32,4 +30,6 @@ export type LoadedMDXContent<FrontMatter, Metadata, Assets = undefined> = {
32
30
  readonly assets: Assets;
33
31
  (): JSX.Element;
34
32
  };
35
- export type {Options, MDXPlugin, MDXOptions} from './loader';
33
+
34
+ export type {Options, MDXPlugin} from './loader';
35
+ export type {MDXOptions} from './processor';
package/src/loader.ts CHANGED
@@ -13,54 +13,25 @@ import {
13
13
  escapePath,
14
14
  getFileLoaderUtils,
15
15
  } from '@docusaurus/utils';
16
- import {createCompiler} from '@mdx-js/mdx';
17
- import emoji from 'remark-emoji';
18
16
  import stringifyObject from 'stringify-object';
17
+ import preprocessor from './preprocessor';
18
+ import {validateMDXFrontMatter} from './frontMatter';
19
+ import {createProcessorCached} from './processor';
20
+ import type {MDXOptions} from './processor';
19
21
 
20
- import headings from './remark/headings';
21
- import toc from './remark/toc';
22
- import unwrapMdxCodeBlocks from './remark/unwrapMdxCodeBlocks';
23
- import transformImage from './remark/transformImage';
24
- import transformLinks from './remark/transformLinks';
25
- import mermaid from './remark/mermaid';
26
-
27
- import transformAdmonitions from './remark/admonitions';
28
22
  import type {MarkdownConfig} from '@docusaurus/types';
29
23
  import type {LoaderContext} from 'webpack';
30
- import type {Processor, Plugin} from 'unified';
31
- import type {AdmonitionOptions} from './remark/admonitions';
24
+
25
+ // TODO as of April 2023, no way to import/re-export this ESM type easily :/
26
+ // This might change soon, likely after TS 5.2
27
+ // See https://github.com/microsoft/TypeScript/issues/49721#issuecomment-1517839391
28
+ type Pluggable = any; // TODO fix this asap
32
29
 
33
30
  const {
34
31
  loaders: {inlineMarkdownImageFileLoader},
35
32
  } = getFileLoaderUtils();
36
33
 
37
- const pragma = `
38
- /* @jsxRuntime classic */
39
- /* @jsx mdx */
40
- /* @jsxFrag React.Fragment */
41
- `;
42
-
43
- const DEFAULT_OPTIONS: MDXOptions = {
44
- admonitions: true,
45
- rehypePlugins: [],
46
- remarkPlugins: [unwrapMdxCodeBlocks, emoji, headings, toc],
47
- beforeDefaultRemarkPlugins: [],
48
- beforeDefaultRehypePlugins: [],
49
- };
50
-
51
- const compilerCache = new Map<string | Options, [Processor, Options]>();
52
-
53
- export type MDXPlugin =
54
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
- [Plugin<any[]>, any] | Plugin<any[]>;
56
-
57
- export type MDXOptions = {
58
- admonitions: boolean | AdmonitionOptions;
59
- remarkPlugins: MDXPlugin[];
60
- rehypePlugins: MDXPlugin[];
61
- beforeDefaultRemarkPlugins: MDXPlugin[];
62
- beforeDefaultRehypePlugins: MDXPlugin[];
63
- };
34
+ export type MDXPlugin = Pluggable;
64
35
 
65
36
  export type Options = Partial<MDXOptions> & {
66
37
  markdownConfig: MarkdownConfig;
@@ -139,17 +110,15 @@ function createAssetsExportCode(assets: unknown) {
139
110
  return `{\n${codeLines.join('\n')}\n}`;
140
111
  }
141
112
 
142
- function getAdmonitionsPlugins(
143
- admonitionsOption: MDXOptions['admonitions'],
144
- ): MDXPlugin[] {
145
- if (admonitionsOption) {
146
- const plugin: MDXPlugin =
147
- admonitionsOption === true
148
- ? transformAdmonitions
149
- : [transformAdmonitions, admonitionsOption];
150
- return [plugin];
113
+ // TODO temporary, remove this after v3.1?
114
+ // Some plugin authors use our mdx-loader, despite it not being public API
115
+ // see https://github.com/facebook/docusaurus/issues/8298
116
+ function ensureMarkdownConfig(reqOptions: Options) {
117
+ if (!reqOptions.markdownConfig) {
118
+ throw new Error(
119
+ 'Docusaurus v3+ requires MDX loader options.markdownConfig - plugin authors using the MDX loader should make sure to provide that option',
120
+ );
151
121
  }
152
- return [];
153
122
  }
154
123
 
155
124
  export async function mdxLoader(
@@ -158,77 +127,62 @@ export async function mdxLoader(
158
127
  ): Promise<void> {
159
128
  const callback = this.async();
160
129
  const filePath = this.resourcePath;
161
- const reqOptions = this.getOptions();
130
+ const reqOptions: Options = this.getOptions();
131
+ const {query} = this;
132
+ ensureMarkdownConfig(reqOptions);
162
133
 
163
134
  const {frontMatter, content: contentWithTitle} = parseFrontMatter(fileString);
164
-
165
- const {content, contentTitle} = parseMarkdownContentTitle(contentWithTitle, {
166
- removeContentTitle: reqOptions.removeContentTitle,
135
+ const mdxFrontMatter = validateMDXFrontMatter(frontMatter.mdx);
136
+
137
+ const {content: contentUnprocessed, contentTitle} = parseMarkdownContentTitle(
138
+ contentWithTitle,
139
+ {
140
+ removeContentTitle: reqOptions.removeContentTitle,
141
+ },
142
+ );
143
+
144
+ const content = preprocessor({
145
+ fileContent: contentUnprocessed,
146
+ filePath,
147
+ admonitions: reqOptions.admonitions,
148
+ markdownConfig: reqOptions.markdownConfig,
167
149
  });
168
150
 
169
151
  const hasFrontMatter = Object.keys(frontMatter).length > 0;
170
152
 
171
- if (!compilerCache.has(this.query)) {
172
- const remarkPlugins: MDXPlugin[] = [
173
- ...(reqOptions.beforeDefaultRemarkPlugins ?? []),
174
- ...getAdmonitionsPlugins(reqOptions.admonitions ?? false),
175
- ...DEFAULT_OPTIONS.remarkPlugins,
176
- ...(reqOptions.markdownConfig.mermaid ? [mermaid] : []),
177
- [
178
- transformImage,
179
- {
180
- staticDirs: reqOptions.staticDirs,
181
- siteDir: reqOptions.siteDir,
182
- },
183
- ],
184
- [
185
- transformLinks,
186
- {
187
- staticDirs: reqOptions.staticDirs,
188
- siteDir: reqOptions.siteDir,
189
- },
190
- ],
191
- ...(reqOptions.remarkPlugins ?? []),
192
- ];
193
-
194
- const rehypePlugins: MDXPlugin[] = [
195
- ...(reqOptions.beforeDefaultRehypePlugins ?? []),
196
- ...DEFAULT_OPTIONS.rehypePlugins,
197
- ...(reqOptions.rehypePlugins ?? []),
198
- ];
199
-
200
- const options: Options = {
201
- ...reqOptions,
202
- remarkPlugins,
203
- rehypePlugins,
204
- };
205
- compilerCache.set(this.query, [createCompiler(options), options]);
206
- }
207
-
208
- const [compiler, options] = compilerCache.get(this.query)!;
153
+ const processor = await createProcessorCached({
154
+ filePath,
155
+ reqOptions,
156
+ query,
157
+ mdxFrontMatter,
158
+ });
209
159
 
210
160
  let result: string;
211
161
  try {
212
- result = await compiler
213
- .process({
214
- contents: content,
215
- path: this.resourcePath,
216
- })
217
- .then((res) => res.toString());
218
- } catch (err) {
219
- return callback(err as Error);
162
+ result = await processor.process({content, filePath});
163
+ } catch (errorUnknown) {
164
+ const error = errorUnknown as Error;
165
+ return callback(
166
+ new Error(
167
+ `MDX compilation failed for file ${logger.path(filePath)}\nCause: ${
168
+ error.message
169
+ }\nDetails:\n${JSON.stringify(error, null, 2)}`,
170
+ // TODO error cause doesn't seem to be used by Webpack stats.errors :s
171
+ {cause: error},
172
+ ),
173
+ );
220
174
  }
221
175
 
222
176
  // MDX partials are MDX files starting with _ or in a folder starting with _
223
177
  // Partial are not expected to have associated metadata files or front matter
224
- const isMDXPartial = options.isMDXPartial?.(filePath);
178
+ const isMDXPartial = reqOptions.isMDXPartial?.(filePath);
225
179
  if (isMDXPartial && hasFrontMatter) {
226
180
  const errorMessage = `Docusaurus MDX partial files should not contain front matter.
227
181
  Those partial files use the _ prefix as a convention by default, but this is configurable.
228
182
  File at ${filePath} contains front matter that will be ignored:
229
183
  ${JSON.stringify(frontMatter, null, 2)}`;
230
184
 
231
- if (!options.isMDXPartialFrontMatterWarningDisabled) {
185
+ if (!reqOptions.isMDXPartialFrontMatterWarningDisabled) {
232
186
  const shouldError = process.env.NODE_ENV === 'test' || process.env.CI;
233
187
  if (shouldError) {
234
188
  return callback(new Error(errorMessage));
@@ -240,8 +194,11 @@ ${JSON.stringify(frontMatter, null, 2)}`;
240
194
  function getMetadataPath(): string | undefined {
241
195
  if (!isMDXPartial) {
242
196
  // Read metadata for this MDX and export it.
243
- if (options.metadataPath && typeof options.metadataPath === 'function') {
244
- return options.metadataPath(filePath);
197
+ if (
198
+ reqOptions.metadataPath &&
199
+ typeof reqOptions.metadataPath === 'function'
200
+ ) {
201
+ return reqOptions.metadataPath(filePath);
245
202
  }
246
203
  }
247
204
  return undefined;
@@ -265,6 +222,8 @@ ${JSON.stringify(frontMatter, null, 2)}`;
265
222
  ? reqOptions.createAssets({frontMatter, metadata})
266
223
  : undefined;
267
224
 
225
+ // TODO use remark plugins to insert extra exports instead of string concat?
226
+ // cf how the toc is exported
268
227
  const exportsCode = `
269
228
  export const frontMatter = ${stringifyObject(frontMatter)};
270
229
  export const contentTitle = ${stringifyObject(contentTitle)};
@@ -273,10 +232,6 @@ ${assets ? `export const assets = ${createAssetsExportCode(assets)};` : ''}
273
232
  `;
274
233
 
275
234
  const code = `
276
- ${pragma}
277
- import React from 'react';
278
- import { mdx } from '@mdx-js/react';
279
-
280
235
  ${exportsCode}
281
236
  ${result}
282
237
  `;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import {
9
+ escapeMarkdownHeadingIds,
10
+ unwrapMdxCodeBlocks,
11
+ admonitionTitleToDirectiveLabel,
12
+ } from '@docusaurus/utils';
13
+ import {normalizeAdmonitionOptions} from './remark/admonitions';
14
+ import type {Options} from './loader';
15
+
16
+ /**
17
+ * Preprocess the string before passing it to MDX
18
+ * This is not particularly recommended but makes it easier to upgrade to MDX 2
19
+ */
20
+ export default function preprocessContent({
21
+ fileContent: initialFileContent,
22
+ filePath,
23
+ markdownConfig,
24
+ admonitions,
25
+ }: {
26
+ fileContent: string;
27
+ filePath: string;
28
+ markdownConfig: Options['markdownConfig'];
29
+ admonitions: Options['admonitions'] | undefined;
30
+ }): string {
31
+ let fileContent = initialFileContent;
32
+ if (markdownConfig.preprocessor) {
33
+ fileContent = markdownConfig.preprocessor({
34
+ fileContent,
35
+ filePath,
36
+ });
37
+ }
38
+ fileContent = unwrapMdxCodeBlocks(fileContent);
39
+ if (markdownConfig.mdx1Compat.headingIds) {
40
+ fileContent = escapeMarkdownHeadingIds(fileContent);
41
+ }
42
+ if (markdownConfig.mdx1Compat.admonitions && admonitions) {
43
+ const {keywords} = normalizeAdmonitionOptions(admonitions);
44
+ fileContent = admonitionTitleToDirectiveLabel(fileContent, keywords);
45
+ }
46
+ return fileContent;
47
+ }