txt-to-markdown

Converts .txt plain text (occasionally with images) into standardized CommonMark markdown and uploads images to the xiaona.cc.cd image host (fallback to local save on failure), outputting a same-named .md file. Used when the user supplies a .txt file path and requests conversion to md/markdown/notes or uses trigger phrases like “txt to md”, “convert to markdown”, “make this md”; also suitable for turning copied plain text, drafts, or notes into a clear, editable markdown document.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "txt-to-markdown" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-a8f3125492b50b3038a403e26f46edd8ae5b7c0b983369424f05697628db16f5. Verify the upstream source and version against https://skillhub.cn/skills/user_a3ed06bc/txt-to-markdown before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Converts .txt plain text (occasionally with images) into standardized CommonMark markdown and uploads images to the xiaona.cc.cd image host (fallback to local save on failure), outputting a same-named .md file. Used when the user supplies a .txt file path and requests conversion to md/markdown/notes or uses trigger phrases like “txt to md”, “convert to markdown”, “make this md”; also suitable for turning copied plain text, drafts, or notes into a clear, editable markdown document.

0 Downloads

Introduction source: third_party · user_a3ed06bc · 1.1.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Translation pending; see source documentation.
Inputs and outputs
Translation pending; see source documentation.
Software, accounts and paid services
Not specified in the source documentation.
Limits and differences
Not specified in the source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: txt-to-markdown
slug: txt-to-markdown
version: 1.1.0
displayName: TXT 转 Markdown
description: 把 .txt 纯文本(偶尔夹带图片)规范化整理成标准 CommonMark markdown,并把图片上传到 xiaona.cc.cd 图床(失败则本地兜底),输出为同名 .md 文件。当用户给出 .txt 文件路径并要求"转成 md / markdown / 整理成笔记",或触发词"txt转md""转markdown""把这段改成md"时使用;也适用于把复制来的纯文本、草稿、笔记统一成结构清晰、可编辑的 markdown 文档。
agent_created: true

Txt To Markdown

Overview

将纯文本(.txt)内容重写为结构清晰、符合 CommonMark 规范的 markdown,并把零散图片上传到图床(或本地兜底),最终落盘为同名 .md 文件。面向"手头有 txt 笔记 / 草稿 / 复制来的文字,想变成干净 markdown"的场景。

When To Use

  • 用户给出 .txt 文件路径,要求"转成 markdown / 存成 md"
  • 触发词 / 意图:"txt转md"、"转markdown"、"整理成笔记"、"把这段改成md"
  • 输入以纯文本为主,可能同目录附带图片,或文本内提到了图片路径

图床(图片托管)

默认把图片上传到「猫羽雫工作室文件托管」图床:

  • 上传接口:POST https://xiaona.cc.cd/api/file
  • 请求:multipart/form-data,文件字段名 file(可选 title)
  • 鉴权:无需(token 免鉴权,公开 API)
  • 响应:返回 JSON,取 file.slug;图片公开访问地址 = https://xiaona.cc.cd/api/file/{slug}
  • 限制:图片 ≤ 10 MB(视频 30 MB / 文本 2 MB);超大图片会被拒,走本地兜底
  • ⚠️ 隐私:该图床免登录、即时公开,上传即意味着图片变成任何人可访问的公开 URL。仅上传可公开的图片;涉密 / 隐私图片不要传,改用 --no-upload 本地模式。

Workflow

Step 1 — 读取并理解源文本

用 Read 工具读取 .txt 全文。通读后判断结构:哪些是标题、哪些是段落、哪些是列表 / 代码 / 引用 / 图片指向。

Step 2 — 规范化成 markdown

硬约束:动手写 .md 之前,必须先 Read references/markdown-spec.md 全文,未读禁止输出。

遵循 references/markdown-spec.md 的规范,把纯文本重写为 markdown:

  • 标题层级、列表、代码块、引用、链接、粗体按规范处理
  • 段落之间空一行
  • 只做结构规范化,不擅自润色、翻译、扩写原文;信息零丢失

Step 3 — 处理图片

先判定图片来源与引用方式,再决定插入位置。插入位置的优先级从高到低:

1. 用户占位符(最高优先,绝不放文末) 源 txt 中出现用户手写的图片占位标记,常见写法:

  • 此处放置图片xxx / 放置图片:xxx / 图片xxx / [图xxx] 其中 xxx 是图片标识,用来匹配附件 / 同目录里的图片文件(如 img_xxx.png、xxx.png)。
  • 处理方式:把占位符就地替换为 ![alt](图片地址),图片就插在用户写占位符的那个位置。
  • 匹配不到对应文件时,保留占位符并 stderr 警告,不要静默丢弃或挪到文末。
  • 这一步先于一切:只要文本里有占位符,就按占位符走,不要退化到下面的兜底逻辑。

