orderedMarker function
N. or N) ordered marker. Returns (number, content).
Implementation
({int number, String content})? orderedMarker(String trimmed) {
var idx = 0;
while (idx < trimmed.length) {
final c = trimmed.codeUnitAt(idx);
if (c < _zero || c > _nine) {
break;
}
idx += 1;
}
if (idx == 0) {
return null;
}
if (idx < trimmed.length &&
(trimmed[idx] == '.' || trimmed[idx] == ')') &&
idx + 1 < trimmed.length &&
trimmed.codeUnitAt(idx + 1) == _space) {
final num = int.tryParse(trimmed.substring(0, idx)) ?? 1;
return (number: num, content: trimmed.substring(idx + 2));
}
return null;
}