Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/readability.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
/*jslint undef: true, nomen: true, eqeqeq: true, plusplus: true, newcap: true, immed: true, browser: true, devel: true, passfail: false */
/*global window: false, readConvertLinksToFootnotes: false, readStyle: false, readSize: false, readMargin: false, Typekit: false, ActiveXObject: false */

var Buffer = require('buffer').Buffer;
var Iconv = require('iconv').Iconv;
var dbg = (typeof console !== 'undefined') ? function(s) {
if (readability.debugging) {
console.log("Readability: " + s);
Expand DownExpand Up@@ -2225,7 +2226,11 @@ exports.parse = function parse(theHtml, url, options, callback) {
removeClassNames: true
};
options = Utils.extend({}, defaultOptions, options);

if(options.encoding && options.encoding != 'utf8') {
body = new Buffer(theHtml, 'binary');
iconv = new Iconv(options.encoding, 'utf8');
theHtml = iconv.convert(body).toString('utf8');
}
var startTime = new Date().getTime();
//dbg(html);
var html = theHtml.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, '');
Expand All@@ -2239,7 +2244,7 @@ exports.parse = function parse(theHtml, url, options, callback) {
features : {
FetchExternalResources : [],
ProcessExternalResources : false
}
},
};

function createDocWithHTMLParser() {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,7 +42,10 @@
"dependencies": {
"mjsunit.runner": ">=0.1.0",
"jsdom": ">=0.1.21",
"htmlparser": ">=1.7.3"
"htmlparser": ">=1.7.3",
"html5":">0.1",
"main": "iconv",
"iconv":">=1.1.3"
},
"engines" : { "node" : ">=0.2.5" },
"directories": {
Expand Down