init
This commit is contained in:
24
app/Support/MarkdownRenderer.php
Normal file
24
app/Support/MarkdownRenderer.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user