Skip to content

Commit

Permalink
fix: preserve whitespace (#51)
Browse files Browse the repository at this point in the history
No longer normalizing whitespace in html
  • Loading branch information
adampash authored Dec 6, 2016
1 parent 15656cb commit 64c0fad
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
2 changes: 1 addition & 1 deletion src/resource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
8 changes: 0 additions & 8 deletions src/shims/cheerio-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 64c0fad

Please sign in to comment.