diff --git a/src/Converter/PreformattedConverter.php b/src/Converter/PreformattedConverter.php index 7d8ccc1..af6dd10 100644 --- a/src/Converter/PreformattedConverter.php +++ b/src/Converter/PreformattedConverter.php @@ -11,7 +11,9 @@ class PreformattedConverter implements ConverterInterface public function convert(ElementInterface $element): string { $preContent = \html_entity_decode($element->getChildrenAsString()); - $preContent = \str_replace(['
', ''], '', $preContent); + $preContent = \preg_replace('/
]*>/', '', $preContent); + \assert($preContent !== null); + $preContent = \str_replace('', '', $preContent); /* * Checking for the code tag. diff --git a/tests/HtmlConverterTest.php b/tests/HtmlConverterTest.php index 64b9086..4b71832 100644 --- a/tests/HtmlConverterTest.php +++ b/tests/HtmlConverterTest.php @@ -300,6 +300,7 @@ public function testPreformat(): void $this->assertHtmlGivesMarkdown("
\n\n\n", "```\n\n\n\n```"); $this->assertHtmlGivesMarkdown("
\n
\n", "```\n\n```\n\n```\n\n```"); $this->assertHtmlGivesMarkdown("
one\ntwo\r\nthree\n
line
", "```\none\ntwo\nthree\n```\n\nline"); + $this->assertHtmlGivesMarkdown("test with attributes", "```\ntest with attributes\n```"); } public function testBlockquotes(): void