<?php

namespace App\Controller\Blog\Api;

use App\Markdown\Parser\Comment as CommentParser;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

class CommentController extends AbstractController
{
    /**
     * @Route("/api/blog/comment/preview", name="api_blog_comment_preview", options={"expose"=true})
     */
    public function preview(Request $request, CommentParser $parser): JsonResponse
    {
        return $this->json([
            'render' => $parser->transformMarkdown($request->request->get('content')),
        ]);
    }
}
