league/commonmark
Extensible PHP Markdown parser supporting the full CommonMark spec and GitHub-Flavored Markdown. Works with PHP 7.4+ (mbstring) and provides simple converters to turn Markdown into HTML with configurable safety options.
{% assign version = site.data.project.default_version %}
use League\CommonMark\CommonMarkConverter;
$converter = new CommonMarkConverter();
echo $converter->convert('# Hello World!');
// <h1>Hello World!</h1>
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>
This project includes [several built-in extensions you can use](/{{ version }}/extensions/overview/) to enable additional features and syntax.
This library allows you to add custom syntax, renderers, and more. Check out the [Customization](/{{ version }}/customization/overview/) section for more information.
An updated list of pre-built integrations and extensions can be found in the Related Packages section of the README.
How can I help you explore Laravel packages today?