Your comments

I haven't seen the new implementation but just in case...

The current one gets very confused on Perl regular expressions with single quotes.

For example

$str =~ s/\'/\\\'/g; # '# Convert all ' to \' '

I added the '# to get most of the comment rendered in grey and the trailing ' to make the number of quotes even so the following lines rendered correctly