PHPackages                             wnx/commonmark-markdown-renderer - 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. wnx/commonmark-markdown-renderer

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

wnx/commonmark-markdown-renderer
================================

Render Markdown AST back to Markdown.

v1.6.0(6mo ago)9318.3k↑20.4%2[2 issues](https://github.com/stefanzweifel/commonmark-markdown-renderer/issues)[1 PRs](https://github.com/stefanzweifel/commonmark-markdown-renderer/pulls)4MITPHPPHP ^8.1CI passing

Since Aug 3Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/stefanzweifel/commonmark-markdown-renderer)[ Packagist](https://packagist.org/packages/wnx/commonmark-markdown-renderer)[ Docs](https://github.com/stefanzweifel/commonmark-markdown-renderer)[ GitHub Sponsors](https://github.com/stefanzweifel)[ RSS](/packages/wnx-commonmark-markdown-renderer/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (5)Versions (13)Used By (4)

Render Markdown AST back to Markdown.
=====================================

[](#render-markdown-ast-back-to-markdown)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bd6587f397f6461e5d2c1727c69e58d0647a2d02d828c2d1856e71921a72f2cd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776e782f636f6d6d6f6e6d61726b2d6d61726b646f776e2d72656e64657265722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wnx/commonmark-markdown-renderer)[![Tests](https://github.com/stefanzweifel/commonmark-markdown-renderer/actions/workflows/run-tests.yml/badge.svg)](https://github.com/stefanzweifel/commonmark-markdown-renderer/actions/workflows/run-tests.yml)[![Check & fix styling](https://github.com/stefanzweifel/commonmark-markdown-renderer/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/stefanzweifel/commonmark-markdown-renderer/actions/workflows/php-cs-fixer.yml)[![Total Downloads](https://camo.githubusercontent.com/b6bf7c96ea9eede237a7968f5820b980e668a0aa55fdbb7579945d92f2a2ec6c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f776e782f636f6d6d6f6e6d61726b2d6d61726b646f776e2d72656e64657265722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wnx/commonmark-markdown-renderer)

Render a league/commonmark AST back to Markdown.

**Note**: Markdown knows alternate syntaxes for the same elements (heading, emphasis, unordered lists, horizontal rules). Therefore input and output Markdown may differ.

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

[](#installation)

You can install the package via composer:

```
composer require wnx/commonmark-markdown-renderer
```

Usage
-----

[](#usage)

```
use League\CommonMark\Environment\Environment;
use League\CommonMark\Parser\MarkdownParser;
use Wnx\CommonmarkMarkdownRenderer\MarkdownRendererExtension;
use Wnx\CommonmarkMarkdownRenderer\Renderer\MarkdownRenderer;

$environment = new Environment($config);
$environment->addExtension(new MarkdownRendererExtension());

$markdownParser = new MarkdownParser($environment);
$markdownRenderer = new MarkdownRenderer($environment);

$markdown = "**Hello World!**";

$documentAST = $markdownParser->parse($markdown);

// Manipulate AST in your script (append, prepend or replace nodes)

$markdown = $markdownRenderer->renderDocument($documentAST);
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Stefan Zweifel](https://github.com/stefanzweifel)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance67

Regular maintenance activity

Popularity42

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 88.1% 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

Every ~157 days

Recently: every ~211 days

Total

11

Last Release

198d ago

PHP version history (2 changes)v1.0.0PHP ^8.0

v1.3.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/b6e76cb0a5ed6788731857a8b4e1a27e283cef831fe42bf9636549bf9b35ddd7?d=identicon)[stefanzweifel](/maintainers/stefanzweifel)

---

Top Contributors

[![stefanzweifel](https://avatars.githubusercontent.com/u/1080923?v=4)](https://github.com/stefanzweifel "stefanzweifel (37 commits)")[![GuySartorelli](https://avatars.githubusercontent.com/u/36352093?v=4)](https://github.com/GuySartorelli "GuySartorelli (3 commits)")[![weph](https://avatars.githubusercontent.com/u/1123079?v=4)](https://github.com/weph "weph (2 commits)")

---

Tags

commonmarkcommonmark-extensionmarkdownmarkdownrendererwnxcommonmark-markdown-renderer

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/wnx-commonmark-markdown-renderer/health.svg)

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

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[daux/daux.io

Documentation generator that uses a simple folder structure and Markdown files to create custom documentation on the fly

826195.5k1](/packages/daux-dauxio)[torchlight/torchlight-commonmark

A Commonmark extension for Torchlight, the syntax highlighting API.

29265.5k6](/packages/torchlight-torchlight-commonmark)[maglnet/magl-markdown

Provides a ZF2 View Helper to render markdown syntax. It uses third-party libraries for the rendering and you can switch between different renderers.

22194.6k4](/packages/maglnet-magl-markdown)[zoon/commonmark-ext-youtube-iframe

Extension for league/commonmark to replace youtube link with iframe

12281.0k1](/packages/zoon-commonmark-ext-youtube-iframe)[spatie/commonmark-wire-navigate

Add a wire:navigate attribute to links rendered in Markdown

1012.1k](/packages/spatie-commonmark-wire-navigate)

PHPackages © 2026

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