Replace sed instruction by a JavaScript program that substitutes stuff in a more reliable way