25 lines
433 B
PHP
25 lines
433 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Support;
|
||
|
|
|
||
|
|
use Illuminate\Support\Str;
|
||
|
|
|
||
|
|
class MarkdownRenderer
|
||
|
|
{
|
||
|
|
public function render(?string $content): string
|
||
|
|
{
|
||
|
|
$markdown = trim((string) $content);
|
||
|
|
|
||
|
|
if ($markdown === '') {
|
||
|
|
return '';
|
||
|
|
}
|
||
|
|
|
||
|
|
return (string) Str::markdown($markdown, [
|
||
|
|
'html_input' => 'strip',
|
||
|
|
'allow_unsafe_links' => false,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
}
|