You are filtering out the This is Bar
and This is Foo.
with the condition itr.currentNode.textContent.search("\n")
.
I'm not sure what you're trying to do with the first two conditions in your if statement but search
returns -1 when the needle isn't found and -1
is truthy
if (/*itr.currentNode.textContent.search("\t") &&
itr.currentNode.textContent.search("\n") &&*/
itr.currentNode.parentNode.nodeName.toLowerCase() != 'script' &&
itr.currentNode.parentNode.nodeName.toLowerCase() != 'noscript')
var text = $.trim(itr.currentNode.textContent);
if (text.length > 0 && itr.currentNode.parentNode.nodeName.toLowerCase() != 'script' && itr.currentNode.parentNode.nodeName.toLowerCase() != 'noscript')
{
if (i == 0)
{
pageText = text;
i++;
}
else
{
pageText = pageText + sep + text;
i++;
}
}