Doru's suggestion of PP + islands is good and makes building complex parsers easy, but his toy example gives wrong results:
<script>
function end() {
document.writeln('</script>');
}
function start() {
document.writeln('<script>');
}
</script>
or:
<script>
alert('hello');
// <script> alert('world')
</script>
or:
<!--<script>alert('hello')</script>-->
better to use one of the proper HTML parsers, at least if you need more
correctness.
