Use maps with replace to escape characters

See benchmarks:

* http://jsperf.com/multiple-replacements
* http://jsperf.com/multiple-replacements-ii