Text to Mind Map Skill
This skill converts user-input text, Markdown files, or Txt files into mind map images.
Dependency Installation
CODEBLOCK0
Workflow
CODEBLOCK1
Step 1: text-to-markdown
Use LLM to convert input content into mind map Markdown format according to the following rules:
Rule Specifications:
- - Extract Core Content: Extract key points from broadcast scripts with high information density, concise and clear, without omitting important points
- Reduce Hallucinations: Generated content must come from the input broadcast script; do not fabricate, rewrite, exaggerate, flatter, omit, or produce hallucinations
- Strictly Follow Node Hierarchy: Only one root node, subsequent nodes progress by hierarchy levels
- Support All Basic Markdown Syntax: Bold, code, links, and LaTeX formulas can be embedded in node text
- Output Format Compliance: Strictly follow the format below; do not output any other extraneous content
- Use Appropriate Emoji: Use relevant emojis appropriately to enhance visual expression, but avoid excessive use
- Content Limit: Ensure output content is limited to 300 tokens
- Hierarchy Limit: Mind map generates maximum 4 levels (root node counts as level 1)
Output Format:
CODEBLOCK2
Step 2: markdown-to-html
Use markmap command to convert Markdown to HTML:
CODEBLOCK3
Step 3: html-to-image
Use html-to-image.js to convert HTML to image (default: jpg format):
CODEBLOCK4
Parameter Specifications:
| Parameter | Description |
|---|
| INLINECODE0 | Output format is png (default) |
| INLINECODE1 |
Auto-detect mindmap content size and adapt dimensions |
|
input-html | Input HTML file path |
|
output-image | Output image path |
Execution Steps
- 1. Read user-input text content or file path
- Call LLM to convert content into mind map Markdown format according to the rules above
- Save the generated Markdown to a temporary file (e.g.,
/tmp/mindmap.md) - Execute
markmap --offline --no-open --no-toolbar -o <html_file> <markdown_file> to generate HTML - Execute
node (or bun) scripts/html-to-image.js --auto-fit <html_file> <output-image> to generate PNG image - Inform user of the output image path | If user uses openclaw, send the image to the user as a file
Input Types
- - Directly input text content
- INLINECODE7 file path
- INLINECODE8 file path
Output
- - Generated mind map image file (default: PNG format)
Examples
Example 1:
- - User Input: "How to learn React"
- Output: PNG image of React learning path mind map
Example 2:
- - User Input: "Help me convert this markdown file to a mind map: /path/to/notes.md"
- Output: PNG image of mind map corresponding to notes.md content
文本转思维导图技能
本技能可将用户输入的文本、Markdown文件或Txt文件转换为思维导图图片。
依赖安装
bash
使用 npm
npm install markmap-cli markmap-lib markmap-render puppeteer
使用 bun
bun install markmap-cli markmap-lib markmap-render puppeteer
工作流程
输入内容 → 文本转Markdown → Markdown转HTML → HTML转图片 → 输出图片
→ [如果用户使用openclaw,将图片作为文件发送给用户]
步骤一:文本转Markdown
使用LLM按照以下规则将输入内容转换为思维导图Markdown格式:
规则说明:
- - 提取核心内容: 从文稿中提取信息密度高、简洁明了的关键要点,不遗漏重要内容
- 减少幻觉: 生成内容必须来源于输入的文稿,不得编造、改写、夸大、美化、省略或产生幻觉
- 严格遵循节点层级: 仅有一个根节点,后续节点按层级递进
- 支持所有基础Markdown语法: 节点文本中可嵌入加粗、代码、链接和LaTeX公式
- 输出格式合规: 严格遵循以下格式,不输出任何其他无关内容
- 使用适当表情符号: 适当使用相关表情符号增强视觉表现力,但避免过度使用
- 内容限制: 确保输出内容限制在300个token以内
- 层级限制: 思维导图最多生成4级(根节点算第1级)
输出格式:
markdown
根节点(必须有且仅有一个)
二级节点
三级节点
- - 也支持列表项
- 加粗、代码、链接
- $LaTeX公式$
步骤二:Markdown转HTML
使用markmap命令将Markdown转换为HTML:
bash
markmap --offline --no-open --no-toolbar -o
步骤三:HTML转图片
使用html-to-image.js将HTML转换为图片(默认:jpg格式):
bash
node (或 bun) scripts/html-to-image.js --auto-fit <输入HTML> <输出图片>
参数说明:
| 参数 | 说明 |
|---|
| -t jpg | 输出格式为png(默认) |
| --auto-fit |
自动检测思维导图内容大小并适配尺寸 |
| 输入HTML | 输入HTML文件路径 |
| 输出图片 | 输出图片路径 |
执行步骤
- 1. 读取用户输入的文本内容或文件路径
- 调用LLM按照上述规则将内容转换为思维导图Markdown格式
- 将生成的Markdown保存到临时文件(例如:/tmp/mindmap.md)
- 执行markmap --offline --no-open --no-toolbar -o 生成HTML
- 执行node (或 bun) scripts/html-to-image.js --auto-fit <输出图片>生成PNG图片
- 告知用户输出图片路径 | 如果用户使用openclaw,将图片作为文件发送给用户
输入类型
- - 直接输入文本内容
- .md文件路径
- .txt文件路径
输出
示例
示例一:
- - 用户输入: 如何学习React
- 输出: React学习路径思维导图PNG图片
示例二:
- - 用户输入: 帮我把这个markdown文件转换成思维导图:/path/to/notes.md
- 输出: notes.md内容对应的思维导图PNG图片