X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=www%2Fjs%2Fblerg.js;h=9f92594ba51b22777d5855bf0390d4854d0bb3b9;hb=f4bf2d2efc566e9f165b97bda72cd5a27e0d2b19;hp=4efad6a33b881fcbc605272a21f26915a1823a87;hpb=53272b3c1ec9303c69ccd55facfd5b90598a376c;p=blerg.git diff --git a/www/js/blerg.js b/www/js/blerg.js index 4efad6a..9f92594 100644 --- a/www/js/blerg.js +++ b/www/js/blerg.js @@ -272,26 +272,82 @@ User.prototype.loadItems = function(from, to) { function mangleRecord(record, template) { record.recInt = parseInt(record.record); - // Sanitize HTML input - record.data = record.data.replace(/&/g, '&').replace(//g, '>'); + var lines = record.data.split(/\r?\n/); + if (lines[lines.length - 1] == '') + lines.pop(); + + var out = ['

']; + var endpush = null; + var listMode = false; + lines.each(function(l) { + if (l == '') { + if (out[out.length - 1] == '
') { + out[out.length - 1] = '

'; + } + if (out[out.length - 1] == '') { + out.push(''); + out.push('

'); + listMode = false; + } + return; + } + + if (l[0] == '>') { + var pi = out.lastIndexOf('

'); + if (pi != -1) { + out[pi] = '

'; + l = l.replace(/^>\s*/, ''); + } + } + if (l[0] == '*') { + if (!listMode) { + var pi = out.lastIndexOf('

'); + out[pi] = '