md-doc-cleanup

Markdown Document Cleanup — normalizes and organizes long Markdown documents by fixing structural issues such as flattened heading levels, un-nested numbered outlines, inline numbered lists, unformatted bullet-point items, and missing clickable table of contents. Use when the user requests: rebuilding Markdown heading hierarchy, splitting inline numbered lists into separate lines, formatting “● Title: content” as bold subitems with indentation, and generating a clickable TOC at the top.

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 "md-doc-cleanup" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-8d6b21c9ff9dffd303732463f524366884f57afba0b174c5da3bcd64e316f833. Verify the upstream source and version against https://skillhub.cn/skills/user_7e25a48a/clean-md 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

Markdown Document Cleanup — normalizes and organizes long Markdown documents by fixing structural issues such as flattened heading levels, un-nested numbered outlines, inline numbered lists, unformatted bullet-point items, and missing clickable table of contents. Use when the user requests: rebuilding Markdown heading hierarchy, splitting inline numbered lists into separate lines, formatting “● Title: content” as bold subitems with indentation, and generating a clickable TOC at the top.

0 Downloads

Introduction source: third_party · user_7e25a48a · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Translation pending; see source documentation.
Limits and differences
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: md-doc-cleanup
description: 规范化/整理长篇 Markdown 文档(如从 PDF、网页、OCR 复制而来的技术手册、论文、白皮书),典型症状包括:标题层级被平铺在同一级(全是 ##)、带编号大纲(1. / 1.1 / 1.1.1)未分级、同一行里用分号连写的「1)2)3)」编号列表、用 ● 标记的要点未格式化、缺少可点击跳转的目录。当用户要求:(1) 修复/重建 Markdown 标题层级;(2) 把连写的编号列表拆成逐行断首;(3) 把「● 标题:内容」格式化为加粗子项并缩进;(4) 在文首生成可跳转目录(GitHub 锚点 `[文字](#锚点)` 或笔记软件 wiki-link `[[## 标题]]` 风格)——使用本 skill。

Markdown 文档整理(md-doc-cleanup)

将结构混乱的长 Markdown 文档整理为层级清晰、列表规整、带可跳转目录的规范文档。

适用场景

  • 文档标题被平铺在同一个级别(几乎全是 ##),但正文带有清晰的数字编号大纲(1. / 1.1 / 1.1.1)。
  • 同一行内用 ; 连写多个编号项:1)…;2)…;3)…。。
  • 要点用 ● 标题:内容 形式,未加粗、未断行、未缩进。
  • 没有目录,或目录链接在目标渲染器里无法点击跳转。

处理流程(4 步,按顺序执行)

脚本 scripts/cleanup_markdown.py 按固定顺序串起全部步骤,每步读入上一步的结果:

  1. 重建标题层级 fix_headings:依据数字编号的「点」数映射层级——N.→H2(章节),N.N→H3(节),N.N.N→H4(子节);全文第一个无编号标题升为 H1(主标题);## ● 要点: 这类 ● 子标题降为 H5 并去掉 ●;带冒号的内联子标题(## 2. 检索策略:)降为 H5。
  2. 拆分列表 + 标题空行 fmt_list_blanks:在 ;/。 后、数字) 前插入换行,把连写编号拆成逐行;确保每个标题行与其后正文之间有一个空行(标题后已是空行或紧跟另一个标题则不插)。
  3. 格式化要点 fmt_bullets:把 ● 标题:内容 转为 * **标题**: 并换行,内容缩进为子项 * 内容;若内容(或紧随的后续行)含 数字) 编号,则把后续编号行一并收为同级缩进子项;无冒号的纯 ● 行仅把 ● 换成 *。
  4. 生成目录 gen_toc:在 H1 标题之后插入 ## 目录 + 说明 + TOC 列表 + --- 分隔线。TOC 默认提取到 H3(章节+节),H4/H5 不进目录。链接风格由 --toc-style 决定。

脚本用法

# 默认:重建层级 + 拆分列表 + 格式化要点 + 生成 wiki-link 风格目录(到 H3)
python scripts/cleanup_markdown.py article.md

# 生成 GitHub 标准锚点链接的目录
python scripts/cleanup_markdown.py article.md --toc-style github

# 目录细化到子节(H4)
python scripts/cleanup_markdown.py article.md --toc-depth 4

# 只做其中某几步(用 --skip-* 关闭其余步骤)
python scripts/cleanup_markdown.py article.md --skip-toc          # 不生成目录
python scripts/cleanup_markdown.py article.md --skip-headings     # 标题已正确时跳过层级重建

参数

参数 默认 说明
path 必填 目标 .md 文件路径(脚本就地修改该文件)
--toc-depth 3 目录包含的层级深度:2=仅章节,3=章节+节,4=含子节
--toc-style wikilink wikilink 生成 [[## 标题]];github 生成 [标题](#锚点)
--skip-headings off 跳过标题层级重建
--skip-list off 跳过列表拆分与标题空行
--skip-bullets off 跳过要点格式化
--skip-toc off 跳过目录生成

注意事项 / 边界情况

  • 幂等与适用范围:本流程针对「标题平铺 + 编号大纲」这类混乱文档设计。对层级已经正确的文档重复运行 fix_headings 可能破坏结构,此时用 --skip-headings。
  • 目录防重复:若文档前 50 行已存在 ## 目录,gen_toc 会自动跳过,不重复插入。
  • wiki-link 兼容性:[[## 标题]] 是部分笔记/渲染器(如支持双链的工具)的语法;若目标平台是 GitHub / VS Code 预览,请用 --toc-style github。
  • 中文锚点:github 风格下锚点按 GitHub 规则生成(小写、去标点、空格转 -、中文保留),与渲染器默认跳转一致。
  • 执行前建议备份:脚本就地修改原文件,处理重要文档前先 git stash 或复制一份。

Current listing version

1.0.0

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 解决用户从 PDF/网页/OCR 复制文档后结构混乱的痛点
  • 提供标题层级重建、列表拆分、要点格式化、目录生成等实用功能
  • 属于明确场景的通用工具,受众广泛
Trigger Precision95/100

Highlights

  • description 详细描述了典型症状和处理场景
  • 覆盖多种变体(如标题平铺、编号连写、● 要点等),边界清晰
Structure and Standards90/100

Highlights

  • Phase/步骤清晰(4 步流程),有参数说明、示例用法、注意事项
  • frontmatter 完整,单文件未超限
Execution Reliability85/100

Highlights

  • 工具来源明确(cleanup_markdown.py),参数正确
  • 覆盖主要异常(如目录防重复、幂等性说明),有备份建议
Evidence Verifiability (mean of the first four)89/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.

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.

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