Fix template literals when end backtick immediately folows newline

Previously, a backtick which immediately followed a newline would be treated
as part of the template text, rather than as a note to stop processing. This
CL corrects this behaviour.

Closes #1877