mktoc
Markdown Table of Content generator
- About - Installation - Cargo - Binary - Usage - Update Markdown file - Command line - Environment configuration - Performance - License
mktoc
parses markdown files and generates a Table Of Content linking all headlines up to heading level 6 deep, or as specified by command line arguments. A start depth and maximum depth can be specified.
mktoc
can be installed using Cargo, the Rust package manager.
sh
$ cargo install mktoc
$ cargo install --force mktoc
Binaries are actually not available yet. If you know how releasing binaries with Rust can be implemented, please let me know!
Add the following HTML comment into the Markdown file where the Table of Contents should be rendered.
<!-- BEGIN mktoc -->
<!-- END mktoc -->
Everything between those comments will be replaced!
Specify --stdout
or -s
to output generated content to stdout
instead of overwriting file. By default the specified file will be overwritten.
```
$ mktoc -s README.md $ mktoc -m 2 -M 4 README.md $ mktoc ``` If no arguments are given the default or configured (via environment) values are used.
See mktoc --help
for list of all arguments and flags.
``` mktoc
USAGE: mktoc [FLAGS] [OPTIONS] [file]
FLAGS: -h, --help Prints help information -s, --stdout If set will output to stdout instead of replacing content in file -V, --version Prints version information
OPTIONS:
-M, --max-depth
ARGS:
mktoc can be configured with environment variables, namely:
MKTOC_MIN_DEPTH
equal to -m
MKTOC_MAX_DEPTH
equal to -M
Place these variables in a shell environment file such as ~/.bashrc
or
~/.zshrc
, then just run mktoc without -m
and -M
```sh
$ mktoc README.md ```
mktoc
is fast but can probably be even faster! Pull Requests and bug reports are appreciated!
MIT, see LICENSE file.