fluxbb/commonmark

Object-oriented and extensible PHP 5.4+ CommonMark spec-compliant Markdown parser

dev-master / 1.0.x-dev 2015-04-09 14:37 UTC

README

Latest Stable Version Build Status License

An object oriented, fully extensible CommonMark parser for PHP 5.4 and above.

CommonMark spec

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.