Skip to content

Commit

Permalink
Fixed issue #09594: EM nl2br() function doesn't work when content com…
Browse files Browse the repository at this point in the history
…es from current page

Dev: uodated to raw nl2br for phpjs
Dev: Todo : adding phpjs in third_party to allow easily update ?
  • Loading branch information
Shnoulle committed Apr 3, 2015
1 parent 202f68f commit 678a3de
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions scripts/expressions/em_javascript.js
Expand Up @@ -13,8 +13,9 @@
* @author Thomas M. White (TMSWhite)
* @author Denis Chenu (Shnoulle)
*
* Portion from php.js is copyright 2012 Kevin van Zonneveld.
* php.js is dual licensed under the MIT licenses.
* Portion from php.js licensed under the MIT licenses.
* Copyright (c) 2013 Kevin van Zonneveld (http://kvz.io)
* and Contributors (http://phpjs.org/authors)
*/

function LEMcount()
Expand Down Expand Up @@ -1416,29 +1417,28 @@ function ltrim (str, charlist) {
return (str + '').replace(re, '');
}

function nl2br (str, is_xhtml) {
// Converts newlines to HTML line breaks
//
// version: 1107.2516
// discuss at: http://phpjs.org/functions/nl2br
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: Philip Peterson
// + improved by: Onno Marsman
// + improved by: Atli Þór
// + bugfixed by: Onno Marsman
// + input by: Brett Zamir (http://brett-zamir.me)
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: Brett Zamir (http://brett-zamir.me)
// + improved by: Maximusya
// * example 1: nl2br('Kevin\nvan\nZonneveld');
// * returns 1: 'Kevin\nvan\nZonneveld'
// * example 2: nl2br("\nOne\nTwo\n\nThree\n", false);
// * returns 2: '<br>\nOne<br>\nTwo<br>\n<br>\nThree<br>\n'
// * example 3: nl2br("\nOne\nTwo\n\nThree\n", true);
// * returns 3: '\nOne\nTwo\n\nThree\n'
var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '' : '<br>';

return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
function nl2br(str, is_xhtml) {
// discuss at: http://phpjs.org/functions/nl2br/
// original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Philip Peterson
// improved by: Onno Marsman
// improved by: Atli Þór
// improved by: Brett Zamir (http://brett-zamir.me)
// improved by: Maximusya
// bugfixed by: Onno Marsman
// bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// input by: Brett Zamir (http://brett-zamir.me)
// example 1: nl2br('Kevin\nvan\nZonneveld');
// returns 1: 'Kevin<br />\nvan<br />\nZonneveld'
// example 2: nl2br("\nOne\nTwo\n\nThree\n", false);
// returns 2: '<br>\nOne<br>\nTwo<br>\n<br>\nThree<br>\n'
// example 3: nl2br("\nOne\nTwo\n\nThree\n", true);
// returns 3: '<br />\nOne<br />\nTwo<br />\n<br />\nThree<br />\n'

var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br ' + '/>' : '<br>'; // Adjust comment to avoid issue on phpjs.org display

return (str + '')
.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
}

function number_format (number, decimals, dec_point, thousands_sep) {
Expand Down

0 comments on commit 678a3de

Please sign in to comment.