From 980ea6af947baaf0650533c5c4a28f175d130a65 Mon Sep 17 00:00:00 2001 From: tim Date: Sat, 8 Apr 2023 18:08:45 +0200 Subject: [PATCH] Remove the parsable tags when showing raw snip --- src/Controller/SnipController.php | 4 ++-- src/Service/SnipParser/Pipeline.php | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Controller/SnipController.php b/src/Controller/SnipController.php index 0bd6ca3..c74326c 100644 --- a/src/Controller/SnipController.php +++ b/src/Controller/SnipController.php @@ -51,7 +51,7 @@ class SnipController extends AbstractController $snipService = $this->snipServiceFactory->create($snip); return $this->render('snip/single.html.twig', [ 'snip' => $snip, - 'content' => (new Pipeline())->parse(($snipService->get())), + 'content' => (new Pipeline())->parse($snipService->get()), 'branch' => $snipService->getRepo()->getCurrentBranchName(), ]); } @@ -62,7 +62,7 @@ class SnipController extends AbstractController $this->denyAccessUnlessGranted(SnipVoter::VIEW, $snip); $response = new Response( - $this->snipServiceFactory->create($snip)->get(), + (new Pipeline())->clean($this->snipServiceFactory->create($snip)->get()), Response::HTTP_OK, ['Content-Type' => 'text/html'] ); diff --git a/src/Service/SnipParser/Pipeline.php b/src/Service/SnipParser/Pipeline.php index 7831b00..666ca57 100644 --- a/src/Service/SnipParser/Pipeline.php +++ b/src/Service/SnipParser/Pipeline.php @@ -19,4 +19,13 @@ class Pipeline return $pipeline->process($payload); } + + public function clean(string $payload): string + { + return str_replace( + ['```', '``'], + '', + $payload + ); + } } \ No newline at end of file