replaceReadmeSection function
Replaces the block between kReadmeStart and kReadmeEnd in text
with section; appends the section when the markers are absent.
Implementation
String replaceReadmeSection(String text, String section) {
final s = text.indexOf(kReadmeStart);
final e = text.indexOf(kReadmeEnd);
return (s >= 0 && e > s)
? text.replaceRange(s, e + kReadmeEnd.length, section)
: '${text.trimRight()}\n\n$section\n';
}