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 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

title: Customize request detection weight: 3

The built-in detector handles most cases, but you can fine-tune which detection methods are active or replace the detector entirely.

Toggle detection methods

You can enable or disable individual detection methods in the config:

// config/markdown-response.php

'detection' => [
    'detect_via_accept_header' => true,
    'detect_via_md_suffix' => true,
    'detect_via_user_agents' => [
        'GPTBot',
        'ClaudeBot',
        // ...
    ],
],

Set detect_via_user_agents to an empty array to disable user agent detection.

Extend the detector

If you need more control, you can extend the DetectsMarkdownRequest class and point to it in the config:

// config/markdown-response.php

'detection' => [
    'detector' => App\Actions\CustomDetectsMarkdownRequest::class,
],
namespace App\Actions;

use Illuminate\Http\Request;
use Spatie\MarkdownResponse\Actions\DetectsMarkdownRequest;

class CustomDetectsMarkdownRequest extends DetectsMarkdownRequest
{
    public function __invoke(Request $request): false|string
    {
        // Only respond with markdown for specific paths
        if (! str_starts_with($request->getPathInfo(), '/docs')) {
            return false;
        }

        return parent::__invoke($request);
    }
}

The returned string tells the middleware how to handle the request:

  • 'suffix': the middleware strips .md from the URL before routing
  • 'accept': the middleware temporarily swaps the Accept header to text/html
  • 'user-agent': the middleware lets the request pass through normally
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.
hamzi/corewatch
minionfactory/raw-hydrator
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