mermaid-protect.ts
4 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.
Reference
modulemermaid-protectProtects mermaid SVG content from rehype HTML5 parser corruption. rehypeParse + rehypeStringify converts <br /> in SVG…
Protects mermaid SVG content from rehype HTML5 parser corruption.
rehypeParse + rehypeStringify converts <br /> in SVG foreignObject to <br></br>, which HTML5 interprets as 2 <br> elements. Each rehype pass doubles them: 1 → 2 → 4 → 8 → 16.
This module extracts ox-mermaid SVG blocks into placeholders before rehype processing and restores them after.
interfaceMermaidSvgProtectionProtects mermaid SVG content from rehype HTML5 parser corruption. rehypeParse +…
Protects mermaid SVG content from rehype HTML5 parser corruption.
rehypeParse + rehypeStringify converts <br /> in SVG foreignObject to <br></br>, which HTML5 interprets as 2 <br> elements. Each rehype pass doubles them: 1 → 2 → 4 → 8 → 16.
This module extracts ox-mermaid SVG blocks into placeholders before rehype processing and restores them after.
Signature
export interface MermaidSvgProtection
Members
Properties
| Name | Type | Description |
|---|---|---|
html |
string |
|
svgs |
Map<string, string> |
fnprotectMermaidSvgs(html: string): MermaidSvgProtectionExtract <div class="ox-mermaid">...</div> blocks and replace with HTML comment…
Extract <div class="ox-mermaid">...</div> blocks and replace with HTML comment placeholders that rehype will preserve.
Signature
export function protectMermaidSvgs(html: string): MermaidSvgProtection
Parameters
-
htmlstring
Returns
fnrestoreMermaidSvgs(html: string, svgs: Map<string, string>): stringRestore protected mermaid SVG blocks from placeholders.
Restore protected mermaid SVG blocks from placeholders.
Signature
export function restoreMermaidSvgs(html: string, svgs: Map<string, string>): string
Parameters
-
htmlstring -
svgsMap<string, string>
Returns
string