thephpleague / html-to-markdown

Convert HTML to Markdown with PHP
MIT License
1.77k stars 204 forks source link

newline character immediately after <pre> should be stripped #244

Open GoBigorGoHome opened 10 months ago

GoBigorGoHome commented 10 months ago

Version(s) affected

5.1.1

Description

use League\HTMLToMarkdown\HtmlConverter;
$converter = new HtmlConverter();
$md = $converter->convert('<pre>
line 1
</pre>')
var_export($md);

prints

'```

line 1
```'

there is an empty line above line 1. But the HTML spec says

In the HTML syntax, a leading newline character immediately following the pre element start tag is stripped.

so the expected markdown is

line 1

See also https://stackoverflow.com/q/23969607

How to reproduce

See description.