Skip to content

Latest commit

 

History

History
62 lines (39 loc) · 1.45 KB

File metadata and controls

62 lines (39 loc) · 1.45 KB

TableOfContents Extension

Summary

A must-have for any document longer than a page. Place @toc where you want the contents list and the extension takes care of the rest: headings are collected, anchor IDs are assigned, and a navigable nested list is rendered -- with filtering by level and configurable output style.

Installation

composer require

composer require alto/commonmark

Registration

use Alto\CommonMark\Extension\TableOfContents\TableOfContentsExtension;
use League\CommonMark\Environment\Environment;

$environment = new Environment();
$environment->addExtension(new TableOfContentsExtension());

Usage

@toc
@toc {min: 2, max: 3, title: "Contents", style: ordered}

Configuration

  • min_level / max_level: heading level bounds.
  • style: bullet or ordered.
  • title, class, id, marker: output/customization options.

Minimal Example

# Guide
@toc {min: 2}

## Intro

## Setup

### Advanced Setup

Development

This extension is actively developed in the alto/commonmark monorepo.

License

MIT License -- Simon André & Alto