Utility for generating table of contents from markdown content.
This class extracts headings from markdown content and generates formatted table of contents with proper indentation and anchor links.
const generator = new TocGenerator(); const content = `# Title\n## Section 1\n### Subsection\n## Section 2`; const result = generator.generateToc(content); console.log(result.toc); // Output: // - [Title](#title) // - [Section 1](#section-1) // - [Subsection](#subsection) // - [Section 2](#section-2) Copy
const generator = new TocGenerator(); const content = `# Title\n## Section 1\n### Subsection\n## Section 2`; const result = generator.generateToc(content); console.log(result.toc); // Output: // - [Title](#title) // - [Section 1](#section-1) // - [Subsection](#subsection) // - [Section 2](#section-2)
const generator = new TocGenerator(); const options = { minDepth: 2, maxDepth: 4, includeLineNumbers: true }; const result = generator.generateToc(content, options); Copy
const generator = new TocGenerator(); const options = { minDepth: 2, maxDepth: 4, includeLineNumbers: true }; const result = generator.generateToc(content, options);
Extract headings from markdown content without generating TOC.
Markdown content to analyze
Configuration options
Array of headings
Generate table of contents from markdown content.
TOC result
Utility for generating table of contents from markdown content.
This class extracts headings from markdown content and generates formatted table of contents with proper indentation and anchor links.
Example: Basic usage
Example: With custom options