https://github.com/hoytech/md-toc
Markdown Table Of Contents Generator
https://github.com/hoytech/md-toc
Last synced: 6 months ago
JSON representation
Markdown Table Of Contents Generator
- Host: GitHub
- URL: https://github.com/hoytech/md-toc
- Owner: hoytech
- Created: 2023-10-17T18:32:10.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-06-22T03:34:17.000Z (12 months ago)
- Last Synced: 2024-06-22T15:41:53.540Z (12 months ago)
- Language: Perl
- Size: 4.88 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# md-toc: Markdown Table Of Contents Generator
This simple script will scan a markdown file for headers and build a table-of-contents, like this:
* [Usage](#usage)
* [Setup](#setup)
* [Custom Nesting](#custom-nesting)
* [Updating](#updating)
* [Warnings](#warnings)
* [Author](#author)## Usage
### Setup
Before running the first time, put the following on a line by itself (with no leading whitespace):
Then run the script like this:
md-toc README.md
`md-toc` will collect all `h1`, `h2`... tags (in markdown: `#`, `##`, ...), build nested lists of these, and insert them after the `TOC FOLLOWS` line. The header levels used can be [customised](#custom-nesting).
#### Custom Nesting
By default, it will only include levels 2 through 4, but you can customise this with another argument:
md-toc README.md 1-5
### Updating
Each time you run `md-toc`, it will again search for the `TOC FOLLOWS` line, and delete everything between the `START OF TOC` and `END OF TOC` comment lines, re-render the new ToC, and insert it.
### Warnings
`md-toc` will warn you in the following cases:
* Duplicate headers
* Broken internal links (ie `[click here](#no-such-header)`)## Author
Doug Hoyte, 2023
MIT License