This package provides an extension for league/commonmark
that lets you embed Laravel Blade code inside of your Markdown content.
You can install the package via Composer:
composer require ryangjchandler/commonmark-blade-block
Start by registering the extension.
use League\CommonMark\MarkdownConverter;
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use RyanChandler\CommonmarkBladeBlock\BladeExtension;
$environment = new Environment();
$environment
->addExtension(new CommonMarkCoreExtension)
->addExtension(new BladeExtension);
$converter = new MarkdownConverter($environment);
Then start embedding Blade inside of your Markdown content with the @blade
and @endblade
tags.
# Hello, world!
@blade
<x-button>
Click me!
</x-button>
@endblade
If you're using Str::markdown()
or str()->markdown()
, then you can register the extension through the extensions
argument.
Str::markdown(
<<<'MD'
@blade
<x-button></x-button>
@endblade
MD,
extensions: [
new BladeExtension(),
]
)
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.