A remark plugin that automatically cleans up "[See Demo]" links and horizontal rules that follow Demo components in markdown documentation. This plugin identifies Demo components (without .Title) and removes associated navigation elements to create cleaner documentation.
Use this plugin to automatically clean up demo-related markdown patterns in your documentation. It removes redundant "[See Demo]" links that point to demo pages and optional horizontal rules that follow Demo components, streamlining the reading experience by eliminating unnecessary navigation clutter.
<Demo components without .Title props---) that follow Demo componentsimport { unified } from 'unified';
import remarkParse from 'remark-parse';
import transformMarkdownDemoLinks from '@mui/internal-docs-infra/pipeline/transformMarkdownDemoLinks';
const processor = unified().use(remarkParse).use(transformMarkdownDemoLinks);
This plugin is automatically included when using withDocsInfra() from @mui/internal-docs-infra. See the CodeHighlighter documentation for examples of Demo components in action.
The most common usage - removes "[See Demo]" links and horizontal rules that follow Demo components:
Before:
<Demo src="ButtonDemo" />
[See Demo](/material-ui/react-button/)
---
More content here...
After:
<Demo src="ButtonDemo" />
More content here...
Before:
<Demo
src="advanced/ButtonDemo"
variant="playground"
height={400}
/>
[See Demo](/material-ui/react-button/playground/)
---
Next section content...
After:
<Demo
src="advanced/ButtonDemo"
variant="playground"
height={400}
/>
Next section content...
Removes horizontal rules even when there's no "[See Demo]" link:
Before:
<Demo src="SimpleDemo" />
---
Continue reading...
After:
<Demo src="SimpleDemo" />
Continue reading...
The plugin detects Demo components in various formats:
Standalone HTML:
<Demo src="ButtonDemo" />
Opening/Closing Tags:
<Demo src="ButtonDemo">
Content here
</Demo>
Multiline with Properties:
<Demo
src="advanced/ButtonDemo"
variant="playground"
height={400}
/>
Demo components with .Title are not processed:
Preserved (not cleaned up):
<Demo.Title>Button Examples</Demo.Title>
[See Demo](/material-ui/react-button/)
---
This pattern remains unchanged because Demo.Title components serve a different purpose and their associated links should be preserved.
"[See Demo]" Links:
Horizontal Rules:
---)The plugin preserves:
.TitleRemove redundant navigation elements from documentation that already contains interactive demos.
Clean up documentation when migrating from external demo pages to embedded demos.
Eliminate navigation clutter to create a more focused reading experience.
This plugin works out-of-the-box with no configuration required. It automatically detects Demo components and cleans up associated navigation elements.
For more information about Demo components and how they work with the CodeHighlighter system, see the CodeHighlighter documentation.
Problem: "[See Demo]" links remain in the output.
Solutions:
.TitleProblem: The plugin doesn't recognize Demo components.
Solutions:
Demo.Title (which is excluded)Problem: Content is being removed that shouldn't be.
Solutions: