extractFirstCodeBlock function

String? extractFirstCodeBlock(
  1. String markdown
)

Returns first fenced code block content or null. Audited: 2026-06-12 11:26 EDT

Implementation

String? extractFirstCodeBlock(String markdown) {
  final RegExp re = RegExp(r'```[\w]*\n([\s\S]*?)```');
  final Match? m = re.firstMatch(markdown);
  return m?.group(1)?.trim();
}