String _processLines()

in packages/code_excerpt_updater/lib/src/code_excerpt_updater.dart [124:148]


  String _processLines() {
    final output = <String>[];
    while (_lines.isNotEmpty) {
      final line = _lines.removeAt(0);
      output.add(line);
      if (!line.contains('<?code-excerpt')) continue;
      final match = procInstrRE.firstMatch(line);
      if (match == null) {
        _reporter.error('invalid processing instruction: $line');
        continue;
      }
      if (!(match[0]?.endsWith('?>') ?? false)) {
        _reporter
            .warn('processing instruction must be closed using "?>" syntax');
      }
      final info = _argProcessor.extractAndNormalizeArgs(match);

      if (info.unnamedArg == null) {
        _processSetInstruction(info);
      } else {
        output.addAll(_getUpdatedCodeBlock(info));
      }
    }
    return output.join(eol);
  }