https://github.com/fjebaker/mdtoc
Table of contents generator for markdown documents.
https://github.com/fjebaker/mdtoc
markdown md mdtoc toc toc-generator
Last synced: about 1 year ago
JSON representation
Table of contents generator for markdown documents.
- Host: GitHub
- URL: https://github.com/fjebaker/mdtoc
- Owner: fjebaker
- License: gpl-3.0
- Created: 2020-03-29T05:55:48.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-10T17:39:51.000Z (about 5 years ago)
- Last Synced: 2025-04-05T01:06:58.583Z (about 1 year ago)
- Topics: markdown, md, mdtoc, toc, toc-generator
- Language: JavaScript
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mdtoc
A simple table of contents generator for markdown documents.
To setup, clone the repository and run
```
cd mdtoc && npm install
```
If you want to be able to use the tool in any directory for OSX or Linux, also run
```
echo "export PATH=$(pwd):$PATH" >> ~/.profile
```
### Usage
In a terminal
```
mdtoc {file|dir} [{file|dir}, ...] [-d/--header N]
```
The `-d` option sets the count of # for the top level header. For example, if you formatted a document with
```
# Title
### Some preliminary information
Lorem Ipsum dolor sit amet.
## First heading
...
```
You can omit headings prior to the `## First Heading` by setting the header flag `-d 2` (which is also the default value).
The program will crawl directories for `.md` files and generate a table of contents in the format
1. [Heading]()
2. [Heading]()
1. [Subheading]()
1. [Sub-subheading]()
2. [Subheading]()
3. [Heading]()
### Features
- Creates hyperlinked index references using `` tags.
- Nests headings, subheadings, and sub-subheadings in coherent format.
- Places generated table of contents at top of document, tagged with
```
...
```
If the tags are moved and the program executed again, `mdtoc` will replace the existing table of contents, instead of reinserting at the top of the document.