Fix admin guide: laad Composer autoloader voor CommonMark markdown render
This commit is contained in:
+16
-3
@@ -12,6 +12,12 @@ header('X-XSS-Protection: 1; mode=block');
|
|||||||
header('Referrer-Policy: strict-origin-when-cross-origin');
|
header('Referrer-Policy: strict-origin-when-cross-origin');
|
||||||
header_remove('X-Powered-By');
|
header_remove('X-Powered-By');
|
||||||
|
|
||||||
|
// Load Composer autoloader for CommonMark
|
||||||
|
$autoloader = __DIR__ . '/../vendor/autoload.php';
|
||||||
|
if (file_exists($autoloader)) {
|
||||||
|
require_once $autoloader;
|
||||||
|
}
|
||||||
|
|
||||||
// Load admin components
|
// Load admin components
|
||||||
$appConfig = require __DIR__ . '/../admin/config/app.php';
|
$appConfig = require __DIR__ . '/../admin/config/app.php';
|
||||||
require_once __DIR__ . '/../admin/src/AdminAuth.php';
|
require_once __DIR__ . '/../admin/src/AdminAuth.php';
|
||||||
@@ -1387,11 +1393,18 @@ function handleGuide(AdminAuth $auth, array $config): void
|
|||||||
|
|
||||||
// Parse markdown using CommonMark if available
|
// Parse markdown using CommonMark if available
|
||||||
$content = '';
|
$content = '';
|
||||||
if (class_exists('League\CommonMark\CommonMarkConverter')) {
|
if (class_exists('League\CommonMark\MarkdownConverter')) {
|
||||||
$converter = new League\CommonMark\CommonMarkConverter([
|
$config = [
|
||||||
'html_input' => 'allow',
|
'html_input' => 'allow',
|
||||||
'allow_unsafe_links' => false,
|
'allow_unsafe_links' => false,
|
||||||
]);
|
'max_nesting_level' => 100,
|
||||||
|
];
|
||||||
|
$environment = new \League\CommonMark\Environment\Environment($config);
|
||||||
|
$environment->addExtension(new \League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension());
|
||||||
|
$environment->addExtension(new \League\CommonMark\Extension\Table\TableExtension());
|
||||||
|
$environment->addExtension(new \League\CommonMark\Extension\Strikethrough\StrikethroughExtension());
|
||||||
|
$environment->addExtension(new \League\CommonMark\Extension\TaskList\TaskListExtension());
|
||||||
|
$converter = new \League\CommonMark\MarkdownConverter($environment);
|
||||||
$content = $converter->convert($rawContent)->getContent();
|
$content = $converter->convert($rawContent)->getContent();
|
||||||
} else {
|
} else {
|
||||||
$content = '<pre>' . htmlspecialchars($rawContent) . '</pre>';
|
$content = '<pre>' . htmlspecialchars($rawContent) . '</pre>';
|
||||||
|
|||||||
Reference in New Issue
Block a user