summary property
String
summary
Implementation
String get summary {
final firstSentenceMatch = RegExp(r'^.*?\\n');
final matchParen = RegExp(r'\(.*\)');
final matchLink = RegExp(r'!?\[.*]]?');
final matchFullHtml = RegExp(r'<.*?\/.*?>');
final matchHeader = RegExp(r'#+\s.*?\n');
final matchTag = RegExp('<.*?>');
final matchUrl = RegExp(r'https?:\/\/[^\s]*');
final matchMultipleSpaces = RegExp(r'\s\s+');
final matchPostedTag = RegExp('Posted Using.*');
// print('_getSummaryText > $value');
// Note that the order is important, as we are removing nested items
final plainText = body
.replaceAll(matchFullHtml, '')
.replaceAll(matchParen, '')
.replaceAll(matchLink, '')
.replaceAll(matchHeader, '')
.replaceAll(matchTag, '')
.replaceAll(matchUrl, '')
.replaceAll('*', '')
.replaceAll('---', '')
.replaceAll('\n', '')
.replaceAll(matchMultipleSpaces, ' ')
.replaceAll(matchPostedTag, '')
.trim();
// print(' plainText: this.$plainText');
final summary = firstSentenceMatch.stringMatch(plainText) ?? plainText;
// print('_getSummaryText < $summary');
return summary;
}