Laravel Markdown
A highly configurable Markdown renderer and x-markdown Blade component for Laravel.
Repository Health
Technical Analysis
Laravel Markdown is Spatie’s package for rendering Markdown in Laravel applications. It ships both an x-markdown Blade component and a configurable MarkdownRenderer class, so you can drop Markdown straight into your Blade templates or render it programmatically.
Built on top of league/commonmark, it supports the full CommonMark spec plus configurable extensions, and integrates spatie/commonmark-shiki-highlighter for VS Code-quality code syntax highlighting. Rendered output can be cached, and every aspect of the renderer — extensions, options, highlight theme, heading anchors — is configurable.
What You Get
- An
x-markdownBlade component for rendering Markdown directly in templates - A configurable
MarkdownRendererclass for programmatic rendering, with optional caching - Shiki-powered code block syntax highlighting with configurable themes
- Configurable CommonMark extensions, heading anchors, and rendering options via a published config file
Common Use Cases
- Rendering user- or CMS-authored Markdown content in Blade views
- Building documentation, blog, or knowledge-base pages from Markdown files
- Converting Markdown to HTML with syntax-highlighted code in a Laravel app
Under The Hood
Architecture — The package registers via MarkdownServiceProvider (using spatie/laravel-package-tools), which publishes config and binds the renderer. MarkdownRenderer wraps league/commonmark’s environment, wiring in configured extensions, a Shiki highlighter, and an AnchorHeadingRenderer for heading anchors; MarkdownBladeComponent exposes the same pipeline to Blade as the x-markdown component. Rendered output is optionally cached through Laravel’s cache contract.
Tech Stack — PHP 8.1+, built on league/commonmark ^2.6, spatie/commonmark-shiki-highlighter, and Laravel’s illuminate/* cache, view, support, and contracts components (Laravel 9 through 13). Tests use Pest.
Code Quality — A well-structured, small codebase following Spatie’s consistent package conventions. It ships a thorough Pest test suite (Blade component, directive, front matter, inline parser, renderer settings) with snapshot testing, and CI enforces php-cs-fixer styling.
API Design — The developer experience is polished: the Blade component needs zero setup for basic use, and the MarkdownRenderer offers a fluent, well-documented configuration surface. Publishing a single config file exposes every option, keeping the common path simple while allowing deep customization.