Preserve new lines when replacing simple tokens (see #7178)