JSFiddle - React, Tailwind, and code Playground

HTML

<pre>
  1 строка
  2 строка
  3 строка
  4 строка
</pre>

JavaScript

$(document).ready(function(){
    text = $('pre').text();
    strs = text.split('\n');
    text = '';
    for(key in strs)
    {
        str = strs[key].trim()
        if(str.length) text+='<p>'+str+'</p>\n';
    }
    $('pre').text(text);
});