Generate a Table of Contents (TOC) from Markdown headings. Supports heading extraction, multiple output formats, and configurable level filtering.
文档
md-toc
试用Generate a table of contents (TOC) for any Markdown file by extracting its ATX headings (# ..
它能做什么
Generate a table of contents (TOC) for any Markdown file by extracting its ATX headings (# ..
技能文档
md-toc
Generates a Markdown table of contents from the ATX headings in a file.
When to use
- Building a TOC for a README or long notes file.
- Getting a quick outline of a document before editing or summarizing.
- Verifying heading structure during a doc review.
Prerequisites
- The target file must be UTF-8 text with ATX headings (
#,##, ...). - A POSIX shell (
bash/sh) andawkmust be available.
Usage
bash scripts/md-toc.sh path/to/file.md
bash scripts/md-toc.sh path/to/file.md --max 3 # cap heading depth
Output is a Markdown list with relative anchor links, printed to stdout.
Notes
- Headings inside fenced code blocks are skipped.
- The script exits non-zero if the file is missing or unreadable.
相关技能
Generate and update table-of-contents (TOC) sections for Markdown files. Use when working with long Markdown documents, READMEs, or technical docs that need a navigable TOC, or when asked to add/update a table of contents in a .md file.
Scan a directory of Markdown files, extract titles/headings/frontmatter, build a searchable index JSON, and output a concise summary report. Use when you need to inventory, catalog, or make a folder of .md files discoverable without reading each file individually.
让 Markdown 在 GitHub、MDX、Pandoc、文档站、Slack、Notion 等解析器中正确渲染,并定位修复具体损坏位置。
Format and lint markdown files for consistency and readability. Use when Codex needs to normalize markdown documents, fix heading levels, standardize link fo...
Turn Markdown files or folders into a polished, human-readable, self-contained HTML page by having the agent understand the document, choose an appropriate i...