Implements #3249, #1994 Escape newlines in heredocs with backslashes

 Implements #3249, #1994. This brings heredocs on par with simple strings. I also fixed trailing whitespace after escaped backslashes. Thanks to @jashkenas for the awesome regex (I changed the original so the callback is being called only when needed).