Last active
December 12, 2019 11:29
-
-
Save zackslash/1998e5e6027280b1b09271fe8562a0eb to your computer and use it in GitHub Desktop.
HTML-To-Text in browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Description: Small wapper to expose HTML-To-Text (https://www.npmjs.com/package/html-to-text) functionality to browser | |
| * | |
| * package.json == {"dependencies": {"html-to-text": "*"}} | |
| * | |
| * $ browserify --standalone convertHTMLToString wrap.js -o clientHtmlToText.js | |
| * | |
| * convertHTMLToString('<h1>test</h1>',{wordwrap: 130}); | |
| * | |
| * Note: Resulting file needs to be placed before 'requirejs' dependency if present. | |
| */ | |
| function convertHTMLToString(input, options) { | |
| var htmlToText = require('html-to-text'); | |
| var text = htmlToText.fromString(input,options); | |
| return text; | |
| } | |
| module.exports = convertHTMLToString; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment