fluxbb / commonmark
Object-oriented and extensible PHP 5.4+ CommonMark spec-compliant Markdown parser
Requires
- php: >5.4.0
- symfony/console: ~2.3
- symfony/options-resolver: ~2.3
Requires (Dev)
- kzykhys/pygments: >=1.0
- phpunit/phpunit: ~4.0
- symfony/finder: >=2.3,<2.5-dev
- symfony/stopwatch: >=2.3,<2.5-dev
Suggests
- kzykhys/pygments: >=1.0
This package is auto-updated.
Last update: 2024-11-05 18:19:29 UTC
README
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
Requirements
- PHP 5.4+
- Composer
Installation
Add the library to your Composer dependencies:
composer require fluxbb/commonmark
Next, use Composer to install the library and its dependencies:
composer install
Usage
Parsing
use FluxBB\CommonMark\Parser; $parser = new Parser(); $html = $parser->render('Markdown is **awesome**'); // <p>Markdown is <em>awesome</em></p>
Rendering
The parser renders XHTML by default.
Command Line Interface
Usage
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
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
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
Testing
Install or update dev
dependencies.
php composer.phar update --dev
and run phpunit
License
The MIT License
Contributing
Feel free to fork this repository and send pull requests. Take a look at who has contributed so far.
Author
A big thanks to Kazuyuki Hayashi (@kzykhys), who originally created this library.