-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathENRMTextRenderer.m
More file actions
37 lines (31 loc) · 1.41 KB
/
ENRMTextRenderer.m
File metadata and controls
37 lines (31 loc) · 1.41 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
#import "ENRMTextRenderer.h"
#import "AccessibilityInfo.h"
#import "AttributedRenderer.h"
#import "MarkdownASTNode.h"
#import "RenderContext.h"
#import "StyleConfig.h"
@implementation ENRMRenderResult
@end
ENRMRenderResult *ENRMRenderASTNodes(NSArray<MarkdownASTNode *> *nodes, StyleConfig *config, BOOL allowTrailingMargin,
BOOL allowFontScaling, CGFloat maxFontSizeMultiplier,
NSWritingDirection writingDirection)
{
MarkdownASTNode *root = [[MarkdownASTNode alloc] initWithType:MarkdownNodeTypeDocument];
for (MarkdownASTNode *node in nodes) {
[root addChild:node];
}
AttributedRenderer *renderer = [[AttributedRenderer alloc] initWithConfig:config];
[renderer setAllowTrailingMargin:allowTrailingMargin];
RenderContext *context = [RenderContext new];
context.allowFontScaling = allowFontScaling;
context.maxFontSizeMultiplier = maxFontSizeMultiplier;
context.writingDirection = writingDirection;
NSMutableAttributedString *attributedText = [renderer renderRoot:root context:context];
[context applyLinkAttributesToString:attributedText];
ENRMRenderResult *result = [[ENRMRenderResult alloc] init];
result.attributedText = attributedText;
result.context = context;
result.accessibilityInfo = [AccessibilityInfo infoFromContext:context];
result.lastElementMarginBottom = [renderer getLastElementMarginBottom];
return result;
}