layerContext function
Finds context-anchored value spans in text.
Pure function; see the library docs for what counts as an anchor.
Implementation
List<RedactionMatch> layerContext(String text, RedactionConfig cfg) {
if (text.isEmpty) return const [];
if (!text.contains('=') && !text.contains(':')) return const [];
final matches = <RedactionMatch>[];
void add(int start, int end, String label) {
final match = RedactionMatch(
start: start,
end: end,
layer: RedactionLayer.context,
kindLabel: label,
);
if (!matches.any(match.overlaps)) matches.add(match);
}
_scanContextValues(text, add);
_scanCertValues(text, add);
return matches;
}