Automatically identify architecture/flowchart code blocks in Markdown documents, render them as images, and replace them.
Diagram TypeLanguage IdentifierLocal RendererOnline RendererMermaidmermaid, mmdmmdc CLImermaid.inkGraphvizgraphviz, dot, gvgraphviz Python-PlantUMLplantuml, pumlJava jarplantuml.com
Before first use, please install Python dependencies:
bash
# Install dependencies
pip install -r {baseDir}/script/requirements.txt
Optional dependencies (install as needed):
bash
# Mermaid local rendering (recommended)
npm install -g @mermaid-js/mermaid-cli
# Graphviz (for Graphviz diagrams)
# macOS: brew install graphviz
# Ubuntu: sudo apt-get install graphviz
# PlantUML local rendering
# 1. Install Java
# 2. Download plantuml.jar
# 3. Set environment variable: export PLANTUML_JAR=/path/to/plantuml.jar
Note: If local rendering tools are not installed, the system will automatically use online APIs for rendering (requires internet connection).
⚠️ Privacy Warning: Online rendering sends diagram source code to third-party services:
- Mermaid →
mermaid.ink- PlantUML →
plantuml.comDo not include sensitive information (e.g., passwords, keys, internal architecture details) in diagrams. It is recommended to install local rendering tools to avoid data leakage.
bash
# Basic usage
python3 {baseDir}/script/main.py document.md
# Specify output file
python3 {baseDir}/script/main.py document.md -o output.md
# Set confidence threshold
python3 {baseDir}/script/main.py document.md --threshold 0.7
# Output SVG format
python3 {baseDir}/script/main.py document.md --format svg
# Do not preserve source code
python3 {baseDir}/script/main.py document.md --no-preserve
# Detailed logs
python3 {baseDir}/script/main.py document.md -v
python
import sys
sys.path.insert(0, '{baseDir}/script')
from main import create_skill
# Create SKILL instance
config = {
'confidence_threshold': 0.6,
'output_format': 'png',
'preserve_source': True,
}
skill = create_skill(config)
# Execute
result = skill.execute(
input_file='document.md',
output_file='output.md'
)
print(result)
ParameterTypeDefaultDescriptionconfidence_thresholdfloat0.6Diagram identification confidence threshold (0-1)output_formatstringpngOutput image format (png/svg)preserve_sourceboolTrueWhether to preserve original diagram code
Uses a multi-stage filter system:
mermaid, graphviz, plantuml, etc.Before processing:
markdown
```mermaid
graph TD
A[Start] --> B[Process]
B --> C[End]
```
After processing:
markdown

<!-- Original diagram code -->
<!--
```mermaid
graph TD
A[Start] --> B[Process]
B --> C[End]
-->
text
## File Structure
{baseDir}/ ├── SKILL.md # This file ├── script/ │ ├── main.py # Main entry point │ ├── core.py # Core logic │ └── requirements.txt # Python dependencies └── README.md # Detailed documentation
text