Registry / devops / markdown-toc-gen

markdown-toc-gen

JSON →
library1.2.0jsnpmunverified

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-gen
INSTALL
IMPORT
SIG · MARKDOWN-TOC-GEN
M
markdown-toc-gen
devopsjavascriptv1.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

markdown-toc-gen
npx markdown-toc-gen insert README.md
import markdownTocGen from 'markdown-toc-gen'
This is a CLI tool, not a library. Use via npx or global install.

Shows basic usage: install, add TOC markers, insert TOC, and check TOC freshness.

# Install globally or use npx npm install -g markdown-toc-gen # Add markers to your README.md # <!-- toc --> # <!-- tocstop --> # Generate TOC markdown-toc-gen insert README.md # Check if TOC is up-to-date (useful in CI) markdown-toc-gen check README.md
markdown-toc-gen --version
Debug
Known issues
gotchaThe tool excludes h1 headings by default; only h2 through h6 are included in the TOC.
fix
Use --max-depth to include h1 if desired, e.g., --max-depth 1
affects: >=1.0.0
gotchaMarkers '<!-- toc -->' and '<!-- tocstop -->' must be separated by at least one newline from other content.
fix
Ensure there is a blank line before and after the marker lines.
affects: >=1.0.0
gotchaNode.js version 12 or higher is required; lower versions may produce errors.
fix
Upgrade Node.js to >=12
affects: <1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'markdown-toc-gen'
Trying to import as a library instead of using CLI.
fix
Use npx or install globally: npx markdown-toc-gen insert README.md
Error: No toc markers found
Missing '<!-- toc -->' and '<!-- tocstop -->' markers in the file.
fix
Add the required markers to your Markdown file.
Error: ENOENT: no such file or directory
Specified file path does not exist.
fix
Check the file path and ensure it exists.
Error: Cannot read property 'map' of undefined
File is empty or not valid Markdown.
fix
Ensure the file contains at least some headings.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
markdown-toc-gen — npm install markdown-toc-gen · libregistry