stripJsonBlock static method
Removes all found JSON blocks from the text.
Implementation
static String stripJsonBlock(String text) {
final markdownRegex = RegExp(r'```(?:json)?\s*([\s\S]*?)\s*```');
String processed = text.replaceAll(markdownRegex, '');
if (processed.length == text.length) {
final String? jsonString = _extractBalancedJson(text);
if (jsonString != null) {
processed = text.replaceFirst(jsonString, '');
}
}
return processed.trim();
}