Node.js examples for String:HTML String
Converts plain text to HTML
/**// w w w. j a va 2s . co m * Converts plain text to HTML * @param text the plain text to convert * @returns the HTML version of the text */ function plain2html(text) { text = (text || ""); return text .replace(/&/g, "&") .replace(/</g, "<") .replace(/>/g, ">") .replace(/\t/g, " ") .replace(/ /g, "​ ​") .replace(/\r\n|\r|\n/g, "<br />"); }