mermaid-protect.ts

Source

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

4 symbols 2 functions 1 interfaces 1 modules 3 parameters 2 members 2 returns

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.

View source

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

View source

Members

Properties
NameTypeDescription
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

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.

Signature

export function restoreMermaidSvgs(html: string, svgs: Map<string, string>): string

View source

Parameters

  • html string
  • svgs Map<string, string>

Returns

string