An open API service indexing awesome lists of open source software.

https://github.com/kevingimbel/mktoc

🦀 Markdown Table of Content generator
https://github.com/kevingimbel/mktoc

cli command-line command-line-tool generator markdown rust rust-library table-of-contents toc

Last synced: 6 months ago
JSON representation

🦀 Markdown Table of Content generator

Awesome Lists containing this project

README

          

# `mktoc`

![](assets/github-header.png)

Graphic design is my passion ✨

![](https://github.com/kevingimbel/mktoc/workflows/Clippy%20check/badge.svg)
![](https://github.com/kevingimbel/mktoc/workflows/Test/badge.svg)
![Coverage](assets/coverage/flat.svg)

# Table of Contents

- [About](#about)
- [Installation](#installation)
- [Cargo](#cargo)
- [Binary](#binary)
- [Hermit](#hermit)
- [Nix](#nix)
- [Run on demand ](#run-on-demand)
- [Install (nixos / nix-darwin)](#install-nixos--nix-darwin)
- [Usage](#usage)
- [Update Markdown file](#update-markdown-file)
- [Inline config](#inline-config)
- [`min_depth`](#min_depth)
- [`max_depth`](#max_depth)
- [`wrap_in_details`](#wrap_in_details)
- [Command line](#command-line)
- [Environment configuration](#environment-configuration)
- [Auto-run with VSCode](#auto-run-with-vscode)
- [Performance](#performance)
- [Contributing](#contributing)
- [Where to start?](#where-to-start)
- [Tooling](#tooling)
- [Install dev build](#install-dev-build)
- [License](#license)

## About
[⬆️ Back to Top](#table-of-contents)

`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, environment variables, or inline JSON config (see [Usage](#usage)).

## Installation
[⬆️ Back to Top](#table-of-contents)

`mktoc` can be installed using Cargo, the Rust package manager.

### Cargo

**Installation**
```sh
$ cargo install mktoc
```

**Update**
```sh
$ cargo install --force mktoc
```

### Binary

Binaries for Linux and MacOS can be downloaded from the [release page](https://github.com/KevinGimbel/mktoc/releases/latest).

Windows Binaries are not yet build automatically, see [#7](https://github.com/KevinGimbel/mktoc/issues/7).

### Hermit

`mktoc` is available in [hermit](https://github.com/cashapp/hermit) so it can be installed on a per-project basis without the need to install it globally.

```sh
$ hermit init
$ hermit install mktoc
```

This installs `mktoc` to the local bin directory at `bin/mktoc` inside the project.

### Nix

`mktoc` is available in [nixpkgs](https://search.nixos.org/packages?channel=unstable&show=mktoc&query=mktoc) since version 25.11.

#### Run on demand

```sh
nix run 'github:nixos/nixpkgs/nixpkgs-unstable#mktoc'
```

#### Install (nixos / nix-darwin)

```nix
environment.systemPackages = [
pkgs.mktoc
];
```

## Usage

### Update Markdown file
[⬆️ Back to Top](#table-of-contents)

Add the following HTML comment into the Markdown file where the Table of Contents should be rendered.

```html

```

Everything between those comments will be replaced!

#### Inline config
[⬆️ Back to Top](#table-of-contents)

Starting with version 3.0.0 it's possible to set values in-line which is great when collaborating with teams who may have individual settings.

```html