JSFiddle - React, Tailwind, and code Playground

HTML

<textarea id="text1">#ifdef GL_ES
    precision highp float;
    #endif
    
    varying vec4 v_color;
    
    void main (void)
    {
    gl_FragColor = v_color; 
    }
</textarea>
<textarea id="text2"></textarea>

JavaScript

var text = document.getElementById("text1").value;
text = text.replace(/\n/g, "\\n\"\n\"");
document.getElementById("text2").value = "\""+text+"\\n\"";