diff --git a/Frameworks/RSCore/RSCore/NSString+RSCore.h b/Frameworks/RSCore/RSCore/NSString+RSCore.h index 1f8e9354c..1a454fa89 100755 --- a/Frameworks/RSCore/RSCore/NSString+RSCore.h +++ b/Frameworks/RSCore/RSCore/NSString+RSCore.h @@ -59,6 +59,7 @@ typedef struct { - (NSString *)rs_stringByStrippingSuffix:(NSString *)suffix caseSensitive:(BOOL)caseSensitive; - (NSString *)rs_stringByStrippingHTML:(NSUInteger)maxCharacters; +- (NSString *)rs_stringByConvertingToPlainText; /*Filename from path, file URL string, or external URL string.*/ diff --git a/Frameworks/RSCore/RSCore/NSString+RSCore.m b/Frameworks/RSCore/RSCore/NSString+RSCore.m index c28a7e9c0..9e2ed073d 100755 --- a/Frameworks/RSCore/RSCore/NSString+RSCore.m +++ b/Frameworks/RSCore/RSCore/NSString+RSCore.m @@ -301,6 +301,49 @@ NSString *RSStringReplaceAll(NSString *stringToSearch, NSString *searchFor, NSSt return (__bridge_transfer NSString *)s; } +- (NSString *)rs_stringByConvertingToPlainText { + + if (![self containsString:@"<"]) { + return self; + } + + NSMutableString *preflightedCopy = [self mutableCopy]; + [preflightedCopy replaceOccurrencesOfString:@"
" withString:@"\n\n" options:NSCaseInsensitiveSearch range:NSMakeRange(0, preflightedCopy.length)]; + [preflightedCopy replaceOccurrencesOfString:@"" withString:@"\n\n" options:NSCaseInsensitiveSearch range:NSMakeRange(0, preflightedCopy.length)]; + [preflightedCopy replaceOccurrencesOfString:@"
" withString:@"\n" options:NSCaseInsensitiveSearch range:NSMakeRange(0, preflightedCopy.length)]; + [preflightedCopy replaceOccurrencesOfString:@"
" withString:@"\n\n" options:NSCaseInsensitiveSearch range:NSMakeRange(0, preflightedCopy.length)]; + [preflightedCopy replaceOccurrencesOfString:@"