Closed cbsa100 closed 1 year ago
const html = `
<header>header</header>
<div data-elementor-type="header">elementor type header</div>
<p>paragraph</p>
<div data-elementor-type="footer">elementor type footer</div>
<footer>footer</footer>`;
const options = {
wordwrap: null,
selectors: [
{ selector: 'a', options: { ignoreHref: true } },
{ selector: 'img', format: 'skip' },
{ selector: 'nav', format: 'skip' },
{ selector: 'header', format: 'skip' },
{ selector: 'footer', format: 'skip' },
{ selector: '*[data-elementor-type=footer]', format: 'skip' },
{ selector: '*[data-elementor-type=header]', format: 'skip' },
],
};
const text = htmlToText(html, options);
console.log(text);
Outputs only
paragraph
Start reducing your issue to a minimal example to find out what might be wrong in your case.
With no follow-up, I consider this resolved.
Most likely cause - unexpected input HTML and insufficient attention to what input HTNL actually contains and what options are actually used.
Options