-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsedown stops parsing after <img> tag #370
Comments
I've had a look at this, the problem seems to be using two html tags on a single line. I get the same erronous result with other tags. Also, it is not specifically the image tag, because when you put the image tag on a new line, it parses fine. I'll dig a bit deeper |
I witness the same : if there are several HTML tags on the same line, parsing stops for the rest of the document. A simple test to showcase the bug is : public function test_that_breaks() {
$markdownWithHtml = <<<MARKDOWN
<div></div><span></span>
# Test
MARKDOWN;
$expectedHtml = <<<EXPECTED_HTML
<div></div><span></span>
<h1>Test</h1>
EXPECTED_HTML;
$parsedown = new Parsedown();
$this->assertEquals($expectedHtml, $parsedown->text($markdownWithHtml));
} It fails with :
|
I could pin down the cause to the regex test that checks if the opening element closes at the end of the line at line 714 https:/erusev/parsedown/blob/master/Parsedown.php#L714 i.e. if (preg_match('/<\/'.$matches[1].'>[ ]*$/i', $remainder))
{
$Block['closed'] = true;
} |
Not sure what's the best course of action here. Iterate over the remaining found elements in the line while we find them closed ? |
Thanks @jvelo I'll investigate. |
@erusev great ! Thanks. |
This will be fixed in the next release, you'd just need to add a newline after HTML to tell Parsedown to process markdown again |
Input:
expected result:
Got:
The text was updated successfully, but these errors were encountered: