Remove the parsable tags when showing raw snip

This commit is contained in:
Tim 2023-04-08 18:08:45 +02:00
parent 669cbfdaca
commit 980ea6af94
2 changed files with 11 additions and 2 deletions

View File

@ -51,7 +51,7 @@ class SnipController extends AbstractController
$snipService = $this->snipServiceFactory->create($snip); $snipService = $this->snipServiceFactory->create($snip);
return $this->render('snip/single.html.twig', [ return $this->render('snip/single.html.twig', [
'snip' => $snip, 'snip' => $snip,
'content' => (new Pipeline())->parse(($snipService->get())), 'content' => (new Pipeline())->parse($snipService->get()),
'branch' => $snipService->getRepo()->getCurrentBranchName(), 'branch' => $snipService->getRepo()->getCurrentBranchName(),
]); ]);
} }
@ -62,7 +62,7 @@ class SnipController extends AbstractController
$this->denyAccessUnlessGranted(SnipVoter::VIEW, $snip); $this->denyAccessUnlessGranted(SnipVoter::VIEW, $snip);
$response = new Response( $response = new Response(
$this->snipServiceFactory->create($snip)->get(), (new Pipeline())->clean($this->snipServiceFactory->create($snip)->get()),
Response::HTTP_OK, Response::HTTP_OK,
['Content-Type' => 'text/html'] ['Content-Type' => 'text/html']
); );

View File

@ -19,4 +19,13 @@ class Pipeline
return $pipeline->process($payload); return $pipeline->process($payload);
} }
public function clean(string $payload): string
{
return str_replace(
['```', '``'],
'',
$payload
);
}
} }