Skip to the content.

mdtoc

Release Commits Since Release GitHub Issues PRs Welcome License Downloads Go Version Go Report Card Coverage Pages Pages Workflow

View Github Pages

mdtoc: Markdown Table of Contents ☰ with numbering and stable anchor links

generate, strip and check without turning your Markdown into a moving target.

Table of Contents (click to expand)

1. Features

2. Install

2.1. VS Code Extension

CLI install: code --install-extension rokath.mdtoc or open VS Code, click Extensions, enter mdtoc:

2.2. Release Binaries (Linux, MacOS, Windows)

Download a prebuilt binary from GitHub Releases.

2.3. Darwin Setup

Homebrew tap install:

brew install rokath/tap/mdtoc

2.4. Build from source

go build ./cmd/mdtoc

3. Usage

3.1. Inspect the CLI

mdtoc --help        # show compact CLI usage and commands
mdtoc --verbose     # show extended root help with command details
mdtoc <command> -v  # show the long help for one command

3.2. Use .docs/EXAMPLE.md as a playground

mdtoc EXAMPLE.md                    # root mode: update an existing managed container or create a new one
mdtoc generate EXAMPLE.md -a false  # new ToC, use CLI or defaults, rewrite the config block
mdtoc check EXAMPLE.md              # fail in CI when ToC differs from the reconstructed ToC
cat EXAMPLE.md | mdtoc              # dry-run
cat EXAMPLE.md | mdtoc strip > s.md # clear via Unix pipe and write to a different file

4. Managed Structure

mdtoc uses an explicit container so generated content is easy to spot and safe to regenerate.

(click to expand)
<!-- mdtoc -->

* [About](#about)

<!-- numbering=true min=2 max=4 slug=github anchor=true link=true toc=true bullets=auto -->
<!-- /mdtoc -->

The heading title stays the source of truth. Numbers, inline anchors, and ToC entries are derived from it. With anchor=false, the ToC target follows the rendered heading text because no managed inline anchor exists. Use slug=github|gitlab|crossnote to control the renderer/profile-dependent link type generation.

The optional config block records the settings used for regeneration. generate uses current CLI flags or defaults and then rewrites that block when settings need to be persisted.

This means:

5. Limits

6. Documentation

6.1. Specification

6.2. Comparison

7. Status

+ READY TO USE +