webuni/commonmark-attributes-extension
Adds Kramdown-style attribute lists to League/CommonMark markdown, letting you assign HTML ids, classes, and other attributes to block and span elements. Deprecated: use the built-in Attributes extension in league/commonmark 1.5+ instead.
league/commonmark v1.5+’s built-in Attributes extension. Integrating this package introduces unnecessary technical debt, as it adds no unique value beyond what the upstream library already provides.league/commonmark <1.5 or has custom forks incompatible with the native extension. For all other cases, this package offers zero architectural advantage.spatie/laravel-markdown) or other league/commonmark extensions.Tables or Gfm) that may not be documented.league/commonmark versions).league/commonmark versions due to lack of updates.composer.json to avoid surprises.league/commonmark releases for native attribute support improvements.Why Not Use the Native Extension?
league/commonmark version <1.5?league/commonmark v1.5+?Long-Term Viability
Alternative Solutions
Impact Assessment
league/commonmark v1.5+ vs. the risk of using this deprecated package?league/commonmark (v0.x or v1.x). Not recommended for Laravel 9+ (PHP 8.0+), as the package lacks modern PHP support.spatie/laravel-markdown (Laravel’s default markdown parser).league/commonmark extensions (e.g., league/commonmark-gfm).create_function).Audit Current Stack
league/commonmark version:
composer show league/commonmark
Attributes.Integration Steps (If Proceeding)
composer.json:
"require": {
"webuni/commonmark-attributes-extension": "^1.0",
"league/commonmark": "^1.0" // Ensure compatible version
}
use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Extension\Attributes\AttributesExtension;
use Illuminate\Support\ServiceProvider;
class MarkdownServiceProvider extends ServiceProvider {
public function register() {
$this->app->singleton('markdown.converter', function () {
$config = new \League\CommonMark\Config\Config();
$config->addExtension(new AttributesExtension());
return new CommonMarkConverter($config);
});
}
}
use Illuminate\Support\Facades\Blade;
Blade::directive('markdown', function ($expression) {
$markdown = app('markdown.converter')->convertToHtml($expression);
return "<?php echo {$markdown}; ?>";
});
Fallback for Laravel’s Default Parser
spatie/laravel-markdown, override the parser in config/markdown.php:
'parser' => function () {
$config = new \League\CommonMark\Config\Config();
$config->addExtension(new \Webuni\CommonMark\AttributesExtension\AttributesExtension());
return new \League\CommonMark\CommonMarkConverter($config);
},
spatie/laravel-newsletter).php artisan optimize:clear is run after changes.league/commonmark-tables or league/commonmark-smiley to ensure attribute parsing doesn’t interfere.Short-Term (Temporary Workaround)
Medium-Term (Upgrade to Native Extension)
league/commonmark to v1.5+:
composer require league/commonmark:^1.5
use League\CommonMark\Extension\Attributes\AttributesExtension;
$config->addExtension(new AttributesExtension());
Long-Term (Deprecation)
league/commonmark’s built-in features.league/commonmark to a specific version to avoid breaking changes.league/commonmark internals.league/commonmark’s release notes for relevant changes.league/commonmark is already loaded.| Failure Scenario | Impact | **Mitigation
How can I help you explore Laravel packages today?