Martan03 / mdcon

Utility for generating Table of contents from Markdown file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mdcon

Utility for generating Table of contents from Markdown file.

Table of Contents:

Installation

You have to compile it yourself, but that shouldn't be a problem. Only thing you need is cargo:

cargo build -r

After its done compiling, you can start it in ./target/release/mdcon

Usage

Generates Table of contents for README.md:

./mdcon

Generates Tables of contents for given file:

./mdcon -f file.md

You can check other usage in help:

./mdcon -h

Detailes description

This utility generates Table of contents from Markdown file. Each item in the table consists of the text, which is the text corresponding to the header text and then the link itself, which redirects to corresponding header.

Token to insert to file

You can use special token to insert Table of contens to the file to that location. If no token is found, Table of contents are placed to the beginning of the file.

Token looks like this:

{{ mdcon }}

You can place it anywhere you want and mdcon will generate contents from headers only after this token. After generating, it will automatically replace this token with Table of contents.

Example

If we have this Markdown:

# mdcon test
{{ mdcon }}

## This is a title
bla bla bla

### Sub title

## And so on...
bla bla bla

Our file will be modified to this:

# mdcon test
- [This is a title](#this-is-a-title)
    - [Sub title](#sub-title)
- [And so on...](#and-so-on)

## This is a title
bla bla bla

### Sub title

## And so on...
bla bla bla

Dumping Table of Contents

If you don't want to place Table of contents to the file, you can use -d flag to dump the table to stdout.

Technologies

I used library called termint for colored printing.

Links

About

Utility for generating Table of contents from Markdown file

License:GNU General Public License v3.0


Languages

Language:Rust 100.0%