Skip to content

Invalid markdown when using image tags followed by a heading #259

@tkoenig

Description

@tkoenig

Version(s) affected

5.1.1

Description

The parser is not adding a newline between the tag and the subsequent tag, causing the Markdown to be rendered incorrectly.

The following HTML is not being parsed as expected:

<img src="https://placehold.co/600x400" loading="lazy" id="" width="auto" height="auto" alt="" />
<h3 id="">A new header</h3>

Current output

![](https://placehold.co/600x400)### A new header

Expected output

![](https://placehold.co/600x400)

### A new header

How to reproduce

$html = <<<HTML
    <img src="https://placehold.co/600x400" loading="lazy" id="" width="auto" height="auto" alt="" />
    <h3 id="">A new header</h3>
HTML;
$converter =  new HtmlConverter();
$markdown = $converter->convert($html);
echo $markdown;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions