Minor `replace` func improvement.

Just a bit more consistency:
* preserve quote char (`"` vs. `'`)
* preserve escaped flag.

---
(self note) Hmm, now I wonder: if this function can be used to replace whatever string we want (via escaping, with or without this patch) I can't see any reason why we won't also make it to directly accept tree.Keyword value (not counting any aesthetic matters).