fix: preserve whitespace (#51)

No longer normalizing whitespace in html
pull/52/head
Adam Pash 8 years ago committed by GitHub
parent 15656cb3e1
commit 64c0fad2fd

@ -51,7 +51,7 @@ const Resource = {
throw new Error('Content does not appear to be text.');
}
let $ = cheerio.load(content, { normalizeWhitespace: true });
let $ = cheerio.load(content);
if ($.root().children().length === 0) {
throw new Error('No children, likely a bad parse.');

@ -84,17 +84,9 @@ $.cleanup = () => {
};
$.load = (html, opts = {}, returnHtml = false) => {
const { normalizeWhitespace } = opts;
if (!html) {
html = $.cloneHtml();
} else {
if (normalizeWhitespace) {
if (typeof html === 'string') {
html = html.replace(/[\s\n\r]+/g, ' ');
}
}
html = $('<container />').html(html);
}

Loading…
Cancel
Save