| Crates.io | mermaid-fixer |
| lib.rs | mermaid-fixer |
| version | 1.0.2 |
| created_at | 2025-09-28 09:01:31.688041+00 |
| updated_at | 2025-09-29 03:17:00.431249+00 |
| description | Automatically detects and fixes syntax errors in Mermaid diagrams within Markdown files |
| homepage | |
| repository | https://github.com/sopaco/mermaid-fixer |
| max_upload_size | |
| id | 1858123 |
| size | 961,586 |
๐ง High-performance AI-driven Mermaid diagram syntax fixer built with Rust
๐ Automatically detects and fixes syntax errors in Mermaid diagrams within Markdown files
๐ Help me develop this software better by sponsoring on GitHub
Mermaid Fixer is a high-performance AI-driven tool that automatically detects and fixes syntax errors in Mermaid diagrams within Markdown files. Built with Rust for performance and reliability, Mermaid Fixer helps teams maintain accurate and valid Mermaid diagrams with minimal effort.
Mermaid Fixer employs a multi-stage workflow combining static syntax validation with AI-powered intelligent fixing. The system render mermaid in a JS sandbox environment to validate sytax correctnessโ and integrates with large language models (LLMs) to intelligently repair broken diagrams while preserving their original intent and structure.
๐ For:
โค๏ธ Like Mermaid Fixer? Star it ๐ or Sponsor Me! โค๏ธ
![]() |
![]() |
The Mermaid diagram dilemma:
Mermaid Fixer solves this by:
Mermaid Fixer's processing workflow is divided into six distinct stages: scanning, extraction, validation, fixing, re-validation, and saving. Each stage is optimized for performance and accuracy.
flowchart TD
A[Directory Scanner] --> B[Markdown Parser]
B --> C[Mermaid Extractor]
C --> D[Syntax Validator]
D --> E{Valid?}
E -->|Yes| F[Skip Block]
E -->|No| G[AI Fixer]
G --> H[Re-validate]
H --> I{Fixed?}
I -->|Yes| J[Update Content]
I -->|No| K[Log Error]
F --> L[Next Block]
J --> L
K --> L
L --> M{More Blocks?}
M -->|Yes| D
M -->|No| N[Save File]
graph LR
subgraph Input Phase
A[CLI Args] --> B[Config Loader]
B --> C[Directory Scanner]
end
subgraph Processing Phase
C --> D[Markdown Scanner]
D --> E[Mermaid Extractor]
E --> F[Syntax Validator]
F --> G[AI Fixer]
end
subgraph Output Phase
G --> H[File Writer]
H --> I[Statistics Reporter]
end
cargo install mermaid-fixer
After installation, you can use mermaid-fixer command directly:
mermaid-fixer --help
git clone https://github.com/sopaco/mermaid-fixer.git
cd mermaid-fixer
cargo build --release
target/release directory.Mermaid Fixer provides a command-line interface for fixing Mermaid diagrams. Here are some basic usage examples:
# Fix Mermaid diagrams in current directory
mermaid-fixer -d .
# Scan specific directory
mermaid-fixer -d /path/to/your/docs
# Dry run (detect only, no fixes)
mermaid-fixer -d ./docs --dry-run
# Verbose output
mermaid-fixer -d ./docs --verbose
Create a config.toml file in your project root:
[llm]
provider = "openai"
model = "gpt-4"
api_key = "your-api-key-here" # or set via environment variable
max_tokens = 4000
temperature = 0.1
[mermaid]
timeout_seconds = 30
max_retries = 3
# Custom LLM configuration
mermaid-fixer -d ./docs --llm-provider openai --llm-model gpt-5-mini --max-tokens 8192
# Custom and retries
mermaid-fixer -d ./docs --max-retries 5
# Custom config file
mermaid-fixer -d ./docs --config custom-config.toml
-d, --directory <DIR>: Target directory to scan (required)-c, --config <FILE>: Configuration file path (default: config.toml)--dry-run: Detect issues only, don't perform fixes-v, --verbose: Enable detailed logging output--llm-provider <PROVIDER>: LLM provider (openai)--llm-model <MODEL>: LLM model name--llm-api-key <KEY>: LLM API key--llm-base-url <URL>: LLM API base URL--max-tokens <NUM>: Maximum token count--temperature <NUM>: Temperature parameter (0.0-1.0)--timeout-seconds <NUM>: Mermaid validation timeout (seconds)--max-retries <NUM>: Maximum retry attempts-h, --help: Show help information-V, --version: Show version information.md and .markdown filesAfter processing, Mermaid Fixer provides comprehensive statistics:
graph TD
A[่ทๅๆฐๆฎ] --> B{้ช่ฏๅๅบ็ถๆ(status)}
B -- "ๆฏ" --> C[่ฎฐๅฝๆๆฌไธ่ๆถ]
B -- "ๅฆ" --> D[้่ฏฏๅค็]
graph TD
A[่ทๅๆฐๆฎ] --> B{้ช่ฏๅๅบ็ถๆ_Status}
B -- "ๆฏ" --> C[่ฎฐๅฝๆๆฌไธ่ๆถ]
B -- "ๅฆ" --> D[้่ฏฏๅค็]
graph LR
Astart --> Bprocess --> Cend
flowchart TD
A --> B
B -- "ๆๅ" --> C
B -- "ๅคฑ่ดฅ" --> D
--dry-run mode first on important documentsnode_modules, target, etc.)Enable verbose logging for detailed troubleshooting:
mermaid-fixer -d ./docs --verbose
Help improve Mermaid Fixer by reporting bugs or submitting feature requests through GitHub Issues.
MIT.
๐ Help me develop this software better by sponsoring on GitHub
An experienced software developer passionate about developer tools and automation. Currently focused on building high-performance tools that improve developer productivity and code quality.
GitHub: sopaco