extractSections method
Implementation
Map<String, String> extractSections(String content) {
final sectionRegex = RegExp(
r"""@section\s*\(\s*['"](.+?)['"]\s*\)\s*([\s\S]+?)@endsection""",
);
sections.clear(); // clear old values
for (final match in sectionRegex.allMatches(content)) {
final name = match.group(1)!;
final body = match.group(2)!.trim();
sections[name] = body;
}
return sections;
}