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

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

alto/commonmark-include
=======================

CommonMark extension that includes and re-parses external Markdown files at @include directives.

v1.0.0(yesterday)00MITPHPPHP ^8.3

Since Jul 30Pushed yesterdayCompare

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

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

Include Extension
=================

[](#include-extension)

Summary
-------

[](#summary)

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.

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

[](#installation)

### composer require

[](#composer-require)

```
composer require alto/commonmark
```

### Registration

[](#registration)

```
use Alto\CommonMark\Extension\Include\IncludeExtension;
use League\CommonMark\Environment\Environment;

$environment = new Environment();
$environment->addExtension(new IncludeExtension(__DIR__ . '/docs'));
```

Usage
-----

[](#usage)

```
@include "sections/intro.md"
@include "sections/features.md" {lines: 5-20}
```

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

[](#configuration)

- Constructor: `new IncludeExtension(string $basePath='.', int $maxDepth=10, array $allowedExtensions=['md','markdown'], int $maxFileSize=1048576)`.
- Validates extension, file size, and readable path constraints.

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

[](#minimal-example)

```
# Guide

@include "parts/overview.md"
@include "parts/setup.md"
```

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-extensiondocument-compositionfile-includeincludemarkdownpartialsphpphpmarkdowncommonmarkincludealtocommonmark-extensionpartialsfile includedocument-composition

### Embed Badge

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

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

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