#mdbook #table #content #toc #marker #add #inline

bin+lib mdbook-toc

mdbook preprocessor to add Table of Contents

28 releases

0.14.2 Dec 13, 2023
0.14.1 Aug 5, 2023
0.13.0 Jul 18, 2023
0.11.2 Feb 14, 2023
0.2.1 Jul 16, 2019

#328 in Text processing

Download history 995/week @ 2024-10-30 914/week @ 2024-11-06 999/week @ 2024-11-13 1010/week @ 2024-11-20 948/week @ 2024-11-27 3504/week @ 2024-12-04 5042/week @ 2024-12-11 4915/week @ 2024-12-18 4633/week @ 2024-12-25 4513/week @ 2025-01-01 4935/week @ 2025-01-08 4997/week @ 2025-01-15 4963/week @ 2025-01-22 4723/week @ 2025-01-29 3447/week @ 2025-02-05 1498/week @ 2025-02-12

15,393 downloads per month
Used in mdbook-dtmo

MPL-2.0 license

31KB
250 lines

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

Dependencies

~13–25MB
~371K SLoC