The table extension for CommonMark PHP implementation
The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:
League\CommonMark\Extension\Tablenamespace, so you should upgrade to that version and use that bundled extension instead of this one.
The Table extension adds the ability to create tables in CommonMark documents.
This project can be installed via Composer:
composer require league/commonmark-ext-table
Environmentas usual and simply add the
TableExtensionprovided by this package:
use League\CommonMark\Converter; use League\CommonMark\DocParser; use League\CommonMark\Environment; use League\CommonMark\HtmlRenderer; use League\CommonMark\Ext\Table\TableExtension;
// Obtain a pre-configured Environment with all the standard CommonMark parsers/renderers ready-to-go $environment = Environment::createCommonMarkEnvironment();
// Add this extension $environment->addExtension(new TableExtension());
// Instantiate the converter engine and start converting some Markdown! $converter = new Converter(new DocParser($environment), new HtmlRenderer($environment));
echo $converter->convertToHtml('# Hello World!');
This package is fully compatible with GFM-style tables:
markdown th | th(center) | th(right) ---|:----------:|----------: td | td | td
| header 1 | header 2 | header 2 | | :------- | :------: | -------: | | cell 1.1 | cell 1.2 | cell 1.3 | | cell 2.1 | cell 2.2 | cell 2.3 |
header 1 | header 2 -------- | -------- cell 1.1 | cell 1.2 [Simple table]
markdown header 1 | header 2 -------- | -------- cell 1.1 | cell 1.2 [*Prototype* table][reference_table]
|header 1||header 2|
|cell 1.1||cell 1.2|
Please refer to the CHANGELOG for more information on what has changed recently.
You need to have php or docker installed to develop the library. To list all available commands run:
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
This library is licensed under the MIT license. See the License File for more information.