spatie/laravel-markdown
Render Markdown in Laravel with a Blade x-markdown component or a configurable MarkdownRenderer. Converts content to HTML with heading IDs, links, and syntax-highlighted code blocks, using options from your config and container resolution.
@markdown directive provides a clean, declarative syntax for rendering Markdown content.MarkdownRenderer class is highly configurable, allowing customization of parsers (e.g., Parsedown, CommonMark), extensions, and HTML output. This aligns well with Laravel’s modular and extensible architecture.spatie/laravel-package-tools (for package scaffolding) and a Markdown parser (e.g., parsedown/parsedown or league/commonmark).@markdown directive is easy to adopt and requires no additional configuration beyond installation.MarkdownRenderer class provides a fluent interface for programmatic rendering, useful for APIs or background jobs.sanitizeHtml option but requires explicit configuration.Cache::remember.composer require spatie/laravel-markdown.@markdown directive in a Blade template with sample content.@markdown.resources/markdown or a database).MarkdownRenderer::render() in controllers or jobs for dynamic content.config/markdown.php) for parser settings and sanitization.composer.json constraints.parsedown/parsedown and league/commonmark) unless explicitly required.@include, @stack).resources/markdown/).content column in a pages table).@markdown directives to templates, replacing static HTML.MarkdownRenderer in controllers or jobs for dynamic content.Cache::remember or Redis).config/markdown.php to avoid scattered configurations across templates.php-markdown/markdown.dd() or dump() for intermediate Markdown/HTML output.Cache::remember or Redis).resources/markdown/) scales well for static content.content column) may require indexing for large datasets.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Parser crashes on malformed Markdown | Broken rendering in production | Enable error handling in Blade: @markdown($content, ['throwExceptions' => false]) |
| XSS via unsanit |
How can I help you explore Laravel packages today?