markdown-toc-builder
A fast, dependency-free utility that scans Markdown documents and produces a clean, well-formatted table of contents (TOC). Supports nested headings, custom indentation, and optional anchor linking. Ideal for CI pipelines and static site generators. Works on any text stream, no external services.
- License 许可
- MIT
- 最近更新
- 2026-08-21
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- markdown-toc-builder
- license
- MIT
- version
- 1.3.1
- description
- A fast, dependency-free utility that scans Markdown documents and produces a clean, well-formatted table of contents (TOC). Supports nested headings, custom indentation, and optional anchor linking. Ideal for CI pipelines and static site generators. Works on any text stream, no external services.
02 资源文件 2
- 参考文档_provenance.json1.2 KB
- 脚本markdown_toc.py3.0 KB
03 SKILL.md 正文
markdown-toc-builder
Build a table of contents for any Markdown file or stream. It reads from stdin
or a file, parses #-level headings, and writes a nested TOC to stdout.
Features
- Zero runtime dependencies.
- Handles
#through######headings. - Preserves list indentation style (tabs or spaces).
- Optional
--anchorflag to emit GitHub/GitLab-style anchor links. - Safe for untrusted input: operates purely on text, no file writes.
Usage
# Build TOC from a file
markdown-toc README.md > TOC.md
# Build TOC from stdin
cat CHANGELOG.md | markdown-toc --anchor
Options
| Flag | Description |
|---|---|
-f, --file |
Input Markdown file (default: stdin) |
-a, --anchor |
Append anchor links to TOC entries |
-i, --indent |
Indent string for nested levels (default: two spaces) |
-s, --skip |
Comma-separated heading levels to skip (e.g., 1,2) |
Example
Input:
# Intro
## Setup
### Windows
### Mac
## Usage
Output (with --anchor):
- [Intro](#intro)
- [Setup](#setup)
- [Windows](#windows)
- [Mac](#mac)
- [Usage](#usage)
Notes
- The tool never writes to disk; it only prints to stdout.
- All input is treated as plain text; no Markdown rendering is performed.
- For large files, the parser is streaming and memory-efficient.
Exit Codes
0: success1: invalid arguments2: input read failure
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