@mintlify/common 1.0.944 → 1.0.946
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.
|
@@ -3,13 +3,17 @@ export const remarkSplitCodeGroup = () => (tree) => {
|
|
|
3
3
|
const codeGroupCompoenents = ['CodeGroup', 'RequestExample', 'ResponseExample'];
|
|
4
4
|
const groupsToProcess = [];
|
|
5
5
|
visit(tree, 'mdxJsxFlowElement', (node, index, parent) => {
|
|
6
|
-
if (node.name &&
|
|
6
|
+
if (node.name &&
|
|
7
|
+
codeGroupCompoenents.includes(node.name) &&
|
|
8
|
+
typeof index === 'number' &&
|
|
9
|
+
parent) {
|
|
7
10
|
groupsToProcess.push({ node, index, parent });
|
|
8
11
|
}
|
|
9
12
|
});
|
|
10
13
|
// Split the code group into multiple CodeBlock nodes
|
|
11
14
|
// basically remove the CodeGroup component and replace it with the codeblocks
|
|
12
|
-
|
|
15
|
+
// process in reverse document order so splices don't shift saved sibling indices
|
|
16
|
+
for (const { node, index, parent } of groupsToProcess.reverse()) {
|
|
13
17
|
const numberOfCodeBlocks = node.children.length;
|
|
14
18
|
if (numberOfCodeBlocks <= 1)
|
|
15
19
|
continue;
|
|
@@ -2,11 +2,13 @@ import { visit } from 'unist-util-visit';
|
|
|
2
2
|
export const remarkSplitTabs = () => (tree) => {
|
|
3
3
|
const tabsToProcess = [];
|
|
4
4
|
visit(tree, 'mdxJsxFlowElement', (node, index, parent) => {
|
|
5
|
-
if (node.name === 'Tabs' && index && parent) {
|
|
5
|
+
if (node.name === 'Tabs' && typeof index === 'number' && parent) {
|
|
6
6
|
tabsToProcess.push({ node, index, parent });
|
|
7
7
|
}
|
|
8
8
|
});
|
|
9
|
-
|
|
9
|
+
// process in reverse document order so splices don't shift the saved
|
|
10
|
+
// indices of earlier siblings or clone-before-split nested Tabs
|
|
11
|
+
for (const { node, index, parent } of tabsToProcess.reverse()) {
|
|
10
12
|
const numberOfTabs = node.children.length;
|
|
11
13
|
if (numberOfTabs <= 1)
|
|
12
14
|
continue;
|