Skip to content

mermaid-protect.ts#

View Markdown

Source

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

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

Reference#

modulemermaid-protectProtects generated static SVG content from rehype HTML5 parser corruption. rehypeParse + rehypeStringify converts <br /…

Protects generated static 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 and ox-graphviz SVG blocks into placeholders before rehype processing and restores them after.

View source

interfaceMermaidSvgProtectionProtects generated static SVG content from rehype HTML5 parser corruption. rehy…

Protects generated static 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 and ox-graphviz 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
fnprotectStaticDiagramSvgs(html: string): MermaidSvgProtectionExtract generated static diagram blocks and replace them with HTML comment plac…

Extract generated static diagram blocks and replace them with HTML comment placeholders that rehype will preserve.

Signature

export function protectStaticDiagramSvgs(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
fnrestoreStaticDiagramSvgs(html: string, svgs: Map<string, string>): stringRestore generated static diagram blocks from placeholders.

Restore generated static diagram blocks from placeholders.

Signature

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

View source

Parameters

  • html string
  • svgs Map<string, string>

Returns

string