-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrikethroughRenderer.m
More file actions
40 lines (32 loc) · 1.15 KB
/
StrikethroughRenderer.m
File metadata and controls
40 lines (32 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#import "StrikethroughRenderer.h"
#import "MarkdownASTNode.h"
#import "RenderContext.h"
#import "RendererFactory.h"
#import "StyleConfig.h"
@implementation StrikethroughRenderer {
__weak RendererFactory *_rendererFactory;
StyleConfig *_config;
}
- (instancetype)initWithRendererFactory:(id)rendererFactory config:(id)config
{
if (self = [super init]) {
_rendererFactory = rendererFactory;
_config = (StyleConfig *)config;
}
return self;
}
#pragma mark - Rendering
- (void)renderNode:(MarkdownASTNode *)node into:(NSMutableAttributedString *)output context:(RenderContext *)context
{
NSUInteger start = output.length;
[_rendererFactory renderChildrenOfNode:node into:output context:context];
NSRange range = NSMakeRange(start, output.length - start);
if (range.length == 0)
return;
// Apply strikethrough style
[output addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlineStyleSingle) range:range];
// Apply strikethrough line color (not text color)
RCTUIColor *strikethroughColor = [_config strikethroughColor];
[output addAttribute:NSStrikethroughColorAttributeName value:strikethroughColor range:range];
}
@end