extractAllCodeBlocks function
Returns all fenced code blocks as list of (language, code).
Implementation
List<(String, String)> extractAllCodeBlocks(String text) {
final RegExp fenced = RegExp(r'```(\w*)\n([\s\S]*?)```');
return fenced
.allMatches(text)
.map((Match m) => (m.group(1) ?? '', (m.group(2) ?? '').trim()))
.toList();
}