The backbone of large documentation sets. @include directives pull in external markdown fragments and fully parse them inline -- making one-file-per-section composition possible without a build system. Supports optional line-range selection for embedding partial files, with circular-include protection to keep deeply nested setups safe.
composer require alto/commonmarkuse Alto\CommonMark\Extension\Include\IncludeExtension;
use League\CommonMark\Environment\Environment;
$environment = new Environment();
$environment->addExtension(new IncludeExtension(__DIR__ . '/docs'));@include "sections/intro.md"
@include "sections/features.md" {lines: 5-20}- Constructor:
new IncludeExtension(string $basePath='.', int $maxDepth=10, array $allowedExtensions=['md','markdown'], int $maxFileSize=1048576). - Validates extension, file size, and readable path constraints.
# Guide
@include "parts/overview.md"
@include "parts/setup.md"This extension is actively developed in the alto/commonmark monorepo.
MIT License -- Simon André & Alto