mdbook-excalidraw
mdBook preprocessor for rendering Mermaid diagrams with zoom controls.
Features
- Render Mermaid diagrams using mermaid.js
- Interactive zoom controls (zoom in/out, reset)
- Keyboard shortcuts (Ctrl/Cmd + +/-, 0)
- View original Mermaid source
- Support for all Mermaid diagram types
- Dark theme support
- HTML escaping for security
- Transparent backgrounds
- Multiple diagrams per page
Installation
From crates.io
From source
Usage
Install into mdBook project
This copies assets to theme/ and updates book.toml.
Write Mermaid diagrams
\`\`\`mermaid
graph TD
\`\`\`
Build
Configuration
Automatic
Manual
Add to book.toml:
[]
= "mdbook-excalidraw"
[]
= ["mermaid.min.js", "mermaid-init.js", "theme/excalidraw.js"]
= ["theme/excalidraw.css"]
Note: Requires mermaid.min.js and mermaid-init.js for rendering.
Zoom Controls
- Located top-right corner
- 60% opacity, 100% on hover
- Buttons: − (out), percentage, + (in), ⟲ (reset)
- Keyboard: Ctrl/Cmd + +/- for zoom, 0 for reset
Supported Diagrams
All Mermaid types supported:
- Flowcharts
- Sequence diagrams
- Class diagrams
- State diagrams
- ER diagrams
- Gantt charts
- Pie charts
- And more
Security
HTML escaping prevents XSS attacks. Newlines escaped as in attributes.
All rendering is client-side. No external requests.
Development
Build
Test
Lint
Troubleshooting
Preprocessor not running
Check book.toml:
[]
= "mdbook-excalidraw"
Assets not loading
Verify files exist in theme/ and are listed in book.toml:
[]
= ["mermaid.min.js", "mermaid-init.js", "theme/excalidraw.js"]
= ["theme/excalidraw.css"]
Diagrams not rendering
- Check browser console for errors
- Verify mermaid.js loaded
- Validate syntax at mermaid.live
Contributing
Fork, create feature branch, add tests, run clippy and fmt, submit PR.
License
GNU General Public License v3.0 - see LICENSE file.
Author
Divyanshu - Peachy Cloud Security
Contact: help@peachycloudsecurity.com
Support
GitHub Issues: https://github.com/peachycloudsecurity/mdbook-excalidraw/issues