Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions platform/ios/Bypass/Bypass/BPAttributedStringConverter.m
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ - (void)renderBlockQuoteElement:(BPElement *)element
[paragraphStyle setFirstLineHeadIndent:[_displaySettings quoteIndentation]];
[paragraphStyle setHeadIndent:[_displaySettings quoteIndentation]];
[paragraphStyle setTailIndent:-[_displaySettings quoteIndentation]];
[paragraphStyle setAlignment:_displaySettings.textAlignment];
attributes[NSParagraphStyleAttributeName] = paragraphStyle;

[target addAttributes:attributes range:effectiveRange];
Expand All @@ -279,6 +280,7 @@ - (void)renderBlockCodeElement:(BPElement *)element
[paragraphStyle setFirstLineHeadIndent:[_displaySettings codeIndentation]];
[paragraphStyle setHeadIndent:[_displaySettings codeIndentation]];
[paragraphStyle setTailIndent:-[_displaySettings codeIndentation]];
[paragraphStyle setAlignment:_displaySettings.textAlignment];
attributes[NSParagraphStyleAttributeName] = paragraphStyle;

[target addAttributes:attributes range:effectiveRange];
Expand All @@ -293,6 +295,7 @@ - (void)renderParagraphElement:(BPElement *)element
[paragraphStyle setParagraphSpacing:[_displaySettings paragraphSpacing]];
[paragraphStyle setLineSpacing:[_displaySettings paragraphLineSpacing]];
[paragraphStyle setFirstLineHeadIndent:[_displaySettings paragraphFirstLineHeadIndent]];
[paragraphStyle setAlignment:_displaySettings.textAlignment];

if(!self.renderedFirstParagraph) {
[paragraphStyle setFirstLineHeadIndent:[_displaySettings firstParagraphFirstLineHeadIndent]];
Expand All @@ -310,12 +313,10 @@ - (void)renderListItemElement:(BPElement *)element
{
NSUInteger level = 0;
BPElement *inspectedElement = [[element parentElement] parentElement];
NSMutableString *indentation = [NSMutableString string];


while ([inspectedElement elementType] == BPList
|| [inspectedElement elementType] == BPListItem) {
if ([inspectedElement elementType] == BPList) {
[indentation appendString:@"\t"];
++level;
}

Expand Down Expand Up @@ -349,14 +350,18 @@ - (void)renderListItemElement:(BPElement *)element

NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:[_displaySettings lineSpacingSmall]];
[paragraphStyle setAlignment:_displaySettings.textAlignment];
[paragraphStyle setHeadIndent:24*(level)+14];
[paragraphStyle setFirstLineHeadIndent:24*(level)];


NSDictionary *indentationAttributes = @{
NSFontAttributeName : [UIFont systemFontOfSize:[_displaySettings bulletIndentation]],
NSParagraphStyleAttributeName : paragraphStyle
};

NSAttributedString *attributedIndentation;
attributedIndentation = [[NSAttributedString alloc] initWithString:indentation
attributedIndentation = [[NSAttributedString alloc] initWithString:@"\u200B"
attributes:indentationAttributes];
[target insertAttributedString:attributedIndentation atIndex:effectiveRange.location];

Expand All @@ -376,6 +381,7 @@ - (void)renderHeaderElement:(BPElement *)element
[paragraphStyle setLineSpacing:[_displaySettings paragraphLineSpacingHeading]];
[paragraphStyle setFirstLineHeadIndent:[_displaySettings headerFirstLineHeadIndent]];
[paragraphStyle setHeadIndent:[_displaySettings headerHeadIndent]];
[paragraphStyle setAlignment:_displaySettings.textAlignment];
attributes[NSParagraphStyleAttributeName] = paragraphStyle;

// Override font weight and size attributes (but preserve all other attributes)
Expand Down
4 changes: 4 additions & 0 deletions platform/ios/Bypass/Bypass/BPDisplaySettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@
@property(nonatomic) CGFloat headerFirstLineHeadIndent;
@property(nonatomic) CGFloat headerHeadIndent;

// used to add text alignment to blocks if 'Natural' is not right (e.g. the text is known to be right-to-left
// on a left-to-right device.)
@property(nonatomic) NSTextAlignment textAlignment;

@end
1 change: 1 addition & 0 deletions platform/ios/Bypass/Bypass/BPDisplaySettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ - (id)init

self.paragraphLineSpacing = 1.2f;
self.paragraphLineSpacingHeading = 1.2f;
self.textAlignment = NSTextAlignmentNatural;

}
return self;
Expand Down