Files
edx-platform/lms/static/js/edxnotes/utils/utils.js
2016-08-05 15:29:20 -04:00

25 lines
653 B
JavaScript

(function(define, undefined) {
'use strict';
define([], function($, _) {
/**
* Replaces all newlines in a string by HTML line breaks.
* @param {String} str The input string.
* @return `String` with '<br>' instead all newlines (\r\n, \n\r, \n and \r).
* @example
* nl2br("This\r\nis\n\ra\nstring\r")
* Output:
* This<br>
* is<br>
* a<br>
* string<br>
*/
var nl2br = function(str) {
return (str + '').replace(/(\r\n|\n\r|\r|\n)/g, '<br>');
};
return {
nl2br: nl2br
};
});
}).call(this, define || RequireJS.define);