html-to-text
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -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'); | ||
}); |
@@ -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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
41519
478
298