league/commonmark-ext-table
Deprecated CommonMark table extension for PHP. Adds GitHub Flavored Markdown-style tables (alignment, header/body) to league/commonmark environments. Use league/commonmark 1.3+ instead, which includes the same Table extension under League\CommonMark\Extension\Table.
Environment configurations.<thead>, <tbody>, alignment via text-align), reducing reliance on CSS/JS for basic table styling. Supports captions (MultiMarkdown), useful for accessibility or metadata.Str helpers for dynamic content.league/commonmark v1.3+: Bundled TableExtension replaces this package, reducing dependency sprawl. Low risk if upgrading.commonmark.league/commonmark (v1.3+).TableExtension in commonmark v1.3+. Namespace change (League\CommonMark\Extension\Table) is the only adjustment needed.style attributes). Workaround: Extend the HtmlRenderer or use post-processing.league/commonmark v1.3+ already in use?
TableExtension immediately to avoid deprecated code.commonmark version.---, :---:) matches current usage. Test edge cases like empty cells, merged headers, or Unicode characters.htmlspecialchars) to prevent XSS via malicious Markdown (e.g., <script> in table cells).commonmark’s extension ecosystem.return response()->html($converter->convert($markdown));).php artisan markdown:render) for batch updates (e.g., docs).composer.json for league/commonmark version. If <1.3, proceed with integration; if ≥1.3, skip to Step 3.composer require league/commonmark-ext-table
commonmark v1.3+ (Recommended):
composer require league/commonmark:^1.3
use League\CommonMark\Ext\Table\TableExtension; with:
use League\CommonMark\Extension\Table\TableExtension;
$environment->addExtension(new \League\CommonMark\Ext\Table\TableExtension());
with:
$environment->addExtension(new \League\CommonMark\Extension\Table\TableExtension());
| Header |, ---|---, :---: for alignment).= Header = in CommonMark).<table> elements).RendererInterface.// app/Providers/AppServiceProvider.php
public function register()
{
$this->app->singleton(Converter::class, function () {
$environment = Environment::createCommonMarkEnvironment();
$environment->addExtension(new \League\CommonMark\Extension\Table\TableExtension());
return new Converter(new DocParser($environment), new HtmlRenderer($environment));
});
}
@markdown directive for templates./render-markdown route for dynamic content.commonmark v1.3+ and update namespaces.league/commonmark-ext-table from composer.json.commonmark as needed (e.gHow can I help you explore Laravel packages today?