Socket
Socket
Sign inDemoInstall

html-to-text

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-to-text - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

13

bin/cli.js

@@ -6,3 +6,10 @@ #!/usr/bin/env node

var argv = optimist.default('tables', '').default('wordwrap', 80).argv;
var argv = optimist
.default('tables', '')
.default('wordwrap', 80)
.default('ignore-href', false)
.default('ignore-image', false)
.argv;
console.log(argv);
var text = '';

@@ -21,5 +28,7 @@

tables: argv.tables.split(','),
wordwrap: argv.wordwrap
wordwrap: argv.wordwrap,
ignoreHref: argv['ignore-href'],
ignoreImage: argv['ignore-image']
});
process.stdout.write(text + '\n', 'utf-8');
});

25

lib/formatter.js

@@ -18,2 +18,6 @@ var _ = require('underscore');

function formatImage(elem, options) {
if (options.ignoreImage) {
return '';
}
var result = '', attribs = elem.attribs || {};

@@ -56,12 +60,15 @@ if (attribs.alt) {

}
// Get the href, if present
if (elem.attribs && elem.attribs.href) {
href = elem.attribs.href.replace(/^mailto\:/, '');
}
if (href) {
if (options.linkHrefBaseUrl && href.indexOf('/') == 0) {
href = options.linkHrefBaseUrl + href;
if (!options.ignoreHref) {
// Get the href, if present
if (elem.attribs && elem.attribs.href) {
href = elem.attribs.href.replace(/^mailto\:/, '');
}
if (!options.hideLinkHrefIfSameAsText || href != result) {
result += ' [' + href + ']';
if (href) {
if (options.linkHrefBaseUrl && href.indexOf('/') == 0) {
href = options.linkHrefBaseUrl + href;
}
if (!options.hideLinkHrefIfSameAsText || href != result) {
result += ' [' + href + ']';
}
}

@@ -68,0 +75,0 @@ }

@@ -6,3 +6,3 @@ var fs = require('fs');

var _s = require('underscore.string');
var htmlparser = require("htmlparser");
var htmlparser = require('htmlparser');

@@ -9,0 +9,0 @@ var helper = require('./helper');

{
"name": "html-to-text",
"version": "1.2.1",
"version": "1.3.0",
"description": "Advanced html to plain text converter",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -58,2 +58,4 @@ # node-html-to-text

* `hideLinkHrefIfSameAsText` by default links are translated the following `<a href='link'>text</a>` => becomes => `text [link]`. If this option is set to true and `link` and `text` are the same, `[link]` will be hidden and only `text` visible.
* `ignoreHref` ignore all document links if `true`.
* `ignoreImage` ignore all document images if `true`.

@@ -60,0 +62,0 @@ ## Command Line Interface

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc