@mui/internal-docs-infra 0.2.3-canary.8 → 0.3.1-canary.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.
- package/README.md +3 -2
- package/esm/CodeHighlighter/CodeHighlighter.js +16 -16
- package/esm/CodeHighlighter/CodeHighlighterClient.js +33 -33
- package/esm/CodeHighlighter/errors.js +3 -3
- package/esm/CodeHighlighter/types.d.ts +1 -1
- package/esm/CodeProvider/CodeContext.d.ts +4 -4
- package/esm/CodeProvider/CodeProvider.js +7 -7
- package/esm/cli/index.d.ts +1 -0
- package/esm/cli/index.js +6 -0
- package/esm/cli/runValidate.d.ts +8 -0
- package/esm/cli/runValidate.js +297 -0
- package/esm/createSitemap/createSitemap.d.ts +23 -0
- package/esm/createSitemap/createSitemap.js +45 -0
- package/esm/createSitemap/index.d.ts +1 -0
- package/esm/createSitemap/index.js +1 -0
- package/esm/createSitemap/types.d.ts +68 -0
- package/esm/createSitemap/types.js +1 -0
- package/esm/pipeline/getFileConventions/fileConventions.d.ts +4 -0
- package/esm/pipeline/getFileConventions/fileConventions.js +4 -0
- package/esm/pipeline/getFileConventions/getFileConventions.d.ts +4 -0
- package/esm/pipeline/getFileConventions/getFileConventions.js +17 -0
- package/esm/pipeline/getFileConventions/index.d.ts +1 -0
- package/esm/pipeline/getFileConventions/index.js +1 -0
- package/esm/{CodeHighlighter/addPathsToVariant.d.ts → pipeline/loadCodeVariant/addCodeVariantPaths.d.ts} +1 -1
- package/esm/{CodeHighlighter/applyTransform.d.ts → pipeline/loadCodeVariant/applyCodeTransform.d.ts} +3 -3
- package/esm/{CodeHighlighter/applyTransform.js → pipeline/loadCodeVariant/applyCodeTransform.js} +4 -4
- package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.js +1 -1
- package/esm/{CodeHighlighter/transformCode.d.ts → pipeline/loadCodeVariant/computeHastDeltas.d.ts} +9 -5
- package/esm/{CodeHighlighter/transformCode.js → pipeline/loadCodeVariant/computeHastDeltas.js} +20 -16
- package/esm/pipeline/loadCodeVariant/diffHast.d.ts +3 -0
- package/esm/{CodeHighlighter/transformParsedSource.js → pipeline/loadCodeVariant/diffHast.js} +5 -5
- package/esm/{CodeHighlighter/examineVariant.d.ts → pipeline/loadCodeVariant/examineCodeVariant.d.ts} +2 -2
- package/esm/{CodeHighlighter/examineVariant.js → pipeline/loadCodeVariant/examineCodeVariant.js} +1 -1
- package/esm/{useDemo/flattenVariant.d.ts → pipeline/loadCodeVariant/flattenCodeVariant.d.ts} +2 -2
- package/esm/{useDemo/flattenVariant.js → pipeline/loadCodeVariant/flattenCodeVariant.js} +3 -3
- package/esm/{CodeHighlighter/hasAllVariants.d.ts → pipeline/loadCodeVariant/hasAllCodeVariants.d.ts} +1 -1
- package/esm/pipeline/loadCodeVariant/index.d.ts +10 -0
- package/esm/pipeline/loadCodeVariant/index.js +17 -0
- package/esm/{CodeHighlighter/loadFallbackCode.d.ts → pipeline/loadCodeVariant/loadCodeFallback.d.ts} +2 -2
- package/esm/{CodeHighlighter/loadFallbackCode.js → pipeline/loadCodeVariant/loadCodeFallback.js} +180 -106
- package/esm/{CodeHighlighter/loadVariant.d.ts → pipeline/loadCodeVariant/loadCodeVariant.d.ts} +2 -2
- package/esm/{CodeHighlighter/loadVariant.js → pipeline/loadCodeVariant/loadCodeVariant.js} +122 -49
- package/esm/{CodeHighlighter/maybeInitialData.d.ts → pipeline/loadCodeVariant/maybeCodeInitialData.d.ts} +6 -6
- package/esm/{CodeHighlighter/maybeInitialData.js → pipeline/loadCodeVariant/maybeCodeInitialData.js} +6 -6
- package/esm/{CodeHighlighter/mergeMetadata.d.ts → pipeline/loadCodeVariant/mergeCodeMetadata.d.ts} +3 -3
- package/esm/{CodeHighlighter/mergeMetadata.js → pipeline/loadCodeVariant/mergeCodeMetadata.js} +3 -3
- package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.d.ts +1 -1
- package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/transformSource.d.ts +1 -1
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +5 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +86 -13
- package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.d.ts +30 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js +77 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +7 -7
- package/esm/pipeline/loadPrecomputedSitemap/index.d.ts +2 -0
- package/esm/pipeline/loadPrecomputedSitemap/index.js +4 -0
- package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.d.ts +10 -0
- package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.js +213 -0
- package/esm/pipeline/loadServerCodeMeta/index.d.ts +2 -1
- package/esm/pipeline/loadServerCodeMeta/index.js +2 -1
- package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts +1 -1
- package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +2 -2
- package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.d.ts +1 -1
- package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.js +1 -1
- package/esm/pipeline/loadServerPageIndex/index.d.ts +2 -0
- package/esm/pipeline/loadServerPageIndex/index.js +1 -0
- package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.d.ts +51 -0
- package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.js +174 -0
- package/esm/pipeline/loadServerSitemap/index.d.ts +2 -0
- package/esm/pipeline/loadServerSitemap/index.js +1 -0
- package/esm/pipeline/loadServerSitemap/loadServerSitemap.d.ts +39 -0
- package/esm/pipeline/loadServerSitemap/loadServerSitemap.js +168 -0
- package/esm/pipeline/loadServerSource/loadServerSource.js +1 -1
- package/esm/pipeline/loaderUtils/externalsToPackages.js +1 -1
- package/esm/pipeline/loaderUtils/processRelativeImports.js +16 -3
- package/esm/pipeline/loaderUtils/rewriteImports.d.ts +36 -0
- package/esm/pipeline/loaderUtils/rewriteImports.js +139 -8
- package/esm/pipeline/syncPageIndex/createMarkdownNodes.d.ts +76 -0
- package/esm/pipeline/syncPageIndex/createMarkdownNodes.js +305 -0
- package/esm/pipeline/syncPageIndex/index.d.ts +1 -0
- package/esm/pipeline/syncPageIndex/index.js +1 -0
- package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.d.ts +58 -0
- package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.js +214 -0
- package/esm/pipeline/syncPageIndex/metadataToMarkdown.d.ts +67 -0
- package/esm/pipeline/syncPageIndex/metadataToMarkdown.js +1486 -0
- package/esm/pipeline/syncPageIndex/syncPageIndex.d.ts +108 -0
- package/esm/pipeline/syncPageIndex/syncPageIndex.js +540 -0
- package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.d.ts +2 -2
- package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +5 -5
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/index.js +4 -0
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.d.ts +16 -0
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js +58 -0
- package/esm/pipeline/transformMarkdownDemoLinks/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownDemoLinks/index.js +4 -0
- package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.d.ts +26 -0
- package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.js +107 -0
- package/esm/pipeline/transformMarkdownMetadata/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownMetadata/index.js +4 -0
- package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.d.ts +3 -0
- package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js +1010 -0
- package/esm/pipeline/transformMarkdownMetadata/types.d.ts +110 -0
- package/esm/pipeline/transformMarkdownMetadata/types.js +1 -0
- package/esm/pipeline/transformMarkdownRelativePaths/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownRelativePaths/index.js +4 -0
- package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.d.ts +15 -0
- package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +40 -0
- package/esm/useCode/Pre.js +15 -2
- package/esm/useCode/useCode.d.ts +15 -2
- package/esm/useCode/useCode.js +15 -6
- package/esm/useCode/useCodeUtils.js +3 -3
- package/esm/useCode/useFileNavigation.d.ts +9 -3
- package/esm/useCode/useFileNavigation.js +124 -81
- package/esm/useCode/useUIState.d.ts +4 -1
- package/esm/useCode/useUIState.js +17 -2
- package/esm/useCode/useVariantSelection.d.ts +8 -3
- package/esm/useCode/useVariantSelection.js +144 -52
- package/esm/useCopier/index.js +5 -4
- package/esm/useDemo/createCodeSandbox.d.ts +1 -1
- package/esm/useDemo/createStackBlitz.d.ts +1 -1
- package/esm/useDemo/exportVariant.js +13 -11
- package/esm/useDemo/index.d.ts +1 -1
- package/esm/useDemo/index.js +1 -1
- package/esm/useDemo/useDemo.d.ts +5 -5
- package/esm/useDemo/useDemo.js +6 -6
- package/esm/useErrors/useErrors.d.ts +1 -1
- package/esm/useErrors/useErrors.js +6 -2
- package/esm/useSearch/index.d.ts +1 -0
- package/esm/useSearch/index.js +1 -0
- package/esm/useSearch/types.d.ts +165 -0
- package/esm/useSearch/types.js +1 -0
- package/esm/useSearch/useSearch.d.ts +56 -0
- package/esm/useSearch/useSearch.js +647 -0
- package/esm/withDocsInfra/withDeploymentConfig.js +4 -2
- package/esm/withDocsInfra/withDocsInfra.d.ts +39 -0
- package/esm/withDocsInfra/withDocsInfra.js +79 -7
- package/package.json +106 -6
- package/esm/CodeHighlighter/transformParsedSource.d.ts +0 -3
- /package/esm/{CodeHighlighter/addPathsToVariant.js → pipeline/loadCodeVariant/addCodeVariantPaths.js} +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.d.ts +0 -0
- /package/esm/{CodeHighlighter/hasAllVariants.js → pipeline/loadCodeVariant/hasAllCodeVariants.js} +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.js +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.d.ts +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.js +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/transformSource.js +0 -0
|
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
4
4
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
5
|
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
6
6
|
import { visit } from 'unist-util-visit';
|
|
7
|
-
import {
|
|
7
|
+
import { loadCodeVariant } from "../loadCodeVariant/loadCodeVariant.js";
|
|
8
8
|
import { createParseSource } from "../parseSource/index.js";
|
|
9
9
|
import { TypescriptToJavascriptTransformer } from "../transformTypescriptToJavascript/index.js";
|
|
10
10
|
/**
|
|
@@ -206,13 +206,13 @@ function extractFromDl(dl) {
|
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
/**
|
|
209
|
-
* Rehype plugin that transforms semantic HTML code structures to use
|
|
209
|
+
* Rehype plugin that transforms semantic HTML code structures to use loadCodeVariant
|
|
210
210
|
*
|
|
211
211
|
* This plugin:
|
|
212
212
|
* 1. Finds section and dl elements in the HTML AST
|
|
213
213
|
* 2. Extracts code elements from the semantic structure (figure/dl/dd/pre/code)
|
|
214
214
|
* 3. Creates variants from multiple code elements or single Default variant
|
|
215
|
-
* 4. Uses
|
|
215
|
+
* 4. Uses loadCodeVariant to process each variant
|
|
216
216
|
* 5. Stores the combined precompute data on the root element
|
|
217
217
|
* 6. Clears all code element contents and replaces with error message
|
|
218
218
|
*/
|
|
@@ -307,7 +307,7 @@ export var transformHtmlCodePrecomputed = function transformHtmlCodePrecomputed(
|
|
|
307
307
|
});
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
-
// Process each variant with
|
|
310
|
+
// Process each variant with loadCodeVariant
|
|
311
311
|
processedCode = {};
|
|
312
312
|
variantPromises = Object.entries(variants).map(/*#__PURE__*/function () {
|
|
313
313
|
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref4) {
|
|
@@ -321,7 +321,7 @@ export var transformHtmlCodePrecomputed = function transformHtmlCodePrecomputed(
|
|
|
321
321
|
break;
|
|
322
322
|
}
|
|
323
323
|
_context.n = 1;
|
|
324
|
-
return
|
|
324
|
+
return loadCodeVariant(undefined,
|
|
325
325
|
// url - not needed for inline code
|
|
326
326
|
variantName, variantData, {
|
|
327
327
|
sourceParser: sourceParser,
|
package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Plugin } from 'unified';
|
|
2
|
+
/**
|
|
3
|
+
* Remark plugin that extracts GitHub-style callouts from blockquotes and injects them into data attributes.
|
|
4
|
+
*
|
|
5
|
+
* Transforms blockquotes like:
|
|
6
|
+
* > [!NOTE]
|
|
7
|
+
* > This is a note.
|
|
8
|
+
*
|
|
9
|
+
* Into blockquotes with a custom data attribute that will be preserved when converted to HTML:
|
|
10
|
+
* <blockquote data-callout-type="note">
|
|
11
|
+
* <p>This is a note.</p>
|
|
12
|
+
* </blockquote>
|
|
13
|
+
*
|
|
14
|
+
* Supported callout types: NOTE, TIP, IMPORTANT, WARNING, CAUTION
|
|
15
|
+
*/
|
|
16
|
+
export declare const transformMarkdownBlockquoteCallouts: Plugin;
|
package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { visit } from 'unist-util-visit';
|
|
2
|
+
/**
|
|
3
|
+
* Remark plugin that extracts GitHub-style callouts from blockquotes and injects them into data attributes.
|
|
4
|
+
*
|
|
5
|
+
* Transforms blockquotes like:
|
|
6
|
+
* > [!NOTE]
|
|
7
|
+
* > This is a note.
|
|
8
|
+
*
|
|
9
|
+
* Into blockquotes with a custom data attribute that will be preserved when converted to HTML:
|
|
10
|
+
* <blockquote data-callout-type="note">
|
|
11
|
+
* <p>This is a note.</p>
|
|
12
|
+
* </blockquote>
|
|
13
|
+
*
|
|
14
|
+
* Supported callout types: NOTE, TIP, IMPORTANT, WARNING, CAUTION
|
|
15
|
+
*/
|
|
16
|
+
export var transformMarkdownBlockquoteCallouts = function transformMarkdownBlockquoteCallouts() {
|
|
17
|
+
return function (tree) {
|
|
18
|
+
visit(tree, 'blockquote', function (node) {
|
|
19
|
+
// Find the first paragraph in the blockquote
|
|
20
|
+
var firstChild = node.children[0];
|
|
21
|
+
if (!firstChild || firstChild.type !== 'paragraph') {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Find the first text node in the paragraph
|
|
26
|
+
var firstTextNode = firstChild.children[0];
|
|
27
|
+
if (!firstTextNode || firstTextNode.type !== 'text') {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
var textNode = firstTextNode;
|
|
31
|
+
var calloutPattern = /^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*/;
|
|
32
|
+
var match = textNode.value.match(calloutPattern);
|
|
33
|
+
if (match) {
|
|
34
|
+
var calloutType = match[1].toLowerCase();
|
|
35
|
+
|
|
36
|
+
// Remove the callout marker from the text
|
|
37
|
+
var newText = textNode.value.replace(calloutPattern, '');
|
|
38
|
+
if (newText.trim() === '') {
|
|
39
|
+
// Remove the text node if it becomes empty
|
|
40
|
+
firstChild.children.shift();
|
|
41
|
+
} else {
|
|
42
|
+
// Update the text content
|
|
43
|
+
textNode.value = newText;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Add the data attribute to the blockquote
|
|
47
|
+
// This creates a custom property that will be preserved when converting to HTML
|
|
48
|
+
if (!node.data) {
|
|
49
|
+
node.data = {};
|
|
50
|
+
}
|
|
51
|
+
if (!node.data.hProperties) {
|
|
52
|
+
node.data.hProperties = {};
|
|
53
|
+
}
|
|
54
|
+
node.data.hProperties['data-callout-type'] = calloutType;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Plugin } from 'unified';
|
|
2
|
+
/**
|
|
3
|
+
* Remark plugin that cleans up demo patterns in markdown.
|
|
4
|
+
*
|
|
5
|
+
* Looks for patterns where a Demo component is followed by a "[See Demo]" link
|
|
6
|
+
* and optionally a horizontal rule (---). When found, removes the link and
|
|
7
|
+
* any following horizontal rule.
|
|
8
|
+
*
|
|
9
|
+
* This is useful for markdown that will be converted to HTML where the link
|
|
10
|
+
* and separator are distracting on the page.
|
|
11
|
+
*
|
|
12
|
+
* Pattern it matches:
|
|
13
|
+
* ```
|
|
14
|
+
* <DemoSomething />
|
|
15
|
+
*
|
|
16
|
+
* [See Demo](./demos/base/)
|
|
17
|
+
*
|
|
18
|
+
* --- (optional)
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Gets transformed to:
|
|
22
|
+
* ```
|
|
23
|
+
* <DemoSomething />
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare const transformMarkdownDemoLinks: Plugin;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// MDX JSX types
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Remark plugin that cleans up demo patterns in markdown.
|
|
5
|
+
*
|
|
6
|
+
* Looks for patterns where a Demo component is followed by a "[See Demo]" link
|
|
7
|
+
* and optionally a horizontal rule (---). When found, removes the link and
|
|
8
|
+
* any following horizontal rule.
|
|
9
|
+
*
|
|
10
|
+
* This is useful for markdown that will be converted to HTML where the link
|
|
11
|
+
* and separator are distracting on the page.
|
|
12
|
+
*
|
|
13
|
+
* Pattern it matches:
|
|
14
|
+
* ```
|
|
15
|
+
* <DemoSomething />
|
|
16
|
+
*
|
|
17
|
+
* [See Demo](./demos/base/)
|
|
18
|
+
*
|
|
19
|
+
* --- (optional)
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Gets transformed to:
|
|
23
|
+
* ```
|
|
24
|
+
* <DemoSomething />
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export var transformMarkdownDemoLinks = function transformMarkdownDemoLinks() {
|
|
28
|
+
return function (tree) {
|
|
29
|
+
var parent = tree;
|
|
30
|
+
var children = parent.children;
|
|
31
|
+
for (var i = 0; i < children.length - 1; i += 1) {
|
|
32
|
+
var current = children[i];
|
|
33
|
+
var next = children[i + 1];
|
|
34
|
+
var separator = children[i + 2]; // May not exist
|
|
35
|
+
|
|
36
|
+
var hasDemo = false;
|
|
37
|
+
|
|
38
|
+
// Check if current node is an HTML element containing a Demo component without .Title
|
|
39
|
+
if ((current == null ? void 0 : current.type) === 'html') {
|
|
40
|
+
var htmlNode = current;
|
|
41
|
+
hasDemo = htmlNode.value.includes('<Demo') && !htmlNode.value.includes('.Title');
|
|
42
|
+
} else if ((current == null ? void 0 : current.type) === 'mdxJsxFlowElement') {
|
|
43
|
+
// Check if current node is an MDX JSX element (for imported Demo components)
|
|
44
|
+
var mdxNode = current;
|
|
45
|
+
if (mdxNode.name && mdxNode.name.includes('Demo') && !mdxNode.name.includes('.Title')) {
|
|
46
|
+
hasDemo = true;
|
|
47
|
+
}
|
|
48
|
+
} else if ((current == null ? void 0 : current.type) === 'paragraph') {
|
|
49
|
+
// Check if paragraph contains only a single HTML node with a Demo component
|
|
50
|
+
var paragraphNode = current;
|
|
51
|
+
if (paragraphNode.children.length === 1 && paragraphNode.children[0].type === 'html') {
|
|
52
|
+
var _htmlNode = paragraphNode.children[0];
|
|
53
|
+
hasDemo = _htmlNode.value.includes('<Demo') && !_htmlNode.value.includes('.Title');
|
|
54
|
+
} else if (paragraphNode.children.length >= 2 && paragraphNode.children[0].type === 'html' && paragraphNode.children[paragraphNode.children.length - 1].type === 'html') {
|
|
55
|
+
// Check if this looks like a Demo component with opening and closing tags
|
|
56
|
+
var openingTag = paragraphNode.children[0];
|
|
57
|
+
var closingTag = paragraphNode.children[paragraphNode.children.length - 1];
|
|
58
|
+
if (openingTag.value.includes('<Demo') && !openingTag.value.includes('.Title') && closingTag.value.includes('</Demo')) {
|
|
59
|
+
hasDemo = true;
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
// Check if paragraph contains any HTML nodes with Demo components (mixed content)
|
|
63
|
+
hasDemo = paragraphNode.children.some(function (child) {
|
|
64
|
+
return child.type === 'html' && child.value.includes('<Demo') && !child.value.includes('.Title');
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!hasDemo) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
var removedSomething = false;
|
|
72
|
+
|
|
73
|
+
// Check if next node is a paragraph containing a "See Demo" link
|
|
74
|
+
if ((next == null ? void 0 : next.type) === 'paragraph') {
|
|
75
|
+
var hasSeeDemo = next.children.some(function (child) {
|
|
76
|
+
return child.type === 'link' && child.children.some(function (linkChild) {
|
|
77
|
+
return linkChild.type === 'text' && linkChild.value === 'See Demo';
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Check if there's also a thematic break (---) after the paragraph
|
|
82
|
+
var hasThematicBreak = (separator == null ? void 0 : separator.type) === 'thematicBreak';
|
|
83
|
+
if (hasSeeDemo) {
|
|
84
|
+
// Remove the "See Demo" paragraph and any following thematic break
|
|
85
|
+
if (hasThematicBreak) {
|
|
86
|
+
// Remove both the "See Demo" paragraph and the thematic break
|
|
87
|
+
children.splice(i + 1, 2);
|
|
88
|
+
removedSomething = true;
|
|
89
|
+
} else {
|
|
90
|
+
// Remove only the "See Demo" paragraph
|
|
91
|
+
children.splice(i + 1, 1);
|
|
92
|
+
removedSomething = true;
|
|
93
|
+
}
|
|
94
|
+
} else if (hasThematicBreak) {
|
|
95
|
+
// No "See Demo" link, but there's a thematic break after the paragraph - remove just the HR
|
|
96
|
+
children.splice(i + 2, 1);
|
|
97
|
+
removedSomething = true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// If we removed something, adjust the loop index to prevent skipping
|
|
102
|
+
if (removedSomething) {
|
|
103
|
+
i -= 1;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
};
|