Making template generator support newlines inside exercises

It's messy and could use some cleaning up, but it works.