ryangjchandler/commonmark-blade-block

Embed Laravel Blade code inside of your Markdown templates.
7,732 22
Install
composer require ryangjchandler/commonmark-blade-block
Latest Version:v1.1.1
PHP:^8.2
Laravel:12 · 13
License:MIT
Last Updated:Jun 22, 2026
Links: GitHub  ·  Packagist
Maintainer: ryangjchandler

Embed Laravel Blade code inside of your Markdown templates.

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides an extension for league/commonmark that lets you embed Laravel Blade code inside of your Markdown content.

Installation

You can install the package via Composer:

composer require ryangjchandler/commonmark-blade-block

Usage

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

Using Laravel's Str or str() helpers

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(),
    ]
)

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

641,106,524 9,700
laravel/framework

The Laravel Framework.

593,882,149 34,959
laravel/tinker

Powerful REPL for the Laravel framework.

502,645,077 7,441
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

418,291,778 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

394,964,158 4,660

Version History

Version Released PHP Laravel License
v1.1.1 ^8.2 ^12.0 | ^13.0 MIT
v1.1.0 ^8.2 ^12.0 MIT
v1.0.0 ^8.2 ^10.0||^11.0 MIT