foldDigest function
The digest entries for the folded tail of a run (everything after the first
item): "label" #hash pairs, at most max, then +N.
Implementation
String foldDigest(List<SemanticNode> items, String? runBase, {int max = 10}) {
final parts = <String>[];
for (final item in items.take(max)) {
final label = foldItemLabel(item);
final ref = foldItemRef(item, runBase);
if (label == null && ref == null) continue;
parts.add([if (label != null) '"$label"', if (ref != null) ref].join(' '));
}
final rest = items.length - max;
if (rest > 0) parts.add('+$rest');
return parts.join(', ');
}