Mind Elixir Plaintext Format by ssshooter/mind-elixir-core
npx skills add https://github.com/ssshooter/mind-elixir-core --skill 'Mind Elixir Plaintext Format'此技能解释了 Mind Elixir 纯文本格式规范,以及如何在它与 Mind Elixir JSON 数据结构之间进行转换。纯文本格式非常适合人工编辑、AI 生成和流式传输场景。
纯文本格式使用基于缩进的语法,类似于 Markdown 列表。每一行代表思维导图中的一个节点,缩进(每级 2 个空格)定义了层级关系。
- Root Node
- Child Node 1
- Child Node 1-1
- Child Node 1-2
- Child Node 2
- Child Node 2-1
关键规则:
- 开头(短横线后跟一个空格)- 开头,后跟一个空格和主题文本使用 [^id] 语法为节点分配自定义 ID,以便进行交叉引用:
- Root
- Node A [^id1]
- Node B [^id2]
格式: [^customId] 放在主题文本的末尾。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
使用 > 前缀和箭头语法在节点之间创建连接:
- Root
- Node A [^id1]
- Node B [^id2]
- > [^id1] (10,20) <-Link Label-> (-10,-20) [^id2]
格式: > [^sourceId] (delta1X,delta1Y) <-Label-> (delta2X,delta2Y) [^targetId]
(delta1X,delta1Y):控制点相对于起始节点的偏移量。(delta2X,delta2Y):控制点相对于结束节点的偏移量。[!TIP] 可选坐标:当手动编写或生成纯文本(例如通过 AI)时,可以省略
(x,y)坐标。Mind Elixir 在渲染时会自动计算默认的平衡偏移量。但是,当您将数据导回纯文本时,这些坐标将被包含在内,以保留在 UI 中进行的任何手动调整。
- Root
- Node A [^id1]
- Node B [^id2]
- > [^id1] >-Forward Link-> [^id2]
格式:
> [^sourceId] >-Label-> [^targetId]使用类似 JSON 的语法应用内联样式:
- Root
- Styled Node {"color": "#e87a90"}
- Another Node {"color": "#3298db", "background": "#ecf0f1"}
格式: {"property": "value", "property2": "value2"} 放在主题文本的末尾。
常用属性:
color:文本颜色(十六进制代码)background:背景颜色(十六进制代码)fontSize:字体大小(数字作为字符串,例如 "16")创建摘要节点,以视觉方式分组之前的同级节点:
- Root
- Node 1
- Node 2
- Node 3
- } Summary of all above nodes
格式:
} 摘要文本 - 汇总所有之前的同级节点
}:N 摘要文本 - 汇总前 N 个同级节点(例如,}:2 表示最后 2 个节点)
- Project Planning
- Phase 1: Research [^phase1]
- Market Analysis {"color": "#3298db"}
- Competitor Study {"color": "#3298db"}
- }:2 Research Summary
- Phase 2: Development [^phase2]
- Frontend {"color": "#2ecc71"}
- Backend {"color": "#2ecc71"}
- Testing {"color": "#f39c12"}
- } Development Summary
- Phase 3: Launch [^phase3]
- Marketing
- Deployment
- > [^phase1] (50,0) >-Leads to-> (-50,0) [^phase2]
- > [^phase2] >-Leads to-> [^phase3]
Mind Elixir 提供了一个内置的转换器用于解析纯文本:
import { plaintextToMindElixir } from 'mind-elixir/plaintextConverter'
const plaintext = `
- Root Node
- Child 1
- Child 2
`
const mindElixirData = plaintextToMindElixir(plaintext)
// 返回 MindElixirData 对象,可用于 mind.init() 或 mind.refresh()
您也可以将现有的思维导图转换回纯文本格式,这对于导出和保存数据非常有用:
import { mindElixirToPlaintext } from 'mind-elixir/plaintextConverter'
const mindElixirData = mind.getAllData()
const plaintext = mindElixirToPlaintext(mindElixirData)
// 返回包含纯文本格式思维导图的字符串
import MindElixir from 'mind-elixir'
import { plaintextToMindElixir } from 'mind-elixir/plaintextConverter'
// 1. 解析纯文本
const plaintext = `
- My Mind Map
- Topic 1
- Subtopic 1.1
- Subtopic 1.2
- Topic 2
`
const data = plaintextToMindElixir(plaintext)
// 2. 初始化 Mind Elixir
const mind = new MindElixir({
el: '#map',
direction: MindElixir.RIGHT,
})
mind.init(data)
纯文本格式非常适合大语言模型生成:
// 给 AI 的提示示例
const prompt = `
Generate a mind map in plaintext format about "Web Development".
Use this format:
- Root Topic
- Subtopic 1
- Detail 1.1
- Subtopic 2
`
// 然后解析 AI 的响应
const aiResponse = await callAI(prompt)
const data = plaintextToMindElixir(aiResponse)
mind.refresh(data)
将思维导图存储为 .txt 或 .md 文件:
// 从文件加载
const response = await fetch('/mindmaps/project.txt')
const plaintext = await response.text()
const data = plaintextToMindElixir(plaintext)
mind.init(data)
纯文本格式对于版本控制来说易于合并:
# 在 Git 中易于 diff 和 merge
git diff mindmap.txt
始终将解析包装在 try-catch 块中:
function safeParse(plaintext: string): MindElixirData | null {
try {
return plaintextToMindElixir(plaintext)
} catch (error) {
console.error('Parse error:', error)
// 返回备用数据
return {
nodeData: {
id: 'root',
topic: 'Parse Error',
children: []
}
}
}
}
| 功能 | 语法 | 示例 |
|---|---|---|
| 节点 | - 主题 | - My Node |
| 带 ID 的节点 | - 主题 [^id] | - Node A [^id1] |
| 带样式的节点 | - 主题 {"prop": "value"} | - Node {"color": "#ff0000"} |
| 双向链接 | > [^id1] (x,y) <-标签-> (x,y) [^id2] | > [^a] (10,20) <-connects-> (-10,-20) [^b] |
| 正向链接 | > [^id1] (x,y) >-标签-> (x,y) [^id2] | > [^a] (10,20) >-leads to-> (-10,-20) [^b] |
| 摘要(全部) | } 摘要文本 | } Overview |
| 摘要(N 个节点) | }:N 摘要文本 | }:3 Last three items |
import type { MindElixirData, NodeObj } from 'mind-elixir'
// 转换器函数
function plaintextToMindElixir(plaintext: string): MindElixirData
function mindElixirToPlaintext(data: MindElixirData): string
每周安装次数
–
代码仓库
GitHub 星标数
3.0K
首次出现
–
安全审计
This skill explains the Mind Elixir plaintext format specification and how to convert between it and the Mind Elixir JSON data structure. The plaintext format is ideal for human editing, AI generation, and streaming scenarios.
The plaintext format uses indentation-based syntax similar to Markdown lists. Each line represents a node in the mind map, and indentation (2 spaces per level) defines the hierarchy.
- Root Node
- Child Node 1
- Child Node 1-1
- Child Node 1-2
- Child Node 2
- Child Node 2-1
Key Rules:
- (dash followed by space)- followed by a space and the topic textAssign custom IDs to nodes for cross-referencing using [^id] syntax:
- Root
- Node A [^id1]
- Node B [^id2]
Format: [^customId] at the end of the topic text.
Create connections between nodes using the > prefix and arrow syntax:
- Root
- Node A [^id1]
- Node B [^id2]
- > [^id1] (10,20) <-Link Label-> (-10,-20) [^id2]
Format: > [^sourceId] (delta1X,delta1Y) <-Label-> (delta2X,delta2Y) [^targetId]
(delta1X,delta1Y): Offset of the control point from the start node.(delta2X,delta2Y): Offset of the control point from the end node.[!TIP] Optional Coordinates : When manually writing or generating plaintext (e.g., via AI), you can omit the
(x,y)coordinates. Mind Elixir will automatically calculate default balanced offsets when rendering. However, when you export data back to plaintext, these coordinates will be included to preserve any manual adjustments made in the UI.
- Root
- Node A [^id1]
- Node B [^id2]
- > [^id1] >-Forward Link-> [^id2]
Formats:
> [^sourceId] >-Label-> [^targetId]Apply inline styles using JSON-like syntax:
- Root
- Styled Node {"color": "#e87a90"}
- Another Node {"color": "#3298db", "background": "#ecf0f1"}
Format: {"property": "value", "property2": "value2"} at the end of the topic text.
Common Properties:
color: Text color (hex code)background: Background color (hex code)fontSize: Font size (number as string, e.g., "16")Create summary nodes that visually group previous siblings:
- Root
- Node 1
- Node 2
- Node 3
- } Summary of all above nodes
Formats:
} Summary text - Summarizes all previous siblings
}:N Summary text - Summarizes the previous N siblings (e.g., }:2 for last 2 nodes)
- Project Planning
- Phase 1: Research [^phase1]
- Market Analysis {"color": "#3298db"}
- Competitor Study {"color": "#3298db"}
- }:2 Research Summary
- Phase 2: Development [^phase2]
- Frontend {"color": "#2ecc71"}
- Backend {"color": "#2ecc71"}
- Testing {"color": "#f39c12"}
- } Development Summary
- Phase 3: Launch [^phase3]
- Marketing
- Deployment
- > [^phase1] (50,0) >-Leads to-> (-50,0) [^phase2]
- > [^phase2] >-Leads to-> [^phase3]
Mind Elixir provides a built-in converter for plaintext parsing:
import { plaintextToMindElixir } from 'mind-elixir/plaintextConverter'
const plaintext = `
- Root Node
- Child 1
- Child 2
`
const mindElixirData = plaintextToMindElixir(plaintext)
// Returns MindElixirData object ready for mind.init() or mind.refresh()
You can also convert an existing mind map back to the plaintext format, which is useful for exporting and saving data:
import { mindElixirToPlaintext } from 'mind-elixir/plaintextConverter'
const mindElixirData = mind.getAllData()
const plaintext = mindElixirToPlaintext(mindElixirData)
// Returns a string containing the mind map in plaintext format
import MindElixir from 'mind-elixir'
import { plaintextToMindElixir } from 'mind-elixir/plaintextConverter'
// 1. Parse plaintext
const plaintext = `
- My Mind Map
- Topic 1
- Subtopic 1.1
- Subtopic 1.2
- Topic 2
`
const data = plaintextToMindElixir(plaintext)
// 2. Initialize Mind Elixir
const mind = new MindElixir({
el: '#map',
direction: MindElixir.RIGHT,
})
mind.init(data)
The plaintext format is ideal for LLM generation:
// Prompt example for AI
const prompt = `
Generate a mind map in plaintext format about "Web Development".
Use this format:
- Root Topic
- Subtopic 1
- Detail 1.1
- Subtopic 2
`
// Then parse the AI response
const aiResponse = await callAI(prompt)
const data = plaintextToMindElixir(aiResponse)
mind.refresh(data)
Store mind maps as .txt or .md files:
// Load from file
const response = await fetch('/mindmaps/project.txt')
const plaintext = await response.text()
const data = plaintextToMindElixir(plaintext)
mind.init(data)
The plaintext format is merge-friendly for version control:
# Easy to diff and merge in Git
git diff mindmap.txt
Always wrap parsing in try-catch blocks:
function safeParse(plaintext: string): MindElixirData | null {
try {
return plaintextToMindElixir(plaintext)
} catch (error) {
console.error('Parse error:', error)
// Return fallback data
return {
nodeData: {
id: 'root',
topic: 'Parse Error',
children: []
}
}
}
}
| Feature | Syntax | Example |
|---|---|---|
| Node | - Topic | - My Node |
| Node with ID | - Topic [^id] | - Node A [^id1] |
| Node with Style | - Topic {"prop": "value"} | - Node {"color": "#ff0000"} |
| Bidirectional Link | > [^id1] (x,y) <-Label-> (x,y) [^id2] |
import type { MindElixirData, NodeObj } from 'mind-elixir'
// Converter functions
function plaintextToMindElixir(plaintext: string): MindElixirData
function mindElixirToPlaintext(data: MindElixirData): string
Weekly Installs
–
Repository
GitHub Stars
3.0K
First Seen
–
Security Audits
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
109,600 周安装
> [^a] (10,20) <-connects-> (-10,-20) [^b] |
| Forward Link | > [^id1] (x,y) >-Label-> (x,y) [^id2] | > [^a] (10,20) >-leads to-> (-10,-20) [^b] |
| Summary (all) | } Summary text | } Overview |
| Summary (N nodes) | }:N Summary text | }:3 Last three items |