league/commonmark

Markdown done right

$ composer require league/commonmark

Author Latest Version Total Downloads Software License Build Status Coverage Status Quality Score

Highlights

The PHP CommonMark parser is a robust, highly-extensible Markdown parser for PHP based on the CommonMark and GitHub-Flavored Markdown specifications.

  1. The only PHP library fully compatible with the CommonMark and GitHub-Flavored Markdown specs

  2. Highly extensible architecture supports custom syntax and other customizations

  3. Community extensions and integrations for popular frameworks and CMSes

  4. Easy-to-use API

Features

Easy Usage

use League\CommonMark\CommonMarkConverter;

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

// <h1>Hello World!</h1>

Security

All CommonMark features are supported by default, including raw HTML and unsafe links, which you may want to disable using the html_input and allow_unsafe_links options:

use League\CommonMark\CommonMarkConverter;

$converter = new CommonMarkConverter(['html_input' => 'escape', 'allow_unsafe_links' => false]);
echo $converter->convert('# Hello World!');

// <h1>Hello World!</h1>

Included Extensions

This project includes several built-in extensions you can use to enable additional features and syntax.

Customization

This library allows you to add custom syntax, renderers, and more. Check out the Customization section for more information.

Community Integrations & Extensions

An updated list of pre-built integrations and extensions can be found in the Related Packages section of the README.

Sponsors

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

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

Questions?

league/commonmark was created by Colin O'Dell. Find him on Twitter at @colinodell.