Crates.io | mdbook-toc |
lib.rs | mdbook-toc |
version | 0.14.2 |
source | src |
created_at | 2019-07-10 19:29:14.211583 |
updated_at | 2023-12-13 10:48:10.956407 |
description | mdbook preprocessor to add Table of Contents |
homepage | https://github.com/badboy/mdbook-toc |
repository | https://github.com/badboy/mdbook-toc |
max_upload_size | |
id | 148129 |
size | 105,118 |
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.
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
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}"""
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
MPL. See LICENSE.
Copyright (c) 2018-2020 Jan-Erik Rediger janerik@fnordig.de