notationCallsIn function

Set<String> notationCallsIn(
  1. String text,
  2. Set<String> types
)

The names of types that text calls: a line written with one as its word (Card#c "…", Card.compact), or type=Card.

Implementation

Set<String> notationCallsIn(String text, Set<String> types) {
  if (types.isEmpty) return const {};
  final out = <String>{};
  for (final m in RegExp(r'(?:^[ \t]*|\btype=)([A-Z][A-Za-z0-9_]*)', multiLine: true).allMatches(text)) {
    if (types.contains(m[1])) out.add(m[1]!);
  }
  return out;
}