Example #1
0
export function htmlToPlaintext(html: string): string {
    return fromString(html, {
        tables: true,
        ignoreHref: true,
        wordwrap: false,
        uppercaseHeadings: false,
        ignoreImage: true
    })
}
Example #2
0
            res.on('end', function () {
                var html = cheerio.load(data);
                var text = htmlToText.fromString(String(html('div.anyipsum-output > p')));
                console.log(text);
                editor.edit((eb) => {
                    eb.insert(editor.selection.active, text);
                });

            });
/// <reference path="html-to-text.d.ts" />

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));

Example #4
0
export const getLicense = () => {
  return htmlToText.fromString(require('../../LICENSE.md'));
};