html-to-text
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -11,2 +11,8 @@ var fs = require('fs'); | ||
// Which type of tags should not be parsed | ||
var SKIP_TYPES = [ | ||
'style', | ||
'script' | ||
]; | ||
function htmlToText(html, options) { | ||
@@ -21,5 +27,5 @@ options = options || {}; | ||
}, { | ||
verbose: true, | ||
ignoreWhitespace: true | ||
}, { | ||
verbose: true, | ||
ignoreWhitespace: true | ||
}); | ||
@@ -45,3 +51,3 @@ new htmlparser.Parser(handler).parseComplete(html); | ||
walk(dom); | ||
return result || dom; | ||
return result || dom; | ||
} | ||
@@ -68,3 +74,3 @@ | ||
var ids = filterByPrefix(tables, '#'); | ||
return attr && (_.include(classes, attr.class) || _.include(ids, attr.id)); | ||
return attr && (_.include(classes, attr.class) || _.include(ids, attr.id)); | ||
} | ||
@@ -77,3 +83,3 @@ | ||
case 'tag': | ||
switch(elem.name) { | ||
switch(elem.name.toLowerCase()) { | ||
case 'a': | ||
@@ -109,3 +115,3 @@ result += format.anchor(elem, walk, options); | ||
default: | ||
result += walk(elem.children || [], options); | ||
result += walk(elem.children || [], options); | ||
} | ||
@@ -117,3 +123,5 @@ break; | ||
default: | ||
result += walk(elem.children || [], options); | ||
if (!_.include(SKIP_TYPES, elem.type)) { | ||
result += walk(elem.children || [], options); | ||
} | ||
} | ||
@@ -137,2 +145,2 @@ }); | ||
return htmlToText(str, options || {}); | ||
}; | ||
}; |
{ | ||
"name": "html-to-text", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Simple html to plain text converter", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -285,2 +285,4 @@ # node-html-to-text | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/cc03826a7e68e1bb680cf2226276e031 "githalytics.com")](http://githalytics.com/werk85/node-html-to-text) |
Sorry, the diff of this file is not supported yet
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
27353
348
288
0