mergeNoiseLines function

List<String> mergeNoiseLines(
  1. List<String> lines
)

Merges short noise-only lines into the following content line when useful.

Implementation

List<String> mergeNoiseLines(List<String> lines) {
  if (lines.isEmpty) {
    return lines;
  }

  final List<String> merged = <String>[];
  int i = 0;
  while (i < lines.length) {
    final String current = lines[i];
    if (_isNoiseLine(current)) {
      if (current.isEmpty) {
        merged.add(current);
      }
      i++;
      continue;
    }

    merged.add(current);
    i++;
  }

  return merged;
}