+
+ for (var i = 0; i < nPara; i++) {
+ // Remove numbered references such as "[1,3,4]" from text
+ var text = obj[i].replace(/\[[0-9,]+\]/g, '');
+ // Next line from http://stackoverflow.com/questions/18914629/split-string-into-sentences-in-javascript
+ var sentences = text.replace(/([.?!])\s*(?=[A-Z])/g, "$1|").split("|");
+ if (sentences.length > nSent)
+ sentences.length = nSent;
+
+ acc.push('<p>', sentences.join(' '), '</p>');
+ nSent -= sentences.length;
+ if (nSent == 0)
+ break;
+ }
+