Generate and insert table of contents into markdown files.
Analyzes markdown files to extract headings and generates a formatted table of contents that can be inserted at various positions within the file.
Array of file paths to process
TOC generation configuration options
Promise resolving to generation results
Basic TOC generation
const result = await generateToc(['README.md'], {position: 'after-title',minDepth: 2,maxDepth: 4});console.log(`Added TOC to ${result.filesModified} files`); Copy
const result = await generateToc(['README.md'], {position: 'after-title',minDepth: 2,maxDepth: 4});console.log(`Added TOC to ${result.filesModified} files`);
Replace existing TOC
const result = await generateToc(['docs/*.md'], {position: 'replace',marker: '<!-- TOC -->',skipEmpty: true}); Copy
const result = await generateToc(['docs/*.md'], {position: 'replace',marker: '<!-- TOC -->',skipEmpty: true});
Generate and insert table of contents into markdown files.
Analyzes markdown files to extract headings and generates a formatted table of contents that can be inserted at various positions within the file.