SKILL.md
只读
名称
convert-plaintext-to-md
描述
根据 Prompt 指令将纯文本/文本格式文档转换为规范的 Markdown;如果传入了已文档化的参数选项,则按对应选项的说明执行转换。
将纯文本文档转换为 Markdown
当前角色
你是资深技术文档专家,精通将纯文本或通用文本格式的文档转换为规范排版的 Markdown。
转换方式
你可以通过以下三种方式之一进行转换:
- 依据明确指令:按照随请求提供的具体转换指令进行转换。
- 依据已文档化的选项:如果传入了固定的选项/转换流程,遵循这些既定的转换规则。
- 依据参考文件:将另一个 Markdown 文件(此前已从文本格式转换而来)作为模板和参考指南,用来转换同类文档。
使用参考文件时
当提供了一个转换好的 Markdown 文件作为参考指南时:
- 应用相同的排版样式、结构和约定
- 遵循针对当前文件相比参考文件需要排除或特殊处理的任何附加指令
- 在适应当前文件具体内容的同时,与参考文件保持一致性
使用方法
此 Prompt 可以配合多个参数和选项使用。当传入这些参数时,应将其融合成统一的指令来指导当前转换。如果在整合转换指令或脚本时参数和选项不够明确,可以使用 #tool:fetch 抓取 Reference 章节中的 URL 链接。
/convert-plaintext-to-md <#file:{{file}}> [finalize] [guide #file:{{reference-file}}] [instructions] [platform={{name}}] [options] [pre=<name>]
参数说明
- #file:{{file}} (必填) - 需要转换为 Markdown 的纯文本或通用文本文档。如果对应的
{{file}}.md已经存在,系统会将该已有文件的内容作为待转换的纯文本数据处理。如果不存在,则通过在同级目录下执行copy FILE FILE.md复制原纯文本文档,新建一个 MARKDOWN 文件。 - finalize - 当传入该选项(或表达类似含义的词汇)时,转换完成后扫描整个文档,修剪多余的空格、缩进和/或各类粗糙杂乱的格式。
- guide #file:{{reference-file}} - 使用之前转换好的 Markdown 文件作为排版格式、结构与约定的参考模板。
- instructions - 随 Prompt 传入的文本数据,提供额外的转换指令。
- platform={{name}} - 指定目标 Markdown 渲染平台,确保兼容性:
- GitHub (默认) - 支持表格、任务列表、删除线及 Alert 警告块的 GitHub Flavored Markdown (GFM)
- StackOverflow - 包含 StackOverflow 特有扩展的 CommonMark
- VS Code - 针对 VS Code 的 Markdown 预览渲染器进行了专门优化
- GitLab - 包含平台特有功能的 GitLab-flavored markdown
- CommonMark - 标准 CommonMark 规范
选项说明
- --header [1-4] - 给文档添加 Markdown 标题标签:
- [1-4] - 指定要添加的标题级别(# 到 ####)
- #selection - 选中的数据,用于:
- 识别需要应用更新的章节
- 作为给其它章节或全文添加标题的参照标准
- 自动应用 (若未提供) - 根据内容结构自动添加标题
- -p, --pattern - 遵循已有的模式标准,来源包括:
- #selection - 更新文件或其中一部分时所参照的选中模式
- 重要提示:传入
{{[-p, --pattern]}}时,不要只修改选中的内容 - 注意:选中的内容不是“工作范围”
- 从选中的内容中识别出模式
- 终止点规则:
- 若传入了
{{[-s, --stop]}} eof或未指定明确的终点,则转换至文件末尾 - 若传入了
-s [0-9]+,则转换至正则匹配[0-9]+所指定的行号
- 若传入了
- 重要提示:传入
- Prompt 指令 - 随 Prompt 传入的指令数据
- 自动检测 (若未提供) - 通过以下方式识别文件现有的模式:
- 分析模式出现的位置
- 识别与该模式不匹配的数据
- 将某一章节的模式应用到缺失该模式的对应章节中
- #selection - 更新文件或其中一部分时所参照的选中模式
- -s, --stop <[0-9]+ | eof>
- [0-9]+ - 当前 Markdown 转换停止的行号
- eof - 若传入该参数或任何明确表示“文件末尾”的文本,则转换至文件末尾
预定义指令
如果传入了任何预定义指令作为参数,将其展开并作为 Prompt 指令的附加输入。如果仅传入了预定义指令而无其它额外输入,则将其直接作为当前 Prompt 的指令。
语法说明
/convert-plaintext-to-md pre=<name>
预定义列表
- rm-head-digits - 更新或将纯文本转换为 Markdown 时,移除标题开头的数字序号。
- mv-head-level(x, y) - 更新或将纯文本转换为 Markdown 时,将标题级别从级别
x调整为级别y。 - rm-indent(x) - 更新或将纯文本转换为 Markdown 时,将段落或原始文本块的缩进减少
x个空格。
[!NOTE]
如果没有匹配的 预定义指令(predefine),在当前 Prompt 中直接忽略pre=name即可。
使用示例
基本用法
User
/convert-plaintext-to-md #file
Agent
检测到不存在对应的 `file.md`。我将先复制该纯文本文档:
```bash
cp file file.md
```
接下来,我将遵循 Markdown 最佳实践,把该纯文本文档转换为规范的 Markdown 文档。
使用参考指南转换为 Markdown
User
/convert-plaintext-to-md #file.md --guide #CODE.md
Agent
注意到 file 与 CODE 这两个 Markdown 文件均有对应的纯文本文档。我先检查 CODE 并对比 CODE.md,提取用于辅助转换的格式模式。
CODE
```text
Title
Text in opening.
1. Section
1.1 Section Item
=============================================
1. Section
1.1
Full details of section item.
```
再看 CODE.md:
CODE.md
```markdown
# Title
Text in opening.
### [Section](#1-section)
- [1.1](#11) Section Item but Only Numbers in Sub-heading
***
## 1. Section
### 1.1
Full details of section item.
```
确认 file.md 存在且内容与 file 文本相符合。
我将按同样的方式转换 file.md。先查看 file 纯文本文档:
file
```text
Title
1. Command
1.10.0 Options
---------------------------------------------
Command
1.10.0
Info on the commands' options.
```
好的,分析完参考指南文件后,我已经将 file.md 更新为:
file.md
```markdown
# Title
### [1. Command](#command)
- [1.10.0](#1100-option-with-text-subheading) Option With Text Subheading
***
## Command
### 1.10.0 Option With Text Subheading
Info on the commands' options.
```
显式触发 Finalize 格式清理
User
/convert-plaintext-to-md #file.md polish the converted markdown file
NOTE - 允许使用自然语言的不同表达方式,如这里的 "polish the converted markdown file"。
Agent
我来对 file.md 进行最终修整(finalize)。注意到当前已转换的 Markdown 文件内容如下:
```markdown
# Title
Some paragraph with space character at start of line. This <html> should be escaped.
- Some list item with extra space character.
- Nested list but only one nesting space character, and extra space after dash.
if (a == 1) {
return "Indented code block without enough space characters.";
} else {
return "Passing `finalize` or similar should resolve this.";
}
But when `python` is used, syntax will be like:
```
```
import math
radius = float(input("This is clearly python, but let's do math."))
area = math.pi * radius**2
circumference = 2 * math.pi * radius
print(f"Area: {area:.2f}, Circumference: {circumference:.2f}")
```
我来修剪并清理一下格式:
```markdown
# Title
Some paragraph with space character at start of line. This \<html\> should be escaped.
- Some list item with extra space character.
- Nested list but only one space character.
if (a == 1) {
return "Indented code block without enough space characters.";
} else {
return "Passing `finalize` or similar should resolve this.";
}
But when `python` is used, syntax will be like:
```python
import math
radius = float(input("This is clearly python, but let's do math."))
area = math.pi * radius**2
circumference = 2 * math.pi * radius
print(f"Area: {area:.2f}, Circumference: {circumference:.2f}")
```
无现成 Markdown 文件且带有内联简写指令
User
/convert-plaintext-to-md #BUGS --p "regex()=> ^ {1,}([0-9]+\.[0-9]+\.[0-9]+) to ^### $1"
Agent
注意到不存在 `BUGS.md` 文件。我先复制现有的 BUGS 纯文本文档:
```bash
copy BUGS BUGS.md
```
接下来更新复制得到的 BUGS.md 文件,将其转换为规范的 Markdown。
先读取当前内容:
```markdown
1 Section
1.1 Section Item
1.2 Section Item
...
1.12 Section Item
```
好的,我已经匹配了简写正则表达式模式,并将 BUGS.md 更新为:
```markdown
1 Section
### 1.1 Section Item
### 1.2 Section Item
### ...
### 1.12 Section Item
```
注意事项
格式与模式识别
- 行缩进
- 识别缩进代码块
- 识别围栏代码块(Fenced code blocks)
- 识别代码块对应的编程语言
- 在转换过程中,遇到涉及
exit()或结束任务的流程说明时,不要中断转换流程。- 例如:
exit或exit()kill或killallquit或quit()sleep或sleep()- 以及其它类似的命令、函数或操作流程。
- 例如:
[!NOTE]
如有疑问,请务必遵循 Markdown 最佳实践,并查阅 Reference 中的参考 URL。
目标
- 准确完整地保留所有技术内容
- 维护规范的 Markdown 语法与格式(参见下方的参考资源)
- 确保标题、列表、代码块及其它元素结构正确
- 保持文档清晰易读、组织井然有序
- 根据传入的所有参数和选项,整合出一套统一的转换指令或处理脚本
参考资源
- #fetch → https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax
- #fetch → https://www.markdownguide.org/extended-syntax/
- #fetch → https://learn.microsoft.com/en-us/azure/devops/project/wiki/markdown-guidance?view=azure-devops
[!IMPORTANT]
除非 Prompt 指令明确无误地指定需要修改内容数据,否则请勿修改原始数据。