2. 已有标准引用(情形 A) 文本里已是 ![...](...) 或写了图片路径 / 文件名(如 图片1: C:\...\a.png、见 a.jpg):

  • 图床 / 网络 URL 原样保留
  • 本地路径交给 upload_images.py 上传并改写为图床 URL 引用

3. 无引用兜底(情形 B)——仅当文本里完全没有占位符也没有任何图片引用时 典型场景:纯邮件正文 + 附件图片,正文一个占位符都没写。

  • 按附件 / 同目录图片的文件名顺序(img_001、img_002…)依次插到文档各段之后,均匀分布,不要堆文末。
  • 实在无法对应到段落时,才退化为文末 ## 附图,并明确告知用户"以下图片未能就近插入,已集中放文末"。

上传 / 离线

  • 默认行为:上传图床。运行 scripts/upload_images.py <txt路径>,逐个上传并打印 ![alt](图床URL);单张失败自动降级本地 <basename>_images/ 相对引用。
  • 离线模式:用户要求"不上传 / 本地"或图床不可用,改用 scripts/collect_images.py(或 upload_images.py --no-upload),图片留本地 <basename>_images/,md 用相对路径引用。

Step 4 — 输出 .md 文件

  • 输出位置:源 txt 同目录,文件名去掉 .txt 后缀、加 .md(如 note.txt → note.md)
  • 若源 txt 位于个人目录(桌面 / 下载 / 文档等),不要默认往工作区外乱写;先询问用户把 .md 存到哪
  • 图片默认走图床 URL;本地兜底时放在 <basename>_images/ 子目录,md 内用相对路径引用
  • 用 Write 工具写出最终 .md

输出自检清单(每次写完 .md 后逐项核对)

  • [ ] 标题层级是否连续、无跳级
  • [ ] 段落之间是否都有空行
  • [ ] 每个占位符 / 图片引用是否都已替换为实际 ![...](...)
  • [ ] 每张图片的地址是否可访问(图床 URL 或本地相对路径存在)
  • [ ] 是否残留未处理的 此处放置图片xxx 等占位符
  • [ ] 信息是否零丢失(原文内容无遗漏)

Resources

scripts/upload_images.py(默认)

零依赖(仅 Python 标准库)。把图片上传到图床并打印 markdown 引用。用法:

python scripts/upload_images.py <txt_path> [--no-upload] [--print-only]
  • 扫描 txt 同目录及其直接子目录下的图片(png / jpg / jpeg / gif / webp / bmp / svg)
  • 逐个 POST https://xiaona.cc.cd/api/file 上传,取 file.slug 拼出公开 URL
  • 打印 ![<name>](<图床URL>),可直接贴进 md
  • 单张失败自动降级本地 <basename>_images/,并 stderr 注明
  • --no-upload:不联网,等同于本地收集模式
  • --print-only:只打印引用预览,不上传也不复制

scripts/collect_images.py(离线兜底)

零依赖。仅本地收集,不联网。用法:

python scripts/collect_images.py <txt_path> [--images-dir <name>] [--print-only]
  • 扫描图片并复制到 <txt_dir>/<images-dir>/(默认 <basename>_images)
  • 打印相对引用 ![<name>](<relpath>)

references/markdown-spec.md

纯文本 → markdown 的书写规范与判定规则,Step 2 必须遵循。

Current listing version

1.1.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 解决用户将纯文本/草稿/笔记规范化为 markdown 的常见需求
  • 支持图片上传图床与本地兜底,功能闭环完整
  • 适用于广泛用户群体,实用价值高
Trigger Precision90/100

Highlights

  • 触发词覆盖全面(txt转md/转markdown/整理成笔记等)
  • 边界清晰,无明显误触或漏触风险
Structure and Standards95/100

Highlights

  • 步骤划分清晰,有明确的出口条件
  • frontmatter 完整,文档结构规范
  • 包含端到端示例与输出自检清单
Execution Reliability90/100

Highlights

  • 工具来源明确,参数说明清晰
  • 覆盖图床失败、超大图片、隐私等异常场景
  • 不可逆操作有用户确认机制
Evidence Verifiability (mean of the first four)90/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • xiaona.cc.cd

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Not specified in the source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.