An object oriented, fully extensible CommonMark parser for PHP 5.4 and above.
- Forked from Ciconia by Kazuyuki Hayashi
- Tested to comply with the full CommonMark spec test suite
- PHP 5.4+
- Composer
Add the library to your Composer dependencies:
composer require fluxbb/commonmark
Next, use Composer to install the library and its dependencies:
composer install
use FluxBB\CommonMark\Parser;
$parser = new Parser();
$html = $parser->render('Markdown is **awesome**');
// <p>Markdown is <em>awesome</em></p>
The parser renders XHTML by default.
Basic usage: (Outputs result to STDOUT)
bin/markdown /path/to/file.md
The following command saves results to a file:
bin/markdown /path/to/file.md > /path/to/file.html
Or using pipe (does not work on Windows):
echo "Markdown is **awesome**" | bin/markdown
--compress (-c) Remove whitespace between HTML tags
--lint (-l) Syntax check only (lint)
You can also use a single phar file
markdown.phar /path/to/file.md
If you prefer access this command globally, download markdown.phar and move it into your PATH
.
mv markdown.phar /usr/local/bin/markdown
Install or update dev
dependencies.
php composer.phar update --dev
and run phpunit
The MIT License
Feel free to fork this repository and send pull requests. Take a look at who has contributed so far.
A big thanks to Kazuyuki Hayashi (@kzykhys), who originally created this library.