normalizeLinkLabel function
"Normalizes" a link label, according to the CommonMark spec
.
CommonMark spec
https://spec.commonmark.org/0.30/#link-label
Implementation
String normalizeLinkLabel(String label) {
var text = label.trim().replaceAll(_oneOrMoreWhitespacePattern, ' ');
for (var i = 0; i < text.length; i++) {
final mapped = caseFoldingMap[text[i]];
if (mapped != null) {
text = text.replaceRange(i, i + 1, mapped);
}
}
return text;
}