paragraphEnd function
Index of the end of the paragraph containing i: the next line break that
is followed by a blank line, or the end of text.
Implementation
int paragraphEnd(String text, int i) {
var k = text.indexOf('\n', i);
while (k != -1) {
var j = k + 1;
while (j < text.length &&
(text.codeUnitAt(j) == _space || text.codeUnitAt(j) == _tab)) {
j += 1;
}
if (j >= text.length || text.codeUnitAt(j) == 0x0A) {
return k;
}
k = text.indexOf('\n', j);
}
return text.length;
}