Skip to content

Latest commit

Β 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Mermaid Diagram Generator for Inkscape

Inkscape Node.js Mermaid License

Create beautiful diagrams in Inkscape using Mermaid's simple text-based syntax

Transform text descriptions into professional flowcharts, sequence diagrams, class diagrams, and moreβ€”directly within Inkscape. Perfect for technical documentation, presentations, and design projects.

πŸ“Ί Demo

Watch the Demo

Click to watch the full tutorial on YouTube


πŸ“‹ Table of Contents

  • Features
  • Supported Diagrams
  • Requirements
  • Installation
  • Quick Start
  • Usage Guide
  • Configuration
  • Examples
  • Troubleshooting
  • Contributing
  • License

✨ Features

  • πŸ“Š Full Mermaid Support

    • All diagram types supported
    • Native SVG output for editability
    • High-quality PNG export option
  • 🎨 Rich Styling Options

    Feature Description
    Themes Default, Dark, Forest, Neutral, Base
    Backgrounds White, Transparent, Custom colors
    Scaling Manual scale factor or auto-fit
    Quality 1x to 4x resolution for PNG
  • πŸ“ Smart Positioning

    • 9 preset positions (center, corners, edges)
    • Selection-relative placement
    • Custom X/Y offsets
    • Page or viewport alignment
  • πŸ”§ Advanced Features

    • PDF-to-SVG pipeline for best quality
    • Embed or link external images
    • Custom config and CSS files
    • Layer management
    • Object locking
    • Metadata support (title, description)

πŸ“Š Supported Diagrams

Diagram Type Syntax Keyword Description
Flowchart flowchart or graph Process flows and decision trees
Sequence sequenceDiagram Interaction between entities
Class classDiagram UML class relationships
State stateDiagram-v2 State machine diagrams
ER Diagram erDiagram Entity-relationship models
Gantt gantt Project timelines
Pie Chart pie Proportional data
Git Graph gitGraph Git branch visualization
Mindmap mindmap Hierarchical ideas
Timeline timeline Chronological events
User Journey journey User experience mapping
Quadrant quadrantChart 2x2 matrix analysis
Sankey sankey-beta Flow quantities

πŸ“¦ Requirements

Core Requirements

Component Version Purpose
Inkscape 1.0+ Vector graphics editor
Node.js 14+ JavaScript runtime
Mermaid CLI 10+ Diagram generation

Optional Dependencies

Component Purpose
Pillow (Python) Automatic image dimension detection
Custom CSS Advanced diagram styling

πŸš€ Installation

Step 1: Install Node.js

Windows
  1. Download from nodejs.org
  2. Run installer, accept defaults
  3. Verify installation:
    node --version
    npm --version
macOS
# Using Homebrew
brew install node

# Or download from nodejs.org
Linux
# Ubuntu/Debian
sudo apt update
sudo apt install nodejs npm

# Fedora
sudo dnf install nodejs npm

# Arch
sudo pacman -S nodejs npm

Step 2: Install Mermaid CLI

npm install -g @mermaid-js/mermaid-cli

Verify installation:

mmdc --version
# Should output: x.x.x (e.g., 10.6.1)

⚠️ Windows Users: Note the full path to mmdc.cmd:

C:\Users\[YourName]\AppData\Roaming\npm\mmdc.cmd

Step 3: Install the Extension

Locate your Inkscape extensions directory:

OS Path
Windows C:\Users\[YourName]\AppData\Roaming\inkscape\extensions\
macOS ~/Library/Application Support/org.inkscape.Inkscape/config/inkscape/extensions/
Linux ~/.config/inkscape/extensions/

πŸ’‘ Tip: In Inkscape: Edit β†’ Preferences β†’ System shows extensions path

Install files:

  1. Create extension folder:

    mkdir -p [extensions-directory]/mermaid_ink
  2. Copy files:

    cp mermaid_diagram.py [extensions-directory]/mermaid_ink/
    cp mermaid_diagram.inx [extensions-directory]/mermaid_ink/
  3. Set permissions (Linux/macOS):

    chmod +x [extensions-directory]/mermaid_ink/mermaid_diagram.py
  4. Restart Inkscape

Step 4: Verify Installation

  1. Open Inkscape
  2. Navigate to Extensions β†’ Render β†’ Mermaid Diagram
  3. Extension dialog should appear

🎯 Quick Start

Create Your First Diagram

  1. Open Inkscape
  2. Go to Extensions β†’ Render β†’ Mermaid Diagram
  3. In the Diagram tab, enter:
flowchart TD
    A[Start] --> B{Decision}
    B -->|Yes| C[Do Something]
    B -->|No| D[Do Something Else]
    C --> E[End]
    D --> E
Loading
  1. Click Apply

Your flowchart appears in the document, fully editable as SVG!


πŸ“– Usage Guide

Tab Overview

Tab Purpose
Diagram Enter Mermaid code or load from file
Style Theme, background, dimensions
Format Output format, scale, quality
Position Placement and alignment options
Scale Auto-scaling and size limits
Config CLI path, config files
Advanced Timeout, viewport, temp files
Layer Layer management, object properties

Input Methods

Direct Code Entry

Enter Mermaid syntax directly in the code field:

sequenceDiagram
    Alice->>Bob: Hello Bob!
    Bob-->>Alice: Hi Alice!
Loading

Load from File

  1. Check "Use external file"
  2. Enter path to .mmd or .mermaid file
  3. Click Apply

Output Formats

Format Best For Editable
SVG Editing, scalability βœ… Yes
PNG Presentations, sharing ❌ No

Theme Options

Theme Description
default Standard Mermaid colors
dark Dark background, light elements
forest Green nature palette
neutral Grayscale, professional
base Minimal, for custom CSS

Position Modes

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ top_left    top_center    top_right β”‚
β”‚                                     β”‚
β”‚ middle_left   center   middle_right β”‚
β”‚                                     β”‚
β”‚ bottom_left bottom_center bottom_right β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Special modes:

  • cursor: Place at current view center
  • Use selection bbox: Position relative to selected object

βš™οΈ Configuration

Style Tab

Option Description Default
Theme Color scheme default
Background Background color white
Width Diagram width (px) 800
Height Diagram height (px) 600

Format Tab

Option Description Default
Output Format SVG or PNG SVG
Scale Factor Size multiplier 1.0
Quality PNG resolution (1-4x) 2
Embed Image Embed or link PNG βœ“

Scale Tab

Option Description Default
Auto Scale Fit to max dimensions βœ—
Max Width Maximum width (0=none) 0
Max Height Maximum height (0=none) 0
Maintain Aspect Ratio Keep proportions βœ“
Lock Object Prevent edits βœ—

Config Tab

Option Description Default
Mermaid CLI Path Path to mmdc mmdc
Config File Custom mermaidConfig.json (empty)
CSS File Custom stylesheet (empty)
Inkscape Path Path to Inkscape CLI inkscape

Advanced Tab

Option Description Default
Timeout Generation timeout (sec) 30
Viewport Width Puppeteer viewport 1920
Viewport Height Puppeteer viewport 1080
Keep Temp Files Don't delete temp files βœ—
Quiet Mode Suppress debug output βœ“
Fit to Content Crop empty space βœ“

Layer Tab

Option Description Default
Create Layer New layer for diagram βœ—
Layer Name Name for new layer Mermaid Diagrams
Object ID Custom SVG ID (auto)
Add Title Include title element βœ—
Add Description Include desc element βœ—

πŸ’‘ Examples

Example 1: Flowchart

flowchart LR
    A[Hard edge] -->|Link text| B(Round edge)
    B --> C{Decision}
    C -->|One| D[Result one]
    C -->|Two| E[Result two]
Loading

Example 2: Sequence Diagram

sequenceDiagram
    participant Browser
    participant Server
    participant Database
    
    Browser->>Server: HTTP Request
    Server->>Database: Query
    Database-->>Server: Results
    Server-->>Browser: HTTP Response
Loading

Example 3: Class Diagram

classDiagram
    Animal <|-- Duck
    Animal <|-- Fish
    Animal : +int age
    Animal : +String gender
    Animal: +isMammal()
    Animal: +mate()
    
    class Duck{
        +String beakColor
        +swim()
        +quack()
    }
    
    class Fish{
        -int sizeInFeet
        -canEat()
    }
Loading

Example 4: Gantt Chart

gantt
    title Project Schedule
    dateFormat  YYYY-MM-DD
    
    section Planning
    Requirements    :a1, 2024-01-01, 30d
    Design          :a2, after a1, 20d
    
    section Development
    Frontend        :b1, after a2, 40d
    Backend         :b2, after a2, 45d
    
    section Testing
    QA              :c1, after b2, 15d
Loading

Example 5: Entity Relationship

erDiagram
    CUSTOMER ||--o{ ORDER : places
    ORDER ||--|{ LINE-ITEM : contains
    CUSTOMER {
        string name
        string email
    }
    ORDER {
        int orderNumber
        date created
    }
    LINE-ITEM {
        string productCode
        int quantity
        float price
    }
Loading

Example 6: Mindmap

mindmap
  root((Project))
    Planning
      Requirements
      Timeline
      Budget
    Development
      Frontend
      Backend
      Database
    Testing
      Unit Tests
      Integration
      UAT
Loading

Example 7: Pie Chart

pie showData
    title Browser Market Share
    "Chrome" : 65
    "Safari" : 19
    "Firefox" : 4
    "Edge" : 4
    "Other" : 8
Loading

Example 8: Git Graph

gitGraph
    commit
    commit
    branch develop
    checkout develop
    commit
    commit
    checkout main
    merge develop
    commit
    branch feature
    checkout feature
    commit
    checkout main
    merge feature
Loading

πŸ› Troubleshooting

Common Issues

Extension not appearing in menu

Solutions:

  1. Verify files are correctly placed:
    ls [extensions-directory]/mermaid_ink/
    # Should show: mermaid_diagram.py, mermaid_diagram.inx
  2. Check file permissions
  3. Restart Inkscape completely
  4. Check Inkscape error log: Edit β†’ Preferences β†’ System β†’ Open Error Log
Mermaid CLI not found

Error: Mermaid CLI not found at: mmdc

Solutions:

  1. Verify mmdc is installed:
    mmdc --version
  2. Install if missing:
    npm install -g @mermaid-js/mermaid-cli
  3. Windows: Use full path in Config tab:
    C:\Users\[YourName]\AppData\Roaming\npm\mmdc.cmd
    
  4. Linux/macOS: Find path:
    which mmdc
    # Use this path in Config tab
Diagram syntax error

Error: Mermaid CLI error: Parse error...

Solutions:

  1. Validate syntax at mermaid.live
  2. Check for:
    • Missing diagram type declaration
    • Unclosed brackets
    • Invalid characters
    • Incorrect indentation
  3. Start with a simple example and build up
Puppeteer/Chrome errors

Error: Could not find Chrome... or Puppeteer timeout

Solutions:

  1. Install Chrome/Chromium:
    # Windows: Install Chrome normally
    # Linux:
    sudo apt install chromium-browser
  2. Increase timeout in Advanced tab
  3. Check system resources (RAM, CPU)
PDF conversion fails

Error: Inkscape conversion error...

Solutions:

  1. Verify Inkscape CLI works:
    inkscape --version
  2. Update Inkscape path in Config tab
  3. Windows: Use full path:
    C:\Program Files\Inkscape\bin\inkscape.exe
    
  4. Enable pdf-poppler option for better compatibility
Empty or corrupted output

Solutions:

  1. Disable Quiet Mode to see debug output
  2. Enable Keep Temp Files and check generated files
  3. Try PNG format instead of SVG
  4. Reduce diagram complexity
  5. Check available disk space
Diagram appears but not editable (SVG)

Solutions:

  1. Ungroup the imported diagram (Ctrl+Shift+G)
  2. Check if object is locked (unlock in Object Properties)
  3. Ensure "Output Format" is set to SVG, not PNG

Debug Mode

Enable detailed output for troubleshooting:

  1. Uncheck Quiet Mode in Advanced tab
  2. Check Keep Temp Files
  3. Run Inkscape from terminal to see console output:
    inkscape
  4. Temp files location:
    • Check the path in extension output
    • Or set custom path in Temp Directory field

Checking Temp Files

With Keep Temp Files enabled:

File Purpose
diagram.mmd Input Mermaid code
diagram.pdf Generated PDF
diagram_converted.svg Converted SVG
diagram_converted.png Converted PNG

πŸ“ File Structure

mermaid_ink/
β”œβ”€β”€ mermaid_diagram.py      # Main extension code
β”œβ”€β”€ mermaid_diagram.inx     # Inkscape extension definition
β”œβ”€β”€ README.md               # This file
└── examples/               # Example diagrams (optional)
    β”œβ”€β”€ flowchart.mmd
    β”œβ”€β”€ sequence.mmd
    └── class.mmd

πŸ”§ Custom Configuration

Mermaid Config File

Create a JSON config file for advanced customization:

{
  "theme": "base",
  "themeVariables": {
    "primaryColor": "#4a90d9",
    "primaryTextColor": "#fff",
    "primaryBorderColor": "#2c5aa0",
    "lineColor": "#333",
    "secondaryColor": "#006100",
    "tertiaryColor": "#fff"
  },
  "flowchart": {
    "curve": "basis",
    "padding": 20
  },
  "sequence": {
    "diagramMarginX": 50,
    "diagramMarginY": 10,
    "actorMargin": 50,
    "width": 150,
    "height": 65
  }
}

Save as mermaid-config.json and reference in Config tab.

Custom CSS

Create a CSS file for diagram styling:

.node rect {
  fill: #f0f0f0;
  stroke: #333;
  stroke-width: 2px;
}

.edgePath .path {
  stroke: #666;
  stroke-width: 2px;
}

.label {
  font-family: 'Arial', sans-serif;
  font-size: 14px;
}

Save as mermaid-styles.css and reference in Config tab.


πŸ“š Resources


🀝 Contributing

Contributions are welcome!

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-feature)
  3. Commit changes (git commit -m 'Add new feature')
  4. Push to branch (git push origin feature/new-feature)
  5. Open a Pull Request

Development Setup:

git clone https://github.com/YouvenZ/mermaid_ink.git
cd mermaid_ink
# Symlink for testing
ln -s $(pwd) ~/.config/inkscape/extensions/mermaid_ink

πŸ“„ License

This project is licensed under the MIT License - see LICENSE file for details.


πŸ“§ Support


πŸ™ Acknowledgments


πŸ”„ Changelog

v1.0.0 (2024)

  • ✨ Initial release
  • βœ… All Mermaid diagram types
  • βœ… SVG and PNG output
  • βœ… PDF-to-SVG conversion pipeline
  • βœ… 5 built-in themes
  • βœ… Auto-scaling
  • βœ… Layer management
  • βœ… Custom config/CSS support
  • βœ… Position and alignment options

About

Inkscape extension to add mermaid diagram within inkscape

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages