A CLI tool to generate, update, check, and test table of contents in Markdown files, with focus on conformity with Prettier formatting (hyphens as bullet list). Current stable version 1.2.0. It handles duplicate headings, ignores code blocks, and supports multiple files via glob patterns. Differs from similar tools by being Prettier-compliant, excluding h1 headings by default, and offering a dry-run mode. The tool requires '<!-- toc -->' and '<!-- tocstop -->' markers in Markdown files.
npm install markdown-toc-genVerified import paths — ran on the pinned version, not inferred.
Shows basic usage: install, add TOC markers, insert TOC, and check TOC freshness.
Use --max-depth to include h1 if desired, e.g., --max-depth 1
Ensure there is a blank line before and after the marker lines.
Upgrade Node.js to >=12
Use npx or install globally: npx markdown-toc-gen insert README.md
Add the required markers to your Markdown file.
Check the file path and ensure it exists.
Ensure the file contains at least some headings.
No dependency data recorded yet.