Crates.io | mtoc |
lib.rs | mtoc |
version | 0.4.1 |
source | src |
created_at | 2024-08-29 08:08:12.129973 |
updated_at | 2024-10-09 12:56:44.405285 |
description | Generate a table of contents for markdown files |
homepage | |
repository | https://github.com/containerscrew/mtoc |
max_upload_size | |
id | 1355809 |
size | 255,827 |
Markdown table of contents generator
Built with ❤ in Rust
Table of Contents generated with mtoc
I'm very supper fan of doctoc and I use it a lot, but I wanted to create a similar tool in Rust.
From this:
# Hello
## World
### How are you?
To this:
<!-- START OF TOC !DO NOT EDIT THIS CONTENT MANUALLY-->
**Table of Contents** *generated with [mtoc](https://github.com/containerscrew/mtoc)*
- [Hello](#hello)
- [World](#world)
- [How are you?](#how-are-you?)
<!-- END OF TOC -->
Language | |
Crates | |
Release | |
Code | |
CI - Build | |
CI - Release | |
CI - Test | |
CI - Coverage | |
Meta | |
Codecov |
Arch | ARM64 | AMD64 |
---|---|---|
darwin | ✅ | ✅ |
linux | ✅ | ✅ |
windows | ❌ | ❌ |
Maybe in windows systems this tool will work, but has not been tested
curl --proto '=https' --tlsv1.2 -sSfL https://raw.githubusercontent.com/containerscrew/mtoc/main/install.sh | sh
curl --proto '=https' --tlsv1.2 -sSfL https://raw.githubusercontent.com/containerscrew/mtoc/main/install.sh | sh -s -- -v "v0.8.0"
cargo install mtoc
If you want to update the tool to a new version, just the run the same command
cargo install mtoc
.
Binary:
sudo rm /usr/local/bin/mtoc
With cargo:
cargo uninstall mtoc
By default, the command will search for markdown files in the current directory and generate the table of contents for each file. But, you can specify a directory to search for markdown files, specify only a specific file, or exclude directories from the search.
$ mtoc --help
Git markdown table of contents generator.
Usage: mtoc [OPTIONS]
Options:
-d, --directory <DIRECTORY> Directory to search for markdown files [default: .]
-e, --exclude-dir <EXCLUDE>... Exclude directories from search
-f, --file <FILE>... Only generate TOC for the specified file(s)
-h, --help Print help
-V, --version Print version
mtoc # default the current dir where the command is executed. All the files, all the directories will be scanned.
mtoc -d /path/to/directory
mtoc -e ".target/" -e "node_modules/"
mtoc -f README.md
Add this configuration to your .pre-commit-config.yaml
- repo: https://github.com/containerscrew/mtoc
rev: v0.3.2 # use the most recent tag
hooks:
- id: mtoc
args: [ "-e", ".target/" ]
Always stay up to date with the latest changes in the project markdown files.
$ mtoc -e ".target/" 🦀 v1.80.1
Excluding directories [".target/"]
Updated markdown file ./docs/test.md
Updated markdown file ./CHANGELOG.md
Updated markdown file ./README.md
$ pre-commit install
# Or run once
$ pre-commit run -a
mtoc
is distributed under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
.