readReviewNotes function
The reviewer-facing half of a review-notes file, as plain text.
Apple's field is plain text, so the markdown has to go. A reviewer
seeing literal ## and ** reads carelessness in the one document whose
job is to argue the opposite. The transformation is deliberately small and
predictable rather than a markdown renderer: heading hashes, bold markers,
and the angle brackets that stop a bare URL being auto-linked.
Length is checked here rather than at upload, because a note over the limit is refused after an archive has been transferred, and this is the package that exists to find that sort of thing without a network.
Implementation
String readReviewNotes(File file, {String label = 'review-notes.md'}) {
final whole = file.readAsStringSync();
final end = whole.indexOf(reviewNotesMarker);
final facing = end < 0 ? whole : whole.substring(0, end);
final text = facing
.replaceAll(RegExp(r'^#{1,6}\s+', multiLine: true), '')
.replaceAll('**', '')
.replaceAllMapped(RegExp(r'<(https?://[^>]+)>'), (m) => m.group(1)!)
.trim();
if (text.isEmpty) {
throw MetadataException(
'$label has nothing above $reviewNotesMarker — the whole file is marked '
'as not for Apple',
);
}
_checkLength('info', label, text, reviewNotesLimit);
return text;
}