From 772af167520c08c71088d62a74e36f902f2eb940 Mon Sep 17 00:00:00 2001 From: Richard Dern Date: Sun, 21 Apr 2024 23:45:09 +0200 Subject: [PATCH] Fix: Last line of code block was wrong --- app/Services/Markdown/Linter.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Services/Markdown/Linter.php b/app/Services/Markdown/Linter.php index f661843..7644694 100644 --- a/app/Services/Markdown/Linter.php +++ b/app/Services/Markdown/Linter.php @@ -187,6 +187,10 @@ private function formatCodeBlock(string $block): string $lines[0] = preg_replace('/^(```\w*)\s*{.*?}$/', '$1', trim($lines[0])); } + $last = count($lines) - 1; + + $lines[$last] = '```'; + // Reassemble the block return implode("\n", $lines); }