No description
Find a file
Jan-Erik Rediger bd0c383640
Some checks are pending
Tests / Build and test (push) Waiting to run
Tests / Checking fmt and docs (push) Waiting to run
A simple utility to quickly create a new test case
2026-01-15 11:44:17 +01:00
.cargo A simple utility to quickly create a new test case 2026-01-15 11:44:17 +01:00
.github/workflows CI: Update deployment script 2025-11-19 16:00:01 +01:00
src Correctly extract text from headers, stripping formatting/links/code tags 2026-01-14 12:26:36 +01:00
tests Correctly extract text from headers, stripping formatting/links/code tags 2026-01-14 12:26:36 +01:00
xtask A simple utility to quickly create a new test case 2026-01-15 11:44:17 +01:00
.gitignore Ignore local testing book 2019-07-10 21:22:02 +02:00
Cargo.lock chore: Release mdbook-toc version 0.15.3 2026-01-14 12:28:45 +01:00
Cargo.toml chore: Release mdbook-toc version 0.15.3 2026-01-14 12:28:45 +01:00
CHANGELOG.md Prepare release 2026-01-14 12:28:27 +01:00
flake.lock build: nix flake 2023-08-25 13:42:28 -04:00
flake.nix build: nix flake 2023-08-25 13:42:28 -04:00
LICENSE Add License and Readme 2018-07-20 12:07:21 +02:00
README.md Clarify which headers are included 2023-06-01 16:41:26 +02:00
release.toml Set tag-name to not include the v 2019-08-21 09:52:41 -07:00

mdbook-toc

A preprocessor for mdbook to add inline Table of Contents support.

It turns this marker:

<!-- toc -->

into a Table of Contents based on headings of the chapter following the marker.

Installation

If you want to use only this preprocessor, install the tool:

cargo install mdbook-toc

Add it as a preprocessor to your book.toml:

[preprocessor.toc]
command = "mdbook-toc"
renderer = ["html"]

Finally, build your book as normal:

mdbook path/to/book

Configuration

Custom TOC marker

The default marker is:

<!-- toc -->

If you wish to use a different marker, such as the GitLab marker [[_TOC_]], you must add the following settings to your book.toml.

[preprocessor.toc]
marker = "[[_TOC_]]"

You can also use multi-line markers such as the GitHub marker, which is:

* auto-gen TOC;
{:toc}

Configure the string with a newline:

[preprocessor.toc]
marker = "* auto-gen TOC;\n{:toc}"

or with multi-line strings:

[preprocessor.toc]
marker = """* auto-gen TOC;
{:toc}"""

Maximum header level

By default the ToC will include headings up to level 4 (####). This can be configured in your book.toml as follows:

[preprocessor.toc]
max-level = 4

License

MPL. See LICENSE.
Copyright (c) 2018-2020 Jan-Erik Rediger janerik@fnordig.de