From a98b76e6cb6dfea13e620e46e8ef7342721c5729 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Fri, 17 Nov 2023 15:35:01 +1300 Subject: [PATCH] Fix rendering of indented code block --- src/Renderer/Block/IndentedCodeRenderer.php | 9 +++++---- tests/Renderer/Block/IndentedCodeRendererTest.php | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Renderer/Block/IndentedCodeRenderer.php b/src/Renderer/Block/IndentedCodeRenderer.php index 8876d42..0154cb3 100644 --- a/src/Renderer/Block/IndentedCodeRenderer.php +++ b/src/Renderer/Block/IndentedCodeRenderer.php @@ -22,10 +22,11 @@ public function render(Node $node, ChildNodeRendererInterface $childRenderer): s { IndentedCode::assertInstanceOf($node); - $content = $node->getLiteral(); + $content = []; + foreach (explode("\n", $node->getLiteral()) as $line) { + $content[] = " {$line}"; + } - return <<renderer->render($block, $fakeRenderer); - $this->assertEquals('```echo "hello world!";```', $result); + $this->assertEquals(' echo "hello world!";', $result); } }