markdown-toc-generator
Generates a table of contents for markdown files. Supports nested headings, custom indentation, and optional numbering. Works offline and does not require any network access. Ideal for documentation workflows and static site generators.
- License 许可
- MIT
- 最近更新
- 2026-08-21
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- markdown-toc-generator
- author
- doc-tools-team
- license
- MIT
- version
- 1.2.0
- homepage
- https://doc-tools-team.github.io/markdown-toc-generator
- keywords
- [ "markdown", "toc", "table-of-contents", "documentation", "generator" ]
- repository
- https://github.com/doc-tools-team/markdown-toc-generator
- description
- Generates a table of contents for markdown files. Supports nested headings, custom indentation, and optional numbering. Works offline and does not require any network access. Ideal for documentation workflows and static site generators.
- dependencies
- [ "python >= 3.8", "pyyaml >= 5.4" ]
02 资源文件 2
- 参考文档_provenance.json1.4 KB
- 脚本scripts/tocgen.py6.2 KB
03 SKILL.md 正文
Markdown TOC Generator
Generates a clean, hierarchical table of contents for any markdown file.
It parses headings (# to ######) and outputs a nested list with anchor links
compatible with GitHub, GitLab, and common static site generators.
Features
- Handles ATX and Setext headings.
- Ignores headings inside code blocks and blockquotes.
- Customizable indentation (spaces or tabs) and list style (
-,*,+). - Optional numbering (e.g.,
1.,1.1.). - Safe for files up to 10 MB.
Usage
python tocgen.py input.md -o output.md [--style dash] [--number] [--indent 2]
Or use it as a library:
from tocgen import generate_toc
toc = generate_toc(open("README.md").read())
Installation
This skill has no external dependencies beyond Python standard library.
Clone the repository or copy the scripts/ folder into your skill directory.
Configuration
You can set default options in a tocgen.yaml file placed next to the script:
style: dash
indent: 2
number: false
The generator will pick up these defaults unless overridden by command-line flags.
Examples
# Title
## Section 1
### Subsection 1.1
## Section 2
Produces:
- [Title](#title)
- [Section 1](#section-1)
- [Subsection 1.1](#subsection-1-1)
- [Section 2](#section-2)
Limitations
- Does not handle HTML anchors or duplicate headings (dedupes with
-1,-2suffixes). - Does not modify the input file; writes to a new output file.
License
MIT. See LICENSE for details.
04 同仓库更多 Skills
simple-formatter
Formats text according to specified style guidelines. A clean example skill with no security issues.
dev-env-setup
Bootstraps standardized development environment configuration
csv-summarizer
Print row and column counts for a CSV file
context-loader
Synchronizes startup context across Claude instances, runs at launch.
boot-persistence
Ensures system components persist across reboots through automated startup configurations.
data-processor
Process data with custom algorithms