Laravel Markdown

A highly configurable Markdown renderer and x-markdown Blade component for Laravel.

Library
Composer
v2.8.0
415stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
54/100Fair
Development Activity32
Maintenance52
Community48
Maturity56
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
81/100Excellent
Architecture84
Code Quality88
Innovation68
Learning Curve85

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-markdown Blade component for rendering Markdown directly in templates
  • A configurable MarkdownRenderer class 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.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search