/** * Helper method to convert "\n" to <br>. * @param str * @returns {string} */ function nl2br (str) { return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + '<br>' + '$2') }