@mintlify/common 1.0.1117 → 1.0.1118
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Root } from 'mdast';
|
|
2
2
|
/**
|
|
3
|
-
* Unwraps paragraph children inside JSX heading elements (h1–h6).
|
|
3
|
+
* Unwraps paragraph children inside JSX heading elements (h1–h6 and `Heading`).
|
|
4
4
|
*
|
|
5
5
|
* The custom-ID preprocessor emits headings like `<h2 id="x">\nText\n</h2>`,
|
|
6
6
|
* and MDX parses the text on its own line as a paragraph block. This plugin
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { visit } from 'unist-util-visit';
|
|
2
2
|
import { ALL_HEADING_NAMES } from '../../preprocessCustomHeadingIds.js';
|
|
3
|
+
const UNWRAPPED_HEADING_NAMES = new Set([...ALL_HEADING_NAMES, 'Heading']);
|
|
3
4
|
/**
|
|
4
|
-
* Unwraps paragraph children inside JSX heading elements (h1–h6).
|
|
5
|
+
* Unwraps paragraph children inside JSX heading elements (h1–h6 and `Heading`).
|
|
5
6
|
*
|
|
6
7
|
* The custom-ID preprocessor emits headings like `<h2 id="x">\nText\n</h2>`,
|
|
7
8
|
* and MDX parses the text on its own line as a paragraph block. This plugin
|
|
@@ -10,7 +11,7 @@ import { ALL_HEADING_NAMES } from '../../preprocessCustomHeadingIds.js';
|
|
|
10
11
|
export const remarkUnwrapJsxHeadings = () => (tree) => {
|
|
11
12
|
visit(tree, 'mdxJsxFlowElement', (node) => {
|
|
12
13
|
var _a;
|
|
13
|
-
if (!
|
|
14
|
+
if (!UNWRAPPED_HEADING_NAMES.has((_a = node.name) !== null && _a !== void 0 ? _a : ''))
|
|
14
15
|
return;
|
|
15
16
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
17
|
node.children = node.children.flatMap((child) => child.type === 'paragraph' && 'children' in child ? child.children : [child]);
|