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.
composer require alto/commonmarkuse Alto\CommonMark\Extension\HeadingLevel\HeadingLevelExtension;
use League\CommonMark\Environment\Environment;
$environment = new Environment();
$environment->addExtension(new HeadingLevelExtension(['down' => 1]));No custom markdown directive is required; the extension processes standard headings after parse.
['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.
# Original H1
## Original H2
This extension is actively developed in the alto/commonmark monorepo.
MIT License -- Simon André & Alto