normalizeLabel function
A label as CommonMark compares it: trimmed, inner whitespace collapsed to one space, and case-folded.
Implementation
String normalizeLabel(String label) {
final trimmed = label.trim();
final collapsed = trimmed.contains(_whitespaceToCollapse)
? trimmed.replaceAll(_whitespaceRun, ' ')
: trimmed;
return collapsed.toLowerCase();
}