Invalid HTML should be handled as good as possible
Minimal HTML example
<p>subject321</p><html><head></head><body>body123</body></html>
Options
default options
Observed output
body123
Expected output
subject321body123
Version information
- html-to-text: 9.0.5
- node:
Context: There can be HTML tags because we only receive concatenated strings of header lines and bodys in out code already and cannot split this reliably
const options = { 'baseElements': { 'selectors': [] } };
const text = htmlToText(html, options);
will result in
subject321
body123
baseElements.returnDomByDefault is set to true by default, but in order for it to always use entire DOM, baseElements.selectors has to never match. By default, it is set to ['body'] which matches a part of your input.
https://github.com/html-to-text/node-html-to-text/blob/master/packages/html-to-text/README.md#options
Oh that's really good to know. I think this should be stated more prominently in the Readme 👍