Skip to content

Add MermaidExtension for rendering Mermaid.js diagrams#131

Merged
dereuromark merged 1 commit intomasterfrom
feature/mermaid-extension
Mar 26, 2026
Merged

Add MermaidExtension for rendering Mermaid.js diagrams#131
dereuromark merged 1 commit intomasterfrom
feature/mermaid-extension

Conversation

@dereuromark
Copy link
Copy Markdown
Contributor

Summary

  • Adds MermaidExtension that transforms code blocks with language mermaid into Mermaid.js-compatible markup
  • Supports <pre> or <div> tag options
  • Optional figure wrapper for semantic markup
  • Preserves custom attributes and classes
  • Comprehensive documentation with JavaScript integration examples

Usage

$converter = new DjotConverter();
$converter->addExtension(new MermaidExtension());

Input:

``` mermaid
graph TD;
    A-->B;
    A-->C;
```

Output:

<pre class="mermaid">graph TD;
    A-->B;
    A-->C;
</pre>

Configuration

Option Type Default Description
tag string 'pre' HTML tag ('pre' or 'div')
cssClass string 'mermaid' CSS class for Mermaid.js
wrapInFigure bool false Wrap in <figure>
figureClass string 'mermaid-figure' Figure wrapper class

Supported Diagram Types

Flowcharts, sequence diagrams, class diagrams, state diagrams, ER diagrams, Gantt charts, pie charts, git graphs, mindmaps, timelines, and more.

See https://mermaid.js.org/ for full Mermaid documentation.

- Transform mermaid code blocks into Mermaid.js-compatible markup
- Support pre/div tag options
- Optional figure wrapper for semantic markup
- Preserve custom attributes and classes
- Comprehensive documentation with JavaScript integration guide
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 97.56098% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.98%. Comparing base (41bdb80) to head (1187971).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/Extension/MermaidExtension.php 97.56% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #131      +/-   ##
============================================
+ Coverage     93.94%   93.98%   +0.03%     
- Complexity     2385     2407      +22     
============================================
  Files            81       83       +2     
  Lines          6310     6379      +69     
============================================
+ Hits           5928     5995      +67     
- Misses          382      384       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dereuromark dereuromark marked this pull request as ready for review March 26, 2026 16:16
@dereuromark dereuromark merged commit f34fa00 into master Mar 26, 2026
6 checks passed
@dereuromark dereuromark deleted the feature/mermaid-extension branch March 26, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant