node-html-to-text
node-html-to-text copied to clipboard
Question: does this work in the browser
I appreciate this is a node library. Is there a version of this or anything similar that works in the browser?
There are already people who are using the library with browserify.
It would be great if you put that in the wiki. Would be easier for node beginners.
Normally the node- prefix of the project indicates that it should be used primarily in node environment.
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...
Exchanging the html parser by a modern one which is usable in node and browser environments with a smaller overhead would be nice.
Found this solution https://github.com/dustinsoftware/html-to-plaintext
In the browser you can use .innerText which does wonders.
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
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.
Found this package: https://github.com/EDMdesigner/textversionjs
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.