How to use the html-to-text.fromFile function in html-to-text

To help you get started, we’ve selected a few html-to-text examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / html-to-text / html-to-text-tests.ts View on Github external
wordwrap: null,
    tables: true,
    hideLinkHrefIfSameAsText: true,
    ignoreImage: true
};


function callback(err: string, result: string) {
    console.log(`callback called with result ${result}`);
}

console.log("Processing file with default options");
htmlToText.fromFile("h2t-test.html", callback);

console.log("Processing file with custom options");
htmlToText.fromFile("h2t-test.html", htmlOptions, callback);

let htmlString = "<p><b>bold</b></p><p><i>italic</i></p>";
console.log("Processing string with default options");
console.log(htmlToText.fromString(htmlString));

console.log("Processing string with custom options");
console.log(htmlToText.fromString(htmlString, htmlOptions));
github DefinitelyTyped / DefinitelyTyped / html-to-text / html-to-text-tests.ts View on Github external
import * as htmlToText from 'html-to-text';

let htmlOptions: HtmlToTextOptions = {
    wordwrap: null,
    tables: true,
    hideLinkHrefIfSameAsText: true,
    ignoreImage: true
};


function callback(err: string, result: string) {
    console.log(`callback called with result ${result}`);
}

console.log("Processing file with default options");
htmlToText.fromFile("h2t-test.html", callback);

console.log("Processing file with custom options");
htmlToText.fromFile("h2t-test.html", htmlOptions, callback);

let htmlString = "<p><b>bold</b></p><p><i>italic</i></p>";
console.log("Processing string with default options");
console.log(htmlToText.fromString(htmlString));

console.log("Processing string with custom options");
console.log(htmlToText.fromString(htmlString, htmlOptions));
github ecomfe / echarts-map-tool / css / font / build.js View on Github external
var Fontmin = require('fontmin');
var htmlToText = require('html-to-text');
var path = require('path');



htmlToText.fromFile(path.join(__dirname, '../../index.html'), {}, function (err, text) {

    new Fontmin()
        .src('./noto-thin.ttf')
        .use(Fontmin.glyph({
            text: text
        }))
        .run(function (err, files) {
            if (err) {
                throw new Error(err);
            }
            require('fs').writeFileSync('./noto-thin.min.ttf', files[0]._contents);
        });
})

html-to-text

Advanced html to plain text converter

MIT
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis