An extensible CommonMark parser for PHP
, (*1)
An object oriented, fully extensible CommonMark parser for PHP 5.4 and above., (*2)
CommonMark spec, (*3)
Requirements
Installation
Add the library to your Composer dependencies:, (*4)
composer require fluxbb/commonmark
Next, use Composer to install the library and its dependencies:, (*5)
composer install
Usage
Parsing
use FluxBB\CommonMark\Parser;
$parser = new Parser();
$html = $parser->render('Markdown is **awesome**');
//
Markdown is awesome, (*6)
Rendering
The parser renders XHTML by default., (*7)
Command Line Interface
Usage
Basic usage: (Outputs result to STDOUT), (*8)
bin/markdown /path/to/file.md
The following command saves results to a file:, (*9)
bin/markdown /path/to/file.md > /path/to/file.html
Or using pipe (does not work on Windows):, (*10)
echo "Markdown is **awesome**" | bin/markdown
Command Line Options
--compress (-c) Remove whitespace between HTML tags
--lint (-l) Syntax check only (lint)
Using PHAR version
You can also use a single phar file, (*11)
markdown.phar /path/to/file.md
If you prefer access this command globally, download markdown.phar and move it into your PATH
., (*12)
mv markdown.phar /usr/local/bin/markdown
Testing
Install or update dev
dependencies., (*13)
php composer.phar update --dev
and run phpunit
, (*14)
License
The MIT License, (*15)
Contributing
Feel free to fork this repository and send pull requests. Take a look at who has contributed so far., (*16)
Author
A big thanks to Kazuyuki Hayashi (@kzykhys), who originally created this library., (*17)