[htmlmixed mode] Make detection of opening script/style tags more robust

Closes #1271