#mdbook #inline #preprocessor

bin+lib mdbook-toc

mdbook preprocessor to add Table of Contents

18 releases

0.7.0 Jul 6, 2021
0.6.3 Apr 21, 2021
0.6.1 Jan 6, 2021
0.5.1 Sep 28, 2020
0.2.1 Jul 16, 2019
Download history 73/week @ 2021-07-03 68/week @ 2021-07-10 160/week @ 2021-07-17 156/week @ 2021-07-24 105/week @ 2021-07-31 62/week @ 2021-08-07 70/week @ 2021-08-14 28/week @ 2021-08-21 75/week @ 2021-08-28 50/week @ 2021-09-04 76/week @ 2021-09-11 46/week @ 2021-09-18 41/week @ 2021-09-25 23/week @ 2021-10-02 77/week @ 2021-10-09 56/week @ 2021-10-16

256 downloads per month
Used in mdbook-dtmo

MPL-2.0 license

28KB
254 lines

mdbook-toc

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

It turns this:

<!-- toc -->

into a Table of Contents based on all top- and second-level headings of the chapter.

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

~9.5MB
~178K SLoC

uO`