Sorry about that, my editor likes to do that automatically sometimes.
fix only attempt to smoosh if src/href exists
fix script parsing bug when scripts contain html
Ah, I see. But the tests are failing?
fix failing test
Apologies again, fixed now :)
One more thing - could you add a test for the new functionality?
k, tests added. I also changed the way the html fix works a bit so that it doesn't translate tags in comments to escape sequences, and added it to the stylesheet processing as well. The way i'm getting cheerio to not process the text is a bit of a hack, but i'm not sure how else to go about it.
add tests for non-local url skipping and html in scripts/styles bugs;…
… fix issues with prior implementation of said fixes
Thanks for the pull request - much appreciated. Also, I tried going back to the previous implementation:
$(element).replaceWith('<style>' + fs.readFileSync(path.join(file.base, href), 'utf8') + '</style>');
var el = $('<style></style>').text('tmp');
el.children.data = fs.readFileSync(path.join(file.base, href), 'utf8');
and found no issues, so I went with the former. But maybe I'm missing something?
var str = '';
Similar code appears in comments within angular.js, which is what the real original problem was for me. That being said, none of the things I proposed actually resolve this issue properly. Your original method will cause cheerio to try to fix up the tags, whereas mine will leave the text umodified, but of course break the actual html.
It seems like the options are:
('</scri' + 'pt>')