Chisle
The coding-agent plugin that bills 52% of a bare model across 20 live tasks. Terse persona + tool-output compressor + context diet.
PHP Markdown parser featuring support for CommonMark, GFM, and custom extensions
Developer toolsPHP · HTMLGitHub @thephpleagueOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
Highly-extensible PHP Markdown parser which fully supports the CommonMark and GFM specs.
Loading the full README.
Read the full README ↗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).
This project requires PHP 7.4 or higher with the mbstring extension. To install it via Composer 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!');
// <h1>Hello World!</h1>
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!');
// <h1>Hello World!</h1>
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_inputandallow_unsafe_linksoptions 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.
Full documentation on advanced usage, configuration, and customization can be found at commonmark.thephpleague.com.
Information on how to upgrade to newer versions of this library can be found at https://commonmark.thephpleague.com/releases.
The GithubFlavoredMarkdownConverter shown earlier is a drop-in replacement for the CommonMarkConverter which adds additional features found in the GFM spec:
See the Extensions documentation for more details on how to include only certain GFM features if you don't want them all.
See our extension documentation for a full list of extensions bundled with this library.
Custom parsers/renderers can be bundled into extensions which extend CommonMark. Here are some that you may find interesting:
<sup> and <sub> HTML tags).<mark> HTML tag).This is the beginning of the README. Read the rest at the original. Read the full README ↗