JSFiddle - React, Tailwind, and code Playground
JavaScript
var reparse = function(text) {
//first replace all the quotes, then restore them in all [code] tags
var res = text.split('"').join('"'), codes = res.match(/\[code\].*?\[\/code\]/gi);
for(var m in codes) res = res.split(codes[m]).join(codes[m].split('"').join('"'));
return res
}
document.getElementById("commentForm").addEventListener("submit",function(){document.getElementById("msg").value=reparse(document.getElementById("msg").value)},false)