-
-
Save shibafu528/521a58c652baf328b9ea7c755bc68aa5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation Hoge | |
- (NSAttributedString *)expandAttributedContent { | |
DONStatusContentParser *parser = [[DONStatusContentParser alloc] initWithString:self.content]; | |
[parser parse]; | |
NSMutableAttributedString *body = [[NSMutableAttributedString alloc] initWithString:parser.textContent]; | |
[parser.linkRanges enumerateObjectsUsingBlock:^(NSValue * _Nonnull value, NSUInteger idx, BOOL * _Nonnull stop) { | |
NSRange range = value.rangeValue; | |
[body addAttribute:NSLinkAttributeName value:[parser.textContent substringWithRange:range] range:range]; | |
}]; | |
if (self.spoilerText.length) { | |
[body insertAttributedString:[[NSAttributedString alloc] initWithString:self.spoilerText] atIndex:0]; | |
return body; | |
} else { | |
return body; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment