parseProjectIdea function

ProjectIdea parseProjectIdea(
  1. String md
)

Reads the ids of the Project Idea Markdown in md.

Implementation

ProjectIdea parseProjectIdea(String md) {
  final lines = md.split('\n');
  final items = <ProjectIdeaItem>[];
  final outOfScope = StringBuffer();
  var inOutOfScope = false;
  for (var i = 0; i < lines.length; i++) {
    final l = lines[i];
    if (l.startsWith('#')) inOutOfScope = l.startsWith('### 6.2');
    if (inOutOfScope && l.startsWith('|')) outOfScope.writeln(l);
    final c = _capability.firstMatch(l) ?? _constraint.firstMatch(l);
    if (c != null) {
      final text = StringBuffer(l);
      var j = i + 1;
      while (j < lines.length &&
          lines[j].startsWith('  ') &&
          lines[j].trim().isNotEmpty) {
        text.write(' ${lines[j].trim()}');
        j++;
      }
      final id = c.group(1)!;
      items.add(
        ProjectIdeaItem(
          id,
          id.startsWith('C-') ? 'constraint' : 'capability',
          '$text',
        ),
      );
      continue;
    }
    final r = _row.firstMatch(l);
    if (r != null && !inOutOfScope) {
      final id = r.group(1)!;
      items.add(
        ProjectIdeaItem(
          id,
          id.startsWith('N-') ? 'expectation' : 'decision',
          l,
        ),
      );
    }
  }
  return ProjectIdea(items, '$outOfScope');
}