← 返回
未分类 中文

Markdown Diagram Renderer

Automatically identify diagram code blocks (Mermaid/Graphviz/PlantUML) in Markdown documents, render them as images, and replace them.
自动识别 Markdown 文档中的图表代码块(Mermaid/Graphviz/PlantUML),渲染为图片并替换。
fireium
未分类 clawhub v1.0.3 1 版本 100000 Key: 无需
★ 1
Stars
📥 529
下载
💾 5
安装
1
版本
#latest

概述

Markdown Diagram Renderer

Automatically identify architecture/flowchart code blocks in Markdown documents, render them as images, and replace them.

Features

  • Smart Identification: Automatically identify Mermaid, Graphviz, and PlantUML diagrams without specific language tags.
  • Multi-backend Rendering: Supports local rendering and online API fallback.
  • Base64 Inline: Images are inlined into Markdown as Base64 encoding, version control friendly.
  • Source Preservation: Optionally keep the original diagram code as comments.

Supported Diagram Types

Diagram TypeLanguage IdentifierLocal RendererOnline Renderer
------------------------------------
Mermaidmermaid, mmdmmdc CLImermaid.ink
Graphvizgraphviz, dot, gvgraphviz Python-
PlantUMLplantuml, pumlJava jarplantuml.com

Getting Started

Before first use, please install Python dependencies:

# Install dependencies
pip install -r {baseDir}/script/requirements.txt

Optional dependencies (install as needed):

# 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.com

>

> Do 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.

Usage

CLI Command Line

# 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

Calling as a Python Module

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)

Configuration Parameters

ParameterTypeDefaultDescription
------------------------
confidence_thresholdfloat0.6Diagram identification confidence threshold (0-1)
output_formatstringpngOutput image format (png/svg)
preserve_sourceboolTrueWhether to preserve original diagram code

Identification Strategy

Uses a multi-stage filter system:

  1. Language Tag Check: Prioritizes identifying mermaid, graphviz, plantuml, etc.
  2. First Line Keyword Matching: Checks for typical declarations at the beginning of code blocks.
  3. Keyword Density Analysis: Counts the frequency of diagram-specific keywords.
  4. Structural Feature Analysis: Detects structural characteristics of diagrams.

Output Example

Before processing:

graph TD

A[Start] --> B[Process]

B --> C[End]

After processing:

![mermaid diagram](data:image/png;base64,iVBORw0KGgo...)

<!-- Original diagram code -->
<!--

graph TD

A[Start] --> B[Process]

B --> C[End]

-->

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

版本历史

共 1 个版本

  • v1.0.3 当前
    2026-03-30 13:50 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-intelligence

ontology

oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 712 📥 243,858
security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,215 📥 266,559
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,358 📥 318,424