JSFiddle - React, Tailwind, and code Playground
HTML
<textarea id="input" name="Text1" cols="40" rows="5" placeholder="enter inout text here">number a =1
number b=2
number sum=0
sum =a +b
print sum</textarea>
<input type="button" value="test" />
<textarea id="output" name="Text2" cols="40" rows="5" placeholder="output"></textarea>
CSS
textarea {
white-space:pre-wrap;
}
JavaScript
$('input[type=button]').click(function () {
var html = "";
var lines = $('#input').val().replace(/([^\w 0-9])/g, "$1\n").replace(/\s+/g, "\n").split("\n");
for (var i = 0; i < lines.length; i++) {
//code here using lines[i] which will give you each line
html += lines[i];
html += "\n";
}
html = html.substring(0,html.length-1);
$("#output").html(html);
});