html5parser icon indicating copy to clipboard operation
html5parser copied to clipboard

Html string to plain text with lines

Open k4mr4n opened this issue 3 years ago • 1 comments

Hey!

I wonder how can I use this library to get the innerText of my HTML string and also preserve the new lines?

const htmlstring = `<p>hello</p><img src="..." /><p>world</p>`

const result = html5parser(htmlstring) // ??

const result = `hello
world`

k4mr4n avatar Jan 28 '22 22:01 k4mr4n

It doesn't seem to me that is the purpose of this library. Even though it has a package internal stringify method it doesn't implement the specifics of innerText.

espretto avatar Jul 29 '22 13:07 espretto