PHPackages                             colinodell/commonmark-php - 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. colinodell/commonmark-php

Abandoned → [league/commonmark](/?search=league%2Fcommonmark)Library[Parsing &amp; Serialization](/categories/parsing)

colinodell/commonmark-php
=========================

Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)

2.8.2(1mo ago)2.9k2.4k210[22 issues](https://github.com/thephpleague/commonmark/issues)[7 PRs](https://github.com/thephpleague/commonmark/pulls)BSD-3-ClausePHPPHP ^7.4 || ^8.0CI passing

Since Sep 8Pushed 1mo ago34 watchersCompare

[ Source](https://github.com/thephpleague/commonmark)[ Packagist](https://packagist.org/packages/colinodell/commonmark-php)[ Docs](https://commonmark.thephpleague.com)[ Fund](https://www.colinodell.com/sponsor)[ Fund](https://www.paypal.me/colinpodell/10.00)[ RSS](/packages/colinodell-commonmark-php/feed)WikiDiscussions 2.8 Synced 1mo ago

READMEChangelog (10)Dependencies (42)Versions (159)Used By (0)

league/commonmark
=================

[](#leaguecommonmark)

[![Latest Version](https://camo.githubusercontent.com/0c680c7a1cdc2b649fe90c24fb266c2d10fb08604ae3a4a3260742a5cd51d5ad/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c65616775652f636f6d6d6f6e6d61726b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/league/commonmark)[![Total Downloads](https://camo.githubusercontent.com/fd75234be37ad4e44060e87eb88dbce30c0e25125f79cdf0d55305cb461fb0a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c65616775652f636f6d6d6f6e6d61726b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/league/commonmark)[![Software License](https://camo.githubusercontent.com/d8c1f1b4c1b899449e9539d4de1ca66abde4c190f41ce41e7abc3330da5cad2e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4253442d2d332d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/736f36289d2bb5c09348a819abe1244699cc30c92e70d1d69c6758e906bb034c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7468657068706c65616775652f636f6d6d6f6e6d61726b2f74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265)](https://github.com/thephpleague/commonmark/actions?query=workflow%3ATests+branch%3Amain)[![Coverage Status](https://camo.githubusercontent.com/766357529e680b5d6c3661bda83b64a326b5b25df12ad298261b871edd878ba2/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f7468657068706c65616775652f636f6d6d6f6e6d61726b2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/thephpleague/commonmark/code-structure)[![Quality Score](https://camo.githubusercontent.com/ab46673002990534cd6f1550c0ea7b1829b95c98f24e66f2b14856d28bc290fd/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7468657068706c65616775652f636f6d6d6f6e6d61726b2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/thephpleague/commonmark)[![Psalm Type Coverage](https://camo.githubusercontent.com/f6c4e07dddc3b76693f741e8a8f99bfe7a550c9c41b4364d40009211c3d19ef8/68747470733a2f2f73686570686572642e6465762f6769746875622f7468657068706c65616775652f636f6d6d6f6e6d61726b2f636f7665726167652e737667)](https://shepherd.dev/github/thephpleague/commonmark)[![CII Best Practices](https://camo.githubusercontent.com/048969dc98c4f246020bf623932b9128d56f8b7d2698f20f47fb50e9c3271bf1/68747470733a2f2f626573747072616374696365732e636f7265696e6672617374727563747572652e6f72672f70726f6a656374732f3132362f6261646765)](https://bestpractices.coreinfrastructure.org/projects/126)[![Sponsor development of this project](https://camo.githubusercontent.com/2e662697b46a37233abdd7e45373397aab0bd5206336533151cdf42455d81048/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73706f6e736f72253230746869732532307061636b6167652d2545322539442541342d6666363962342e7376673f7374796c653d666c61742d737175617265)](https://www.colinodell.com/sponsor)

[![league/commonmark](commonmark-banner.png)](commonmark-banner.png)

**league/commonmark** is a highly-extensible PHP Markdown parser created by [Colin O'Dell](https://www.twitter.com/colinodell) which supports the full [CommonMark](http://commonmark.org/) spec and [GitHub-Flavored Markdown](https://github.github.com/gfm/). It is based on the [CommonMark JS reference implementation](https://github.com/jgm/commonmark.js) by [John MacFarlane](http://johnmacfarlane.net) ([@jgm](https://github.com/jgm)).

📦 Installation &amp; Basic Usage
--------------------------------

[](#-installation--basic-usage)

This project requires PHP 7.4 or higher with the `mbstring` extension. To install it via [Composer](https://getcomposer.org/) simply run:

```
$ composer require league/commonmark
```

The `CommonMarkConverter` class provides a simple wrapper for converting CommonMark to HTML:

```
use League\CommonMark\CommonMarkConverter;

$converter = new CommonMarkConverter([
    'html_input' => 'strip',
    'allow_unsafe_links' => false,
]);

echo $converter->convert('# Hello World!');

// Hello World!
```

Or if you want GitHub-Flavored Markdown, use the `GithubFlavoredMarkdownConverter` class instead:

```
use League\CommonMark\GithubFlavoredMarkdownConverter;

$converter = new GithubFlavoredMarkdownConverter([
    'html_input' => 'strip',
    'allow_unsafe_links' => false,
]);

echo $converter->convert('# Hello World!');

// Hello World!
```

Please note that only UTF-8 and ASCII encodings are supported. If your Markdown uses a different encoding please convert it to UTF-8 before running it through this library.

Caution

If you will be parsing untrusted input from users, please consider setting the `html_input` and `allow_unsafe_links` options per the example above. See  for more details. If you also do choose to allow raw HTML input from untrusted users, consider using a library (like [HTML Purifier](https://github.com/ezyang/htmlpurifier)) to provide additional HTML filtering.

📓 Documentation
---------------

[](#-documentation)

Full documentation on advanced usage, configuration, and customization can be found at [commonmark.thephpleague.com](https://commonmark.thephpleague.com/).

⏫ Upgrading
-----------

[](#-upgrading)

Information on how to upgrade to newer versions of this library can be found at .

💻 GitHub-Flavored Markdown
--------------------------

[](#-github-flavored-markdown)

The `GithubFlavoredMarkdownConverter` shown earlier is a drop-in replacement for the `CommonMarkConverter` which adds additional features found in the GFM spec:

- Autolinks
- Disallowed raw HTML
- Strikethrough
- Tables
- Task Lists

See the [Extensions documentation](https://commonmark.thephpleague.com/customization/extensions/) for more details on how to include only certain GFM features if you don't want them all.

🗃️ Related Packages
-------------------

[](#️-related-packages)

### Integrations

[](#integrations)

- [CakePHP 3](https://github.com/gourmet/common-mark)
- [Drupal](https://www.drupal.org/project/markdown)
- [Laravel 4+](https://github.com/GrahamCampbell/Laravel-Markdown)
- [Sculpin](https://github.com/bcremer/sculpin-commonmark-bundle)
- [Symfony 2 &amp; 3](https://github.com/webuni/commonmark-bundle)
- [Symfony 4](https://github.com/avensome/commonmark-bundle)
- [Twig Markdown extension](https://github.com/twigphp/markdown-extension)
- [Twig filter and tag](https://github.com/aptoma/twig-markdown)
- [Laravel CommonMark Blog](https://github.com/spekulatius/laravel-commonmark-blog)

### Included Extensions

[](#included-extensions)

See [our extension documentation](https://commonmark.thephpleague.com/extensions/overview) for a full list of extensions bundled with this library.

### Community Extensions

[](#community-extensions)

Custom parsers/renderers can be bundled into extensions which extend CommonMark. Here are some that you may find interesting:

- [Emoji extension](https://github.com/ElGigi/CommonMarkEmoji) - UTF-8 emoji extension with Github tag.
- [Sup Sub extensions](https://github.com/OWS/commonmark-sup-sub-extensions) - Adds support of superscript and subscript (`` and `` HTML tags).
- [YouTube iframe extension](https://github.com/zoonru/commonmark-ext-youtube-iframe) - Replaces youtube link with iframe.
- [Lazy Image extension](https://github.com/simonvomeyser/commonmark-ext-lazy-image) - Adds various options for lazy loading of images.
- [Marker Extension](https://github.com/noah1400/commonmark-marker-extension) - Adds support of highlighted text (`` HTML tag).
- [Pygments Highlighter extension](https://github.com/DanielEScherzer/commonmark-ext-pygments-highlighter) - Adds support for highlighting code with the Pygments library.
- [LatexRenderer extension](https://github.com/samwilson/commonmark-latex) - For rendering Markdown to LaTeX.

Others can be found on [Packagist under the `commonmark-extension` package type](https://packagist.org/packages/league/commonmark?type=commonmark-extension).

If you build your own, feel free to submit a PR to add it to this list!

### Others

[](#others)

Check out the other cool things people are doing with `league/commonmark`:

🏷️ Versioning
-------------

[](#️-versioning)

[SemVer](http://semver.org/) is followed closely. Minor and patch releases should not introduce breaking changes to the codebase; however, they might change the resulting AST or HTML output of parsed Markdown (due to bug fixes, spec changes, etc.) As a result, you might get slightly different HTML, but any custom code built onto this library should still function correctly.

Any classes or methods marked `@internal` are not intended for use outside of this library and are subject to breaking changes at any time, so please avoid using them.

🛠️ Maintenance &amp; Support
----------------------------

[](#️-maintenance--support)

When a new **minor** version (e.g. `2.0` -&gt; `2.1`) is released, the previous one (`2.0`) will continue to receive security and critical bug fixes for *at least* 3 months.

When a new **major** version is released (e.g. `1.6` -&gt; `2.0`), the previous one (`1.6`) will receive critical bug fixes for *at least* 3 months and security updates for 6 months after that new release comes out.

(This policy may change in the future and exceptions may be made on a case-by-case basis.)

**Professional support, including notification of new releases and security updates, is available through a [Tidelift Subscription](https://tidelift.com/subscription/pkg/packagist-league-commonmark?utm_source=packagist-league-commonmark&utm_medium=referral&utm_campaign=readme).**

👷‍♀️ Contributing
-----------------

[](#‍️-contributing)

To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure with us.

If you encounter a bug in the spec, please report it to the [CommonMark](http://commonmark.org/) project. Any resulting fix will eventually be implemented in this project as well.

Contributions to this library are **welcome**, especially ones that:

- Improve usability or flexibility without compromising our ability to adhere to the [CommonMark spec](http://spec.commonmark.org/)
- Mirror fixes made to the [reference implementation](https://github.com/jgm/commonmark.js)
- Optimize performance
- Fix issues with adhering to the [CommonMark spec](http://spec.commonmark.org/)

Major refactoring to core parsing logic should be avoided if possible so that we can easily follow updates made to [the reference implementation](https://github.com/jgm/commonmark.js). That being said, we will absolutely consider changes which don't deviate too far from the reference spec or which are favored by other popular CommonMark implementations.

Please see [CONTRIBUTING](https://github.com/thephpleague/commonmark/blob/main/.github/CONTRIBUTING.md) for additional details.

🧪 Testing
---------

[](#-testing)

```
$ composer test
```

This will also test league/commonmark against the latest supported spec.

🚀 Performance Benchmarks
------------------------

[](#-performance-benchmarks)

You can compare the performance of **league/commonmark** to other popular parsers by running the included benchmark tool:

```
$ ./tests/benchmark/benchmark.php
```

👥 Credits &amp; Acknowledgements
--------------------------------

[](#-credits--acknowledgements)

This code was originally based on the [CommonMark JS reference implementation](https://github.com/jgm/commonmark.js) which is written, maintained, and copyrighted by [John MacFarlane](http://johnmacfarlane.net). This project simply wouldn't exist without his work.

And a huge thanks to all of our amazing contributors:

[ ![](https://camo.githubusercontent.com/89051cd875b052dd6fc144250d3519305ec05836201a9be935d78633b9f40604/68747470733a2f2f636f6e747269622e726f636b732f696d6167653f7265706f3d7468657068706c65616775652f636f6d6d6f6e6d61726b)](https://github.com/thephpleague/commonmark/graphs/contributors)### Sponsors

[](#sponsors)

We'd also like to extend our sincere thanks the following sponsors who support ongoing development of this project:

- [Tidelift](https://tidelift.com/subscription/pkg/packagist-league-commonmark?utm_source=packagist-league-commonmark&utm_medium=referral&utm_campaign=readme) for offering support to both the maintainers and end-users through their [professional support](https://tidelift.com/subscription/pkg/packagist-league-commonmark?utm_source=packagist-league-commonmark&utm_medium=referral&utm_campaign=readme) program
- [Blackfire](https://www.blackfire.io/) for providing an Open-Source Profiler subscription
- [JetBrains](https://www.jetbrains.com/) for supporting this project with complimentary [PhpStorm](https://www.jetbrains.com/phpstorm/) licenses

Are you interested in sponsoring development of this project? See  for a list of ways to contribute.

📄 License
---------

[](#-license)

**league/commonmark** is licensed under the BSD-3 license. See the [`LICENSE`](LICENSE) file for more details.

🏛️ Governance
-------------

[](#️-governance)

This project is primarily maintained by [Colin O'Dell](https://www.twitter.com/colinodell). Members of the [PHP League](https://thephpleague.com) Leadership Team may occasionally assist with some of these duties.

🗺️ Who Uses It?
---------------

[](#️--who-uses-it)

This project is used by [Drupal](https://www.drupal.org/project/markdown), [Laravel Framework](https://laravel.com/), [Cachet](https://cachethq.io/), [Firefly III](https://firefly-iii.org/), [Neos](https://www.neos.io/), [Daux.io](https://daux.io/), and [more](https://packagist.org/packages/league/commonmark/dependents)!

---

  **[Get professional support for league/commonmark with a Tidelift subscription](https://tidelift.com/subscription/pkg/packagist-league-commonmark?utm_source=packagist-league-commonmark&utm_medium=referral&utm_campaign=readme)**
  Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

###  Health Score

67

—

FairBetter than 100% of packages

Maintenance90

Actively maintained with recent releases

Popularity45

Moderate usage in the ecosystem

Community34

Small or concentrated contributor base

Maturity87

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 83% 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 ~27 days

Total

156

Last Release

59d ago

Major Versions

0.19.3 → 1.0.0-rc12019-06-20

1.6.4 → 2.0.0-beta12021-06-20

1.6.5 → 2.0.0-beta22021-06-27

1.6.6 → 2.0.0-rc22021-07-17

1.6.7 → 2.2.02022-01-22

PHP version history (7 changes)0.1.0PHP &gt;=5.3.0

0.4.0PHP &gt;=5.3.3

0.8.0PHP &gt;=5.4.8

0.17.0PHP &gt;=5.6.5

0.19.0PHP ^7.1

1.5.0PHP ^7.1 || ^8.0

2.0.0-beta1PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4325b62a6ad366c731c3120595d861469be50f9da88df3ea99752c30ff98c179?d=identicon)[colinodell](/maintainers/colinodell)

---

Top Contributors

[![colinodell](https://avatars.githubusercontent.com/u/202034?v=4)](https://github.com/colinodell "colinodell (2227 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (117 commits)")[![hason](https://avatars.githubusercontent.com/u/288535?v=4)](https://github.com/hason "hason (55 commits)")[![pdelre](https://avatars.githubusercontent.com/u/1379248?v=4)](https://github.com/pdelre "pdelre (52 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (38 commits)")[![fesor](https://avatars.githubusercontent.com/u/172247?v=4)](https://github.com/fesor "fesor (19 commits)")[![glensc](https://avatars.githubusercontent.com/u/199095?v=4)](https://github.com/glensc "glensc (19 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (16 commits)")[![0b10011](https://avatars.githubusercontent.com/u/1123348?v=4)](https://github.com/0b10011 "0b10011 (16 commits)")[![markhalliwell](https://avatars.githubusercontent.com/u/351902?v=4)](https://github.com/markhalliwell "markhalliwell (13 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (12 commits)")[![philsturgeon](https://avatars.githubusercontent.com/u/67381?v=4)](https://github.com/philsturgeon "philsturgeon (10 commits)")[![dakota](https://avatars.githubusercontent.com/u/83255?v=4)](https://github.com/dakota "dakota (8 commits)")[![xavierlacot](https://avatars.githubusercontent.com/u/177293?v=4)](https://github.com/xavierlacot "xavierlacot (7 commits)")[![vkbansal](https://avatars.githubusercontent.com/u/5930351?v=4)](https://github.com/vkbansal "vkbansal (7 commits)")[![martijnengler](https://avatars.githubusercontent.com/u/929994?v=4)](https://github.com/martijnengler "martijnengler (6 commits)")[![marijnvdwerf](https://avatars.githubusercontent.com/u/737603?v=4)](https://github.com/marijnvdwerf "marijnvdwerf (6 commits)")[![Ayesh](https://avatars.githubusercontent.com/u/811553?v=4)](https://github.com/Ayesh "Ayesh (6 commits)")[![pjeby](https://avatars.githubusercontent.com/u/3527052?v=4)](https://github.com/pjeby "pjeby (5 commits)")[![mnapoli](https://avatars.githubusercontent.com/u/720328?v=4)](https://github.com/mnapoli "mnapoli (5 commits)")

---

Tags

commonmarkgfmgithub-flavored-markdownhacktoberfestmarkdownphpparsermarkdowngithubmdgfmcommonmarkflavoredgithub-flavored

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[league/commonmark

Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)

2.9k404.0M702](/packages/league-commonmark)[erusev/parsedown

Parser for Markdown.

15.0k151.8M732](/packages/erusev-parsedown)[cebe/markdown

A super fast, highly extensible markdown parser for PHP

1.0k32.5M136](/packages/cebe-markdown)[erusev/parsedown-extra

An extension of Parsedown that adds support for Markdown Extra.

84314.8M192](/packages/erusev-parsedown-extra)[ion-bazan/composer-diff

Compares composer.lock changes and generates Markdown report so you can use it in PR description.

1861.8M3](/packages/ion-bazan-composer-diff)[parsedown/parsedown

Parser for Markdown.

21342.8k3](/packages/parsedown-parsedown)

PHPackages © 2026

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