tsunamilx
8/12/2017 - 5:25 PM

nl2br.js

/**
 * 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')
}