Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Markdown Response

Laravel Markdown Response Laravel Package

spatie/laravel-markdown-response

Serve clean markdown versions of your Laravel HTML pages for AI agents and bots. Detects requests via Accept: text/markdown, known user agents, or .md URLs. Driver-based conversion (local PHP or Cloudflare Workers AI), caching, and HTML preprocessing included.

View on GitHub
Deep Wiki
Context7

Serve markdown versions of your HTML pages to AI agents and bots

Frequently asked questions about Laravel Markdown Response
How do I enable markdown responses for specific routes in Laravel?
Use the `ProvideMarkdownResponse` middleware in your route group. For example, wrap routes like `Route::middleware(ProvideMarkdownResponse::class)->group(...)` to serve markdown when detected via headers, user agents, or `.md` suffixes.
Does this package work with Laravel 10+ and PHP 8.1+?
Yes, the package is fully compatible with Laravel 10+ and PHP 8.1+. It leverages modern Laravel features and avoids deprecated methods, ensuring smooth integration.
Can I customize how HTML is converted to markdown?
Yes, you can extend the conversion process by creating custom processors. The package supports hooks for preprocessing HTML or post-processing markdown, allowing you to handle edge cases like custom elements or diagrams.
What happens if the markdown conversion fails?
The package defaults to returning the original HTML if conversion fails. You can also configure fallback behavior in middleware or custom processors to handle malformed HTML gracefully.
How does caching work with this package?
The package includes built-in caching for markdown responses. Use Laravel’s cache system (e.g., `Cache::remember`) to store converted markdown, reducing repeated processing overhead for the same requests.
Is there a way to test markdown responses before deploying?
Yes, you can manually trigger conversions using the `Markdown::convert($html)` facade for unit testing. Additionally, test with AI agents/bots by sending requests with `Accept: text/markdown` headers or `.md` URLs.
Does this package support Cloudflare Workers for conversion?
Yes, the package supports driver-based conversion, including Cloudflare Workers AI. Configure the driver in your `.env` or service provider to switch between local PHP or Cloudflare for processing.
Will this break existing HTML responses for non-markdown requests?
No, the package only intercepts requests matching markdown detection criteria (headers, user agents, or `.md` paths). All other requests return the original HTML response unchanged.
Are there any known compatibility issues with `spatie/laravel-responsecache`?
The package integrates well with `spatie/laravel-responsecache`, but ensure you test caching behavior if using both. Refer to the docs for any quirks, as recent PRs (like #6) may address integration specifics.
How do I handle unsupported HTML elements (e.g., `<canvas>`) in markdown?
Unsupported elements default to `[unsupported]` in markdown. For custom handling, create a processor to replace or skip these elements before conversion, or use HTML preprocessing tools like TidyHTML.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai