From a697f890837b6862a91eb40e75dcd9563eb35206 Mon Sep 17 00:00:00 2001 From: tim Date: Fri, 7 Apr 2023 18:45:43 +0200 Subject: [PATCH] Allow inlining code blocks with double quotes --- src/Controller/SnipController.php | 4 ++-- src/Service/SnipParser/Pipeline.php | 3 ++- templates/snip/single.html.twig | 8 +++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Controller/SnipController.php b/src/Controller/SnipController.php index 8be508d..0bd6ca3 100644 --- a/src/Controller/SnipController.php +++ b/src/Controller/SnipController.php @@ -46,12 +46,12 @@ class SnipController extends AbstractController #[Route('/single/{snip}', name: '_single')] public function single(Snip $snip): Response { - $snipParser = new Pipeline(); $this->denyAccessUnlessGranted(SnipVoter::VIEW, $snip); + $snipService = $this->snipServiceFactory->create($snip); return $this->render('snip/single.html.twig', [ 'snip' => $snip, - 'content' => $snipParser->parse(($snipService->get())), + 'content' => (new Pipeline())->parse(($snipService->get())), 'branch' => $snipService->getRepo()->getCurrentBranchName(), ]); } diff --git a/src/Service/SnipParser/Pipeline.php b/src/Service/SnipParser/Pipeline.php index f31719a..7831b00 100644 --- a/src/Service/SnipParser/Pipeline.php +++ b/src/Service/SnipParser/Pipeline.php @@ -13,7 +13,8 @@ class Pipeline $builder = new PipelineBuilder(); $pipeline = $builder ->add(new HtmlEscapeStage()) - ->add(new ReplaceBlocksStage('
', '
', '```')) + ->add(new ReplaceBlocksStage('
', '
', '```')) + ->add(new ReplaceBlocksStage('', '', '``')) ->build(); return $pipeline->process($payload); diff --git a/templates/snip/single.html.twig b/templates/snip/single.html.twig index 59abe3e..ea93e3a 100644 --- a/templates/snip/single.html.twig +++ b/templates/snip/single.html.twig @@ -44,5 +44,11 @@ {% block js %} {{ parent() }} - + {% endblock %} \ No newline at end of file