{"repo":"zeusdeux/md-toc","free":true,"listed":false,"github":"https://github.com/zeusdeux/md-toc","clone":"git clone https://github.com/zeusdeux/md-toc.git","description":"Generate a GitHub compatible table of contents from headings in a markdown file. Tie into a pre-commit hook for max level awesome!","language":"JavaScript","stars":21,"topics":["contents","cli","lint-staged","pre-commit-hook","pre-commit","husky","pnpm","markdown"],"license":"MIT","category":"cli-tools","readme_excerpt":"md-toc Generate a GitHub compatible table of contents from headings in a markdown file. Table of contents - Motivation - Installation - Usage - Usage with lint-staged - Usage as a CLI - Debugging - Contributing Motivation I wanted something for myself that does exactly what I need it to do and exposes all the levers that I need. Also, I specifically wanted a CLI that can run in a pre-commit hook (via husky + lint-staged ) before prettier --write for markdown files so that I never have another piece of documentation without a table of contents! Installation Usage Usage with lint-staged Add the following line to the \"lint-staged\" config It is recommended that you run prettier after md-toc . For example — Usage as a CLI md-toc Usage: $0 [options] Options: -d, --debug Print debug logs to stderr [boolean] [default: false] -v, --version Show cli version [boolean] -h, --help Show help [boolean] -w, --write Write changes to the input file [boolean] [default: false] -a, --insertUnder Heading to insert the table of contents under. Defaults to table of c ontents toc table-of-contents [string] [default: \"\"] Examples: md-toc --write Readme.md Generate a table of contents from headings in Readme. md, insert them under a heading name \"Table of Conten ts\", \"toc\" or \"table-of-contents\" (all case insensiti ve) in Readme.md and write the file to disk. md-toc Readme.md Same as the --write option but the output is written to stdout and Readme.md is left as is. md-toc -a \"Contents\" -w Readme.md Sa","default_branch":null,"files":null,"tree":[],"storefront":"/r/zeusdeux","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/zeusdeux/md-toc/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}