{"id":20202,"library":"markdown-toc-gen","title":"markdown-toc-gen","description":"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.","status":"active","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/thesilk-tux/markdown-toc-gen","tags":["javascript","toc","markdown","generator","table of content","plugin","readme","doc","documentation"],"install":[{"cmd":"npm install markdown-toc-gen","lang":"bash","label":"npm"},{"cmd":"yarn add markdown-toc-gen","lang":"bash","label":"yarn"},{"cmd":"pnpm add markdown-toc-gen","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is a CLI tool, not a library. Use via npx or global install.","wrong":"import markdownTocGen from 'markdown-toc-gen'","symbol":"markdown-toc-gen","correct":"npx markdown-toc-gen insert README.md"}],"quickstart":{"code":"# Install globally or use npx\nnpm install -g markdown-toc-gen\n\n# Add markers to your README.md\n# <!-- toc -->\n# <!-- tocstop -->\n\n# Generate TOC\nmarkdown-toc-gen insert README.md\n\n# Check if TOC is up-to-date (useful in CI)\nmarkdown-toc-gen check README.md","lang":"bash","description":"Shows basic usage: install, add TOC markers, insert TOC, and check TOC freshness."},"warnings":[{"fix":"Use --max-depth to include h1 if desired, e.g., --max-depth 1","message":"The tool excludes h1 headings by default; only h2 through h6 are included in the TOC.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure there is a blank line before and after the marker lines.","message":"Markers '<!-- toc -->' and '<!-- tocstop -->' must be separated by at least one newline from other content.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade Node.js to >=12","message":"Node.js version 12 or higher is required; lower versions may produce errors.","severity":"gotcha","affected_versions":"<1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use npx or install globally: npx markdown-toc-gen insert README.md","cause":"Trying to import as a library instead of using CLI.","error":"Error: Cannot find module 'markdown-toc-gen'"},{"fix":"Add the required markers to your Markdown file.","cause":"Missing '<!-- toc -->' and '<!-- tocstop -->' markers in the file.","error":"Error: No toc markers found"},{"fix":"Check the file path and ensure it exists.","cause":"Specified file path does not exist.","error":"Error: ENOENT: no such file or directory"},{"fix":"Ensure the file contains at least some headings.","cause":"File is empty or not valid Markdown.","error":"Error: Cannot read property 'map' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}