mermaid-protect.ts

Source

3 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.

Reference

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.

View source

fnprotectMermaidSvgs(html: string): MermaidSvgProtectionExtract <div class="ox-mermaid">...</div> blocks and replace with HTML commen…

Extract <div class="ox-mermaid">...</div> blocks and replace with HTML comment placeholders that rehype will preserve.

View source

Parameters

  • html string

Returns

MermaidSvgProtection
fnrestoreMermaidSvgs(html: string, svgs: Map<string, string>): stringRestore protected mermaid SVG blocks from placeholders.

Restore protected mermaid SVG blocks from placeholders.

View source

Parameters

  • html string
  • svgs Map

Returns

string