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

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

alto/commonmark
===============

A collection of CommonMark extensions: code block titles, content slicing, heading level adjustment, file import/include, source display, table of contents, tabs, and link rewriting.

04PHPCI passing

Since Apr 6Pushed 2mo agoCompare

[ Source](https://github.com/PhpAlto/commonmark)[ Packagist](https://packagist.org/packages/alto/commonmark)[ RSS](/packages/alto-commonmark/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Alto CommonMark
===============

[](#alto-commonmark)

Reusable `league/commonmark` extensions in a monorepo, installable as either the umbrella package `alto/commonmark` or as standalone per-extension packages.

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

[](#installation)

```
composer require alto/commonmark
```

`alto/commonmark` declares `replace` on all standalone packages, so dependency resolution stays compatible whether you install one or all.

ExtensionDescriptionGitHubPackagistCodeBlockTitleTitled fenced code blocks rendered as ``[GitHub](https://github.com/PhpAlto/commonmark-code-block-title)[Packagist](https://packagist.org/packages/alto/commonmark-code-block-title)ContentSlicerWraps heading sections in semantic `` elements[GitHub](https://github.com/PhpAlto/commonmark-content-slicer)[Packagist](https://packagist.org/packages/alto/commonmark-content-slicer)HeadingLevelShift or remap heading levels across the document[GitHub](https://github.com/PhpAlto/commonmark-heading-level)[Packagist](https://packagist.org/packages/alto/commonmark-heading-level)ImportImport file contents into code blocks with line ranges[GitHub](https://github.com/PhpAlto/commonmark-import)[Packagist](https://packagist.org/packages/alto/commonmark-import)IncludeInline-include Markdown fragments for doc composition[GitHub](https://github.com/PhpAlto/commonmark-include)[Packagist](https://packagist.org/packages/alto/commonmark-include)LinkRewriterRewrite links &amp; images via base URI, map, or regex[GitHub](https://github.com/PhpAlto/commonmark-link-rewriter)[Packagist](https://packagist.org/packages/alto/commonmark-link-rewriter)SourceEmbed source files with line numbers and highlighting[GitHub](https://github.com/PhpAlto/commonmark-source)[Packagist](https://packagist.org/packages/alto/commonmark-source)TableOfContentsAuto-generated TOC from headings via `@toc`[GitHub](https://github.com/PhpAlto/commonmark-table-of-contents)[Packagist](https://packagist.org/packages/alto/commonmark-table-of-contents)TabsAccessible ARIA tabbed UI from a simple `@tabs` directive[GitHub](https://github.com/PhpAlto/commonmark-tabs)[Packagist](https://packagist.org/packages/alto/commonmark-tabs)Extensions
----------

[](#extensions)

### CodeBlockTitle

[](#codeblocktitle)

The detail that signals craft — adds a `title="..."` to any fenced code block and wraps it in a semantic ``/``. One small thing that makes a doc site feel finished.

```
```php title="hello.php"
echo "Hello";
```
```

```

  hello.php
  echo "Hello";

```

[Doc](src/Extension/CodeBlockTitle/README.md) · [GitHub](https://github.com/alto/commonmark/tree/main/src/Extension/CodeBlockTitle) · [Packagist](https://packagist.org/packages/alto/commonmark-code-block-title)

---

### ContentSlicer

[](#contentslicer)

The rarest one in the set. Most processors stop at rendering headings as tags — this one restructures the entire document into a properly nested `` tree, giving CSS selectors, JavaScript, and accessibility tooling something real to work with. No custom syntax needed.

```
## Subtopic 1
More content.
## Subtopic 2
Final content.
```

```
Subtopic 1More content.
Subtopic 2Final content.
```

[Doc](src/Extension/ContentSlicer/README.md) · [GitHub](https://github.com/alto/commonmark/tree/main/src/Extension/ContentSlicer) · [Packagist](https://packagist.org/packages/alto/commonmark-content-slicer)

---

### HeadingLevel

[](#headinglevel)

The one you don't need until you really do — then it's irreplaceable. Shifts, remaps, or transforms heading levels when embedding content from one context into another without heading hierarchy collisions.

```
# Title
## Section
```

```

Title
Section
```

[Doc](src/Extension/HeadingLevel/README.md) · [GitHub](https://github.com/alto/commonmark/tree/main/src/Extension/HeadingLevel) · [Packagist](https://packagist.org/packages/alto/commonmark-heading-level)

---

### Import

[](#import)

Solves copy-paste drift between your docs and your source code. Pulls external file content directly into a code block — with line-range selection, language hinting, and depth-limited circular-import protection.

```
@import "src/Auth.php" {lines: 1-30, lang: php}
```

```
// src/Auth.php lines 1–30

```

[Doc](src/Extension/Import/README.md) · [GitHub](https://github.com/alto/commonmark/tree/main/src/Extension/Import) · [Packagist](https://packagist.org/packages/alto/commonmark-import)

---

### Include

[](#include)

The backbone of large documentation sets. Pulls in and fully parses markdown fragments inline — making one-file-per-section composition possible without a build system.

```
@include "parts/intro.md"
```

```
Introduction
This is the introduction section.
```

[Doc](src/Extension/Include/README.md) · [GitHub](https://github.com/alto/commonmark/tree/main/src/Extension/Include) · [Packagist](https://packagist.org/packages/alto/commonmark-include)

---

### LinkRewriter

[](#linkrewriter)

Indispensable plumbing for any hosted documentation setup. Decouples your markdown from your deployment URL with a composable chain of rewrite rules — base URI, exact maps, regex, and custom callbacks — applied in sequence.

```
[Guide](/getting-started)
![Logo](/assets/logo.svg)
```

```

Guide

```

[Doc](src/Extension/LinkRewriter/README.md) · [GitHub](https://github.com/alto/commonmark/tree/main/src/Extension/LinkRewriter) · [Packagist](https://packagist.org/packages/alto/commonmark-link-rewriter)

---

### Source

[](#source)

The flagship of the set. Embeds a real file — not a copy — directly into your documentation, with syntax detection, line-range selection, line numbers, and per-line highlighting. Your docs stay in sync with your code by definition.

```
@source "src/Service.php" {lines: 9-11, numbers: true, highlight: "9,11"}
```

```

  src/Service.php
  9    public function add(int $a, int $b): int
10    {
11        return $a + $b;

```

[Doc](src/Extension/Source/README.md) · [GitHub](https://github.com/alto/commonmark/tree/main/src/Extension/Source) · [Packagist](https://packagist.org/packages/alto/commonmark-source)

---

### TableOfContents

[](#tableofcontents)

A must-have for any document longer than a page. Drop `@toc` where you want the contents list — headings are collected, IDs assigned, and a navigable list rendered in one pass.

```
@toc {min: 2}
## Introduction
## Setup
```

```

    Introduction
    Setup

```

[Doc](src/Extension/TableOfContents/README.md) · [GitHub](https://github.com/alto/commonmark/tree/main/src/Extension/TableOfContents) · [Packagist](https://packagist.org/packages/alto/commonmark-table-of-contents)

---

### Tabs

[](#tabs)

One directive, fully accessible tabbed UI, zero JavaScript to write. Wraps content in proper ARIA `tablist`/`tab`/`tabpanel` roles with a self-contained switching script.

```
@tabs
@tab "PHP"
```php
echo 'Hello';
```
@tab "JS"
```js
console.log('Hello');
```
@endtabs
```

```

    PHP
    JS

    …
    …

```

[Doc](src/Extension/Tabs/README.md) · [GitHub](https://github.com/alto/commonmark/tree/main/src/Extension/Tabs) · [Packagist](https://packagist.org/packages/alto/commonmark-tabs)

Support
-------

[](#support)

If Alto CommonMark is useful to your project, [sponsoring on GitHub](https://github.com/sponsors/smnandre) is a great way to support continued development — and it's always appreciated.

License
-------

[](#license)

MIT. See [LICENSE](LICENSE).

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance58

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 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.

### 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 (1 commits)")

---

Tags

commonmarkcommonmark-extensionincludemarkdownmarkdown-extensionphp-markdownsourcetabstoc

### Embed Badge

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

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

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19037.7M41](/packages/mck89-peast)[karriere/json-decoder

JsonDecoder implementation that allows you to convert your JSON data into PHP class objects

141439.4k12](/packages/karriere-json-decoder)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9642.0k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

45143.1k6](/packages/jstewmc-rtf)[json-mapper/laravel-package

The JsonMapper package for Laravel

25188.9k3](/packages/json-mapper-laravel-package)[jamesmoss/toml

A parser for TOML implemented in PHP.

3231.7k15](/packages/jamesmoss-toml)

PHPackages © 2026

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