'Preview requests must use POST.']); return; } if (!phpb_validate_csrf()) { $respond(403, ['error' => 'The preview request could not be verified.']); return; } $body = $_POST['body'] ?? null; if (!is_string($body)) { $respond(400, ['error' => 'A Markdown body is required.']); return; } if (strlen($body) > 1000000) { $respond(413, ['error' => 'The Markdown body is too large to preview.']); return; } try { $html = (new \Plugi\Extensions\Blog\PostContentRenderer())->render($body); $respond(200, ['html' => $html]); } catch (\Throwable) { $respond(500, ['error' => 'The Markdown preview could not be rendered.']); }