1. Go to this page and download the library: Download moneo/markdown-for-agents library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
moneo / markdown-for-agents example snippets
use Moneo\MarkdownForAgents\Facades\MarkdownForAgents;
$result = MarkdownForAgents::url('https://example.com')->convert();
$result->markdown; // string — the converted content
$result->tokens; // int — estimated token count
$result->contentSignals; // ?array — ['ai-train' => 'yes', ...]
$result->driver; // string — which driver was used
$result->fromCache; // bool — served from cache?
// Use the browser driver for JS-heavy pages
$result = MarkdownForAgents::driver('browser')
->url('https://spa-app.com')
->waitUntil('networkidle0')
->convert();
use Moneo\MarkdownForAgents\Events\MarkdownConverted;
Event::listen(MarkdownConverted::class, function (MarkdownConverted $event) {
Log::info("Converted {$event->source} in {$event->duration}s");
});
use Moneo\MarkdownForAgents\Facades\MarkdownForAgents;
MarkdownForAgents::extend('custom', function ($app) {
return new MyCustomDriver($app['config']);
});
$result = MarkdownForAgents::driver('custom')->url($url)->convert();
use Moneo\MarkdownForAgents\Facades\MarkdownForAgents;
use Moneo\MarkdownForAgents\DTOs\ConversionResult;
MarkdownForAgents::shouldReceive('url->convert')
->andReturn(new ConversionResult(...));