From c9de0133e3212be9da92be06035b6704f3e8b579 Mon Sep 17 00:00:00 2001 From: Ravi Bolla Date: Mon, 3 Jul 2017 16:40:07 +0530 Subject: [PATCH] Handling child text nodes of div --- lib/reader.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/reader.js b/lib/reader.js index cb9c0b5..1393767 100644 --- a/lib/reader.js +++ b/lib/reader.js @@ -439,10 +439,8 @@ function getCandidates ($, options) { } // cache innerText here. var childDom = child.get(0) - var innerText - if (childDom.type === 'text' && (innerText = childDom.data.trim())) { - child.replaceWith('

' + innerText + '

') - innerText = null + if (childDom.type === 'text' && childDom.data.trim()) { + child.replaceWith('' + childDom.data + '') } }) } @@ -452,7 +450,7 @@ function getCandidates ($, options) { } }) // assign scores to `P`s that were turned from DIV by us. - $('p.' + extBonusKey, 'body').each(function () { + $('p.' + extBonusKey + ',span.' + extBonusKey, 'body').each(function () { getNodeWeight($(this), cans, options) }) return cans