markmv - v1.29.0
    Preparing search index...

    Function generateTocForFiles

    • 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.

      Parameters

      • filePaths: string[]

        Array of file paths to process

      • options: Partial<TocOperationOptions> = {}

        TOC generation configuration options

      Returns Promise<TocResult>

      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`);

      Replace existing TOC

      const result = await generateToc(['docs/*.md'], {
      position: 'replace',
      marker: '<!-- TOC -->',
      skipEmpty: true
      });