PHPackages                             alto/commonmark-table-of-contents - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. alto/commonmark-table-of-contents

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

alto/commonmark-table-of-contents
=================================

CommonMark extension that generates a linked table of contents from document headings at @toc directives.

v1.0.0(yesterday)00MITPHPPHP ^8.3

Since Jul 30Pushed yesterdayCompare

[ Source](https://github.com/altophp/commonmark-table-of-contents)[ Packagist](https://packagist.org/packages/alto/commonmark-table-of-contents)[ Docs](https://github.com/altophp/commonmark)[ GitHub Sponsors](https://github.com/sponsors/smnandre)[ RSS](/packages/alto-commonmark-table-of-contents/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

TableOfContents Extension
=========================

[](#tableofcontents-extension)

Summary
-------

[](#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
------------

[](#installation)

### composer require

[](#composer-require)

```
composer require alto/commonmark
```

### Registration

[](#registration)

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

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

Usage
-----

[](#usage)

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

Configuration
-------------

[](#configuration)

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

Minimal Example
---------------

[](#minimal-example)

```
# Guide
@toc {min: 2}

## Intro

## Setup

### Advanced Setup
```

Development
-----------

[](#development)

This extension is actively developed in the [`alto/commonmark`](https://github.com/altophp/commonmark) monorepo.

- [Report a bug](https://github.com/altophp/commonmark/issues/new?labels=bug)
- [Suggest a feature](https://github.com/altophp/commonmark/issues/new?labels=enhancement)
- [Open a Pull Request](https://github.com/altophp/commonmark/pulls)

License
-------

[](#license)

MIT License -- [Simon André](https://smnandre.dev) &amp; [Alto](https://github.com/altophp)

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a8951d49b371d210280a58ce48969a07d1f49924810f8a1fab3a9343eb46fdc9?d=identicon)[simonandre](/maintainers/simonandre)

---

Top Contributors

[![smnandre](https://avatars.githubusercontent.com/u/1359581?v=4)](https://github.com/smnandre "smnandre (3 commits)")

---

Tags

altocommonmarkcommonmark-extensionheadingmarkdownmarkdown-tocphpsummarytable-of-contentstocphpmarkdowncommonmarksummaryTOCtable-of-contentsaltocommonmark-extensionheadingmarkdown-toc

### Embed Badge

![Health badge](/badges/alto-commonmark-table-of-contents/health.svg)

```
[![Health](https://phpackages.com/badges/alto-commonmark-table-of-contents/health.svg)](https://phpackages.com/packages/alto-commonmark-table-of-contents)
```

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.5k10](/packages/helsingborg-stad-municipio)[petebishwhip/laradocs

Maintain beautiful, version-controlled documentation alongside your Laravel codebase. Markdown in, a polished docs site out.

1067.0k](/packages/petebishwhip-laradocs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
