diff --git a/MarkdownRuntime.php b/MarkdownRuntime.php index 6a96a52..d1211d2 100644 --- a/MarkdownRuntime.php +++ b/MarkdownRuntime.php @@ -20,8 +20,12 @@ public function __construct(MarkdownInterface $converter) $this->converter = $converter; } - public function convert(string $body): string + public function convert(?string $body): string { + if (empty($body)) { + return ''; + } + // remove indentation if ($white = substr($body, 0, strspn($body, " \t\r\n\0\x0B"))) { $body = preg_replace("{^$white}m", '', $body); diff --git a/Tests/FunctionalTest.php b/Tests/FunctionalTest.php index 368a046..e0e1ea8 100644 --- a/Tests/FunctionalTest.php +++ b/Tests/FunctionalTest.php @@ -81,6 +81,7 @@ public function getMarkdownTests() EOF , "

Hello

\n+

Great!

"], ["{{ include('html')|markdown_to_html }}", "

Hello

\n+

Great!

"], + ['{{ null|markdown_to_html }}', ""] ]; } }