extractBreakingChanges static method
Extract breaking-change descriptions from markdown.
Heuristics:
- Any heading containing "breaking" (case-insensitive) — the section body is returned.
- Any bullet or paragraph that contains one of the marker phrases
(
BREAKING,Breaking Change, or the warning emoji⚠️).
Implementation
static List<String> extractBreakingChanges(String markdown) {
final results = <String>[];
final seen = <String>{};
// Strategy 1: section-level headings.
final sections = parseSections(markdown);
_collectBreakingSections(sections, results, seen);
// Strategy 2: line-level scanning for bullets / paragraphs.
final lines = markdown.split('\n');
for (final line in lines) {
final trimmed = line.trim();
if (trimmed.isEmpty) continue;
if (_breakingMarker.hasMatch(trimmed)) {
// Strip leading bullet markers for cleanliness.
final cleaned = trimmed
.replaceFirst(RegExp(r'^[-*+]\s*'), '')
.replaceFirst(RegExp(r'^\d+\.\s*'), '')
.trim();
if (cleaned.isNotEmpty && !seen.contains(cleaned)) {
seen.add(cleaned);
results.add(cleaned);
}
}
}
return results;
}