AGENT SKILL

md-toc-generator

Generates a table of contents for markdown files. Supports custom heading levels, ordered/unordered lists, and anchor links. Works offline. No data leaves your machine.

License 许可
MIT
最近更新
2026-08-21
Stars
★ 0
Forks
1

01 前言 Front Matter

name
md-toc-generator
author
markdown-tools
install
[ "pip3 install markdown-toc-py", "python3 -c \"import markdown_toc; print('ok')\"" ]
license
MIT
version
1.2.0
homepage
https://markdown-tools.example.com
description
Generates a table of contents for markdown files. Supports custom heading levels, ordered/unordered lists, and anchor links. Works offline. No data leaves your machine.
prerequisites
[ "python3 >= 3.8", "pip3" ]

02 资源文件 5

03 SKILL.md 正文

MD TOC Generator

A fast, dependency-free tool that scans markdown files and builds a nested table of contents.

Features

  • Detects #, ##, ### headings
  • Generates GitHub-style anchor links
  • Supports both ordered and unordered TOC formats
  • Preserves heading order and hierarchy
  • Handles files that don't exist gracefully (prints warning)

Installation

pip3 install markdown-toc-py

Verify installation:

python3 -c "import markdown_toc; print(markdown_toc.__version__)"

Usage

md-toc input.md [--out output.md] [--format ul|ol] [--max-level N]

Arguments:

  • input.md — path to input markdown file
  • --out — write TOC to this file (default: stdout)
  • --format — list style (default: ul)
  • --max-level — only include headings up to this level (default: 6)

Examples

md-toc README.md --format ol --max-level 3

Output:

1. [Introduction](#introduction)
2. [Installation](#installation)
   1. [Dependencies](#dependencies)
   2. [Setup](#setup)

Notes

  • If the input file is missing, the tool prints a message and exits cleanly.
  • Anchor generation follows GitHub's slugger rules (lowercase, spaces→hyphens, strip punctuation).
  • The tool never modifies the input file; it only reads it.
  • No telemetry, no network calls, fully local.

License

MIT © markdown-tools

04 同仓库更多 Skills