https://github.com/codeclown/hohhoijaa
https://github.com/codeclown/hohhoijaa
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/codeclown/hohhoijaa
- Owner: codeclown
- Created: 2020-05-04T20:46:39.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-03-26T15:46:27.000Z (almost 4 years ago)
- Last Synced: 2025-03-07T00:15:50.095Z (about 1 year ago)
- Language: JavaScript
- Size: 83 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# hohhoijaa
> Generate Table of Contents in your Markdown-files
## Table of Contents
- [Table of Contents](#table-of-contents)
- [Why](#why)
- [Installation](#installation)
- [Usage](#usage)
- [Add template tag](#add-template-tag)
- [CLI](#cli)
- [Tests](#tests)
- [License](#license)
## Why
Yes, there [are](https://www.npmjs.com/package/gen-md-toc) [tons](https://www.npmjs.com/package/markdown-toc) [of](https://www.npmjs.com/package/toc-md) [scripts](https://www.npmjs.com/package/md-toc) like this already.
This script is for those of us who want the following:
- Support multiple files out-of-the-box, i.e. `hohhoijaa *.md`
- For CI use, `--check` to validate existing TOCs but not write anything
- No external dependencies, just simple text matching (see [`src/*.test.js`](src/), it works just fine)
## Installation
```bash
npm install --save-dev hohhoijaa
```
## Usage
### Add template tag
Add `` to each markdown file where you want the generated Table of Contents to be inserted.
Files without this template tag will be unaffected.
### CLI
Basic usage:
```bash
hohhoijaa README.md
```
Bash wildcards work:
```bash
hohhoijaa *.md
```
Validate existing TOCs (if any file needs updating, will exit with 1; otherwise with 0):
```bash
hohhoijaa --check *.md
```
By default the first H1-level heading is omitted. Can choose to keep it:
```bash
hohhoijaa --keep-h1 *.md
```
## Tests
Test files are named `src/*.test.js`.
```bash
yarn test
```
## License
MIT