foldItemLabel function

String? foldItemLabel(
  1. SemanticNode item, {
  2. int maxChars = 60,
})

What a folded item is called in the digest: all its texts joined with ·, cut at maxChars. Null when it says nothing.

Implementation

String? foldItemLabel(SemanticNode item, {int maxChars = 60}) {
  final texts = _texts(item);
  if (texts.isEmpty) return null;
  final flat = texts.join(' · ').replaceAll(RegExp(r'\s+'), ' ').trim();
  return flat.length <= maxChars ? flat : '${flat.substring(0, maxChars - 1)}…';
}