PHPackages                             alto/commonmark-heading-level - 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-heading-level

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

alto/commonmark-heading-level
=============================

CommonMark extension that shifts, maps, or transforms heading levels via a config array or callback.

v1.0.0(yesterday)00MITPHPPHP ^8.3

Since Jul 30Pushed yesterdayCompare

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

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

HeadingLevel Extension
======================

[](#headinglevel-extension)

Summary
-------

[](#summary)

The one you don't need until you really do -- then it's irreplaceable. Transforms heading levels after parsing so that content written for one heading context can be safely embedded in another without hierarchy collisions. Supports fixed shifting, explicit level remapping, and a callback option that gives you complete control over every heading in the document.

Installation
------------

[](#installation)

### composer require

[](#composer-require)

```
composer require alto/commonmark
```

### Registration

[](#registration)

```
use Alto\CommonMark\Extension\HeadingLevel\HeadingLevelExtension;
use League\CommonMark\Environment\Environment;

$environment = new Environment();
$environment->addExtension(new HeadingLevelExtension(['down' => 1]));
```

Usage
-----

[](#usage)

No custom markdown directive is required; the extension processes standard headings after parse.

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

[](#configuration)

- `['down' => 1]`: shifts heading level up numerically (`h1 -> h2`, etc.).
- `['map' => [1 => 2, 2 => 3]]`: explicit per-level mapping.
- `['callback' => fn(int $level): int => ...]`: custom transformation logic.

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

[](#minimal-example)

```
# Original H1

## Original H2
```

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-extensionheadingheading-levelheading-shiftmarkdownphpphpmarkdowncommonmarkaltocommonmark-extensionheadingheading-levelheading-shift

### Embed Badge

![Health badge](/badges/alto-commonmark-heading-level/health.svg)

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

###  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)
