Improved Javascript function.
Fixed some highlight problem on empty lines.