Skip to content

Commit

Permalink
Fix #215: pre tags with attrs not being parsed (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
stbneb committed Jul 12, 2023
1 parent e72ed92 commit 54573d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Converter/PreformattedConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class PreformattedConverter implements ConverterInterface
public function convert(ElementInterface $element): string
{
$preContent = \html_entity_decode($element->getChildrenAsString());
$preContent = \str_replace(['<pre>', '</pre>'], '', $preContent);
$preContent = \preg_replace('/<pre\b[^>]*>/', '', $preContent);
\assert($preContent !== null);
$preContent = \str_replace('</pre>', '', $preContent);

/*
* Checking for the code tag.
Expand Down
1 change: 1 addition & 0 deletions tests/HtmlConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ public function testPreformat(): void
$this->assertHtmlGivesMarkdown("<pre>\n\n\n</pre>", "```\n\n\n\n```");
$this->assertHtmlGivesMarkdown("<pre>\n</pre><pre>\n</pre>", "```\n\n```\n\n```\n\n```");
$this->assertHtmlGivesMarkdown("<pre>one\ntwo\r\nthree</pre>\n<p>line</p>", "```\none\ntwo\nthree\n```\n\nline");
$this->assertHtmlGivesMarkdown("<pre class='some-class'>test with attributes</pre>", "```\ntest with attributes\n```");
}

public function testBlockquotes(): void
Expand Down

0 comments on commit 54573d2

Please sign in to comment.