Finds and renders all Mermaid diagrams in the document. This method processes elements matching a selector (default:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mermaid-js/mermaid/llms.txt
Use this file to discover all available pages before exploring further.
.mermaid), converting their text content into SVG diagrams.
Signature
Parameters
Optional configuration for the run operation.
Return value
Promise<void> - Resolves when all diagrams have been rendered.
Behavior
- Processes elements sequentially, not in parallel
- Sets
data-processed="true"attribute on rendered elements - Skips elements that already have
data-processedattribute - Generates unique IDs for diagrams using format
mermaid-{n} - Decodes HTML entities and normalizes whitespace in diagram definitions
- Replaces element’s
innerHTMLwith rendered SVG - Throws first error encountered unless
suppressErrorsistrue
Examples
Basic usage
Custom selector
Specific nodes
With callback
Error suppression
Complete example with HTML
Usage notes
- Can be called multiple times; already-processed diagrams are skipped
- Use
initialize()before callingrun()to configure Mermaid - Elements must be in the DOM before calling
run() - The method processes
innerHTML, so ensure content is properly escaped - Diagram text is dedented and trimmed before processing
Related methods
- initialize() - Configure Mermaid before rendering
- render() - Render a single diagram programmatically
- parse() - Validate diagram syntax without rendering