Don't parse text when inserting/replacing inside a script/style tag

For #5183.

@jasonsanjose - could you look at this one too? It's wafer-thin :) Also, note that it's based on the branch from #5182.