Skip to content
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

Closing document tags added, when code blocks contain closing body or html tag #254

Open
PRGfx opened this issue Sep 16, 2024 · 0 comments

Comments

@PRGfx
Copy link

PRGfx commented Sep 16, 2024

Version(s) affected

5.1.1

Description

Codeblocks with closing </body> or </html> tags will add closing tags to the resulting document.

<pre><code>&lt;/body&gt;</code></pre>
```
</body>
```

</body>

or

```
</html>
```

</body></html>

The issue occurs only once, i.e. having multiple closing html tags will still return the whole document + only one </body></html>.

I guess it's somehow about how the HTML is saved. I can work around this with first replacing these tags with placeholders before conversion and replacing them back, but as long as I'm not sure, why this happens, it might occur for the next best element.

How to reproduce

echo -e '<pre><code>&lt;/body&gt;</code></pre>' | vendor/bin/html-to-markdown
echo -e '<pre><code>&lt;/html&gt;</code></pre>' | vendor/bin/html-to-markdown
<?php
include 'vendor/autoload.php';
$converter = new \League\HTMLToMarkdown\HtmlConverter();
echo $converter->convert('<pre><code>&lt;/html&gt;</code></pre>');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant