JSFiddle - React, Tailwind, and code Playground

HTML

<div id="heredoc"><!--heredoc content
with multiple lines, even 'quotes' or "double quotes",
beware not to close comment before time--></div>
<div id="result"><pre>
</pre></div>

JavaScript

var str = (function () {
    var div = jQuery('#heredoc');
    var str = div.html();
    str = str.replace(/^<\!--/, "").toString();
    str = str.replace(/-->$/, "").toString();
    return str;
})();
$('#result pre').html(str);