node-html-to-text icon indicating copy to clipboard operation
node-html-to-text copied to clipboard

Question: does this work in the browser

Open garemoko opened this issue 10 years ago • 10 comments

I appreciate this is a node library. Is there a version of this or anything similar that works in the browser?

garemoko avatar Oct 20 '15 08:10 garemoko

There are already people who are using the library with browserify.

mlegenhausen avatar Oct 20 '15 11:10 mlegenhausen

It would be great if you put that in the wiki. Would be easier for node beginners.

malpiatko avatar Dec 22 '15 18:12 malpiatko

Normally the node- prefix of the project indicates that it should be used primarily in node environment.

mlegenhausen avatar Dec 28 '15 14:12 mlegenhausen

A browser version could be built smarter since it can "walk" the DOM (child) elements and wouldn't need AST library to parse the content. Hence the node- prefix.

This may work on the client side with browserify, but I would certainly not recommend. It probably would be better of to find a client side alternative to this. All the (sub) dependencies would make the end script file quite large...

jimmywarting avatar Apr 14 '16 21:04 jimmywarting

Exchanging the html parser by a modern one which is usable in node and browser environments with a smaller overhead would be nice.

mlegenhausen avatar Apr 22 '16 15:04 mlegenhausen

Found this solution https://github.com/dustinsoftware/html-to-plaintext

giorgio79 avatar May 29 '17 12:05 giorgio79

In the browser you can use .innerText which does wonders.

fiatjaf avatar Jun 21 '17 22:06 fiatjaf

In the browser you can use .innerText which does wonders.

@fiatjaf i wouldn't say .innerText dose wonders... you only get the text, it won't be transformed like this lib dose it. try getting the text from a table with .innerText and see what you get

jimmywarting avatar Jun 22 '17 07:06 jimmywarting

Has any more talk been done about making this work in the browser? I assume not but I wanted to ask before I attempt to make my own solution. I searched around but couldn't find any other front-end equivalents to this package.

jkupczak avatar Apr 30 '18 03:04 jkupczak

Found this package: https://github.com/EDMdesigner/textversionjs

michaelbukachi avatar Nov 29 '20 17:11 michaelbukachi

Time to close this. People were using this package in web projects for quite a while now. Version 9 moves CLI to external package and hopefully solves some issue with webpack. There should be no obstacles left from this being equally supported both in node and web environment.

KillyMXI avatar Dec 03 '22 12:12 KillyMXI