[htmlmixed mode] Make it possible to customize the way scripts are parsed

Issue #1242
Issue #1198