Improve escaping in code response.

Improve escaping in code response. BLD-1108

@olmar and @adampalay please review.
You can master vs branch in
https://preview.edx.org/courses/RiceX/ELEC301x/T1_2014/courseware/cd24d0f66af143559dfefc613f74a004/a22909387b0746ffafd4655fde9066d7/1
vs
http://preview.auraz.m.sandbox.edx.org/courses/Blades/1/Summer/courseware/5447da249f4a461f8e69f6481baa2063/85b6022a267c409ebc50f1bb507b9a71/1