- Add infographic_markdown.py (English) and infographic_markdown_cn.py (Chinese) - AI-powered infographic generator using AntV library - Renders SVG on frontend and embeds as Markdown Data URL image - Supports 18+ infographic templates (lists, charts, comparisons, etc.) Docs: - Add plugin README.md and README_CN.md - Add docs detail pages (infographic-markdown.md) - Update docs index pages with new plugin - Add 'JS Render to Markdown' pattern to plugin development guides - Update copilot-instructions.md with new advanced development pattern Version: 1.0.0
4.2 KiB
4.2 KiB
Infographic to Markdown
Version: 1.0.0 | Author: Fu-Jie
AI-powered infographic generator that renders SVG on the frontend and embeds it directly into Markdown as a Data URL image.
Overview
This plugin combines the power of AI text analysis with AntV Infographic visualization to create beautiful infographics that are embedded directly into chat messages as Markdown images.
Key Features
- 🤖 AI-Powered: Automatically analyzes text and selects the best infographic template
- 📊 Multiple Templates: Supports 18+ infographic templates (lists, charts, comparisons, etc.)
- 🖼️ Self-Contained: SVG/PNG embedded as Data URL, no external dependencies
- 📝 Markdown Native: Results are pure Markdown images, compatible everywhere
- 🔄 API Writeback: Updates message content via REST API for persistence
How It Works
graph TD
A[User triggers action] --> B[Python extracts message content]
B --> C[LLM generates Infographic syntax]
C --> D[Frontend JS loads AntV library]
D --> E[Render SVG offscreen]
E --> F[Export to Data URL]
F --> G[Update message via API]
G --> H[Display as Markdown image]
Installation
- Download
infographic_markdown.py(English) orinfographic_markdown_cn.py(Chinese) - Navigate to Admin Panel → Settings → Functions
- Upload the file and configure settings
- Use the action button in chat messages
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
SHOW_STATUS |
bool | true |
Show operation status updates |
MODEL_ID |
string | "" |
LLM model ID (empty = use current model) |
MIN_TEXT_LENGTH |
int | 50 |
Minimum text length required |
MESSAGE_COUNT |
int | 1 |
Number of recent messages to use |
SVG_WIDTH |
int | 800 |
Width of generated SVG (pixels) |
EXPORT_FORMAT |
string | "svg" |
Export format: svg or png |
Supported Templates
| Category | Template | Description |
|---|---|---|
| List | list-grid |
Grid cards |
| List | list-vertical |
Vertical list |
| Tree | tree-vertical |
Vertical tree |
| Tree | tree-horizontal |
Horizontal tree |
| Mind Map | mindmap |
Mind map |
| Process | sequence-roadmap |
Roadmap |
| Process | sequence-zigzag |
Zigzag process |
| Relation | relation-sankey |
Sankey diagram |
| Relation | relation-circle |
Circular relation |
| Compare | compare-binary |
Binary comparison |
| Analysis | compare-swot |
SWOT analysis |
| Quadrant | quadrant-quarter |
Quadrant chart |
| Chart | chart-bar |
Bar chart |
| Chart | chart-column |
Column chart |
| Chart | chart-line |
Line chart |
| Chart | chart-pie |
Pie chart |
| Chart | chart-doughnut |
Doughnut chart |
| Chart | chart-area |
Area chart |
Usage Example
- Generate some text content in the chat (or have the AI generate it)
- Click the 📊 Infographic to Markdown action button
- Wait for AI analysis and SVG rendering
- The infographic will be embedded as a Markdown image
Technical Details
Data URL Embedding
The plugin converts SVG graphics to Base64-encoded Data URLs:
const svgData = new XMLSerializer().serializeToString(svg);
const base64 = btoa(unescape(encodeURIComponent(svgData)));
const dataUri = "data:image/svg+xml;base64," + base64;
const markdownImage = ``;
AntV toDataURL API
// Export as SVG (recommended)
const svgUrl = await instance.toDataURL({
type: 'svg',
embedResources: true
});
// Export as PNG
const pngUrl = await instance.toDataURL({
type: 'png',
dpr: 2
});
Notes
- Browser Compatibility: Requires modern browsers with ES6+ and Fetch API support
- Network Dependency: First use requires loading AntV library from CDN
- Data URL Size: Base64 encoding increases size by ~33%
- Chinese Fonts: SVG export embeds fonts for correct display