Skip to content

Commit

Permalink
Fix rendering of indented code block (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Nov 18, 2023
1 parent 9b764d3 commit 4e73b62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/Renderer/Block/IndentedCodeRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<<TXT
```{$content}```
TXT;
return implode("\n", $content);
}
}
2 changes: 1 addition & 1 deletion tests/Renderer/Block/IndentedCodeRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public function it_renders_indented_code_renderer(): void

$result = $this->renderer->render($block, $fakeRenderer);

$this->assertEquals('```echo "hello world!";```', $result);
$this->assertEquals(' echo "hello world!";', $result);
}
}

0 comments on commit 4e73b62

Please sign in to comment.