dockerized_openAger/nodered/rootfs/data/node_modules/html-to-text/bin/cli.js

47 lines
902 B
JavaScript
Raw Normal View History

2020-10-17 16:42:50 +00:00
#!/usr/bin/env node
var parseArgs = require('minimist');
var htmlToText = require('../lib/html-to-text');
var argv = parseArgs(process.argv.slice(2), {
string: [
'tables'
],
boolean: [
'noLinkBrackets',
'ignoreHref',
'ignoreImage'
],
alias: {
'ignore-href': 'ignoreHref',
'ignore-image': 'ignoreImage'
},
default: {
'wordwrap': 80
}
});
argv.tables = interpretTables(argv.tables);
var text = '';
process.title = 'html-to-text';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function data(data) {
text += data;
});
process.stdin.on('end', function end() {
text = htmlToText.fromString(text, argv);
process.stdout.write(text + '\n', 'utf-8');
});
function interpretTables(tables) {
if (!tables || tables === '' || tables === 'false') {
return [];
}
return tables === 'true' || tables.split(',');
}