2017 © Pedro PelΓ‘ez
 

library commonmark

Markdown parser for PHP based on the CommonMark spec

image

league/commonmark

Markdown parser for PHP based on the CommonMark spec

  • Friday, April 13, 2018
  • by frankdejonge
  • Repository
  • 39 Watchers
  • 977 Stars
  • 2,047,721 Installations
  • PHP
  • 145 Dependents
  • 12 Suggesters
  • 83 Forks
  • 13 Open issues
  • 48 Versions
  • 8 % Grown

The README.md

league/commonmark

Latest Version Total Downloads Software License Build Status Coverage Status Quality Score Psalm Type Coverage CII Best Practices Sponsor development of this project, (*1)

league/commonmark, (*2)

league/commonmark is a highly-extensible PHP Markdown parser created by Colin O'Dell which supports the full CommonMark spec and GitHub-Flavored Markdown. It is based on the CommonMark JS reference implementation by John MacFarlane [@jgm]., (*3)

πŸ“¦ Installation & Basic Usage

This project requires PHP 7.4 or higher with the mbstring extension. To install it via Composer simply run:, (*4)

``` bash $ composer require league/commonmark, (*5)


The `CommonMarkConverter` class provides a simple wrapper for converting CommonMark to HTML: ```php 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:, (*6)

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., (*7)

[!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 https://commonmark.thephpleague.com/security/ for more details. If you also do choose to allow raw HTML input from untrusted users, consider using a library (like HTML Purifier) to provide additional HTML filtering., (*8)

πŸ““ Documentation

Full documentation on advanced usage, configuration, and customization can be found at commonmark.thephpleague.com., (*9)

⏫ Upgrading

Information on how to upgrade to newer versions of this library can be found at https://commonmark.thephpleague.com/releases., (*10)

πŸ’» GitHub-Flavored Markdown

The GithubFlavoredMarkdownConverter shown earlier is a drop-in replacement for the CommonMarkConverter which adds additional features found in the GFM spec:, (*11)

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

See the Extensions documentation for more details on how to include only certain GFM features if you don't want them all., (*12)

Integrations

Included Extensions

See our extension documentation for a full list of extensions bundled with this library., (*13)

Community Extensions

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

Others can be found on Packagist under the commonmark-extension package type., (*15)

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

Others

Check out the other cool things people are doing with league/commonmark: https://packagist.org/packages/league/commonmark/dependents, (*17)

🏷️ Versioning

SemVer 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., (*18)

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., (*19)

πŸ› οΈ Maintenance & Support

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

When a new major version is released (e.g. 1.6 -> 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., (*21)

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

Professional support, including notification of new releases and security updates, is available through a Tidelift Subscription., (*23)

πŸ‘·β€β™€οΈ Contributing

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure with us., (*24)

If you encounter a bug in the spec, please report it to the CommonMark project. Any resulting fix will eventually be implemented in this project as well., (*25)

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

Major refactoring to core parsing logic should be avoided if possible so that we can easily follow updates made to the reference implementation. 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., (*27)

Please see CONTRIBUTING for additional details., (*28)

πŸ§ͺ Testing

``` bash $ composer test, (*29)


This will also test league/commonmark against the latest supported spec. ## πŸš€ Performance Benchmarks You can compare the performance of **league/commonmark** to other popular parsers by running the included benchmark tool: ``` bash $ ./tests/benchmark/benchmark.php

πŸ‘₯ Credits & Acknowledgements

This code was originally based on the CommonMark JS reference implementation which is written, maintained, and copyrighted by John MacFarlane. This project simply wouldn't exist without his work., (*30)

And a huge thanks to all of our amazing contributors:, (*31)

, (*32)

Sponsors

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

Are you interested in sponsoring development of this project? See https://www.colinodell.com/sponsor for a list of ways to contribute., (*34)

πŸ“„ License

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

πŸ›οΈ Governance

This project is primarily maintained by Colin O'Dell. Members of the PHP League Leadership Team may occasionally assist with some of these duties., (*36)

πŸ—ΊοΈ Who Uses It?

This project is used by Drupal, Laravel Framework, Cachet, Firefly III, Neos, Daux.io, and more!, (*37)


Get professional support for league/commonmark with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

The Versions

13/04 2018

dev-master

9999999-dev https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • ext-mbstring *
  • php >=5.6.5

 

The Development Requires

parser markdown commonmark

29/03 2018

dev-release-0.17.5

dev-release-0.17.5 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.6.5
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

29/03 2018

0.17.5

0.17.5.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.6.5
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

29/03 2018

dev-release-0.17.4

dev-release-0.17.4 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.6.5
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

29/03 2018

0.17.4

0.17.4.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.6.5
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

26/03 2018

0.17.3

0.17.3.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.6.5
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

26/03 2018

dev-spec-next

dev-spec-next https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.6.5
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

26/03 2018

0.17.2

0.17.2.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.6.5
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

18/03 2018

0.17.1

0.17.1.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.6.5
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

30/12 2017

0.17.0

0.17.0.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.6.5
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

31/10 2017

0.16.0

0.16.0.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

26/10 2017

0.15.7

0.15.7.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

26/10 2017

dev-feature/resolve-parent-class

dev-feature/resolve-parent-class https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

08/08 2017

0.15.6

0.15.6.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

05/08 2017

0.15.5

0.15.5.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

09/05 2017

0.15.4

0.15.4.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

19/12 2016

0.15.3

0.15.3.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

22/11 2016

0.15.2

0.15.2.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

08/11 2016

0.15.1

0.15.1.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

14/09 2016

0.15.0

0.15.0.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

02/07 2016

0.14.0

0.14.0.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

14/06 2016

0.13.4

0.13.4.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

21/05 2016

0.13.3

0.13.3.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

27/03 2016

0.13.2

0.13.2.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

09/03 2016

0.13.1

0.13.1.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

14/01 2016

0.13.0

0.13.0.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

04/11 2015

0.12.0

0.12.0.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

25/09 2015

0.11.3

0.11.3.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

23/09 2015

0.11.2

0.11.2.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

22/09 2015

0.11.1

0.11.1.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

19/09 2015

0.11.0

0.11.0.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

25/07 2015

0.10.0

0.10.0.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

19/06 2015

0.9.0

0.9.0.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

29/04 2015

0.8.0

0.8.0.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.8
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

08/03 2015

0.7.2

0.7.2.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.3
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

01/03 2015

0.7.1

0.7.1.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.3
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

17/02 2015

0.7.0

0.7.0.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.3
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

25/01 2015

0.6.1

0.6.1.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.3
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

09/01 2015

0.6.0

0.6.0.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.3
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

27/12 2014

0.5.1

0.5.1.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.3

 

The Development Requires

parser markdown commonmark

24/12 2014

0.5.0

0.5.0.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.3
  • ext-mbstring *

 

The Development Requires

parser markdown commonmark

15/12 2014

0.4.0

0.4.0.0 https://github.com/thephpleague/commonmark

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

parser markdown commonmark

29/11 2014

0.3.0

0.3.0.0 https://github.com/colinodell/commonmark-php

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

parser markdown commonmark

10/11 2014

0.2.1

0.2.1.0 https://github.com/colinodell/commonmark-php

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

The Development Requires

parser markdown commonmark

10/11 2014

0.2.0

0.2.0.0 https://github.com/colinodell/commonmark-php

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

The Development Requires

parser markdown commonmark

28/09 2014

0.1.2

0.1.2.0 https://github.com/colinodell/commonmark-php

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

The Development Requires

parser markdown commonmark

08/09 2014

0.1.1

0.1.1.0 https://github.com/colinodell/commonmark-php

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

The Development Requires

parser markdown commonmark

08/09 2014

0.1.0

0.1.0.0 https://github.com/colinodell/commonmark-php

Markdown parser for PHP based on the CommonMark spec

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

The Development Requires

parser markdown commonmark