Skip to content

Commit e002e97

Browse files
authored
Merge pull request #3 from CareEvolution/eschramm/bulletIndentFix
Normalize bullet indents/tabs based on font size
2 parents 6e5a8e5 + b50531e commit e002e97

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

NSAttributedString+Markdown.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ @implementation NSAttributedString (Markdown)
175175

176176
NSString *const bulletFontName = @"HelveticaNeue-Medium";
177177

178-
CGFloat const bulletIndentWidth = 20.0;
178+
CGFloat const standardBulletIndentWidth = 20.0;
179179
#endif
180180

181181
#if ALLOW_UNDERLINE
@@ -623,6 +623,7 @@ static void updateAttributedString(NSMutableAttributedString *result, NSString *
623623

624624
NSRange listItemRangeWithBullet = NSMakeRange(mutatedBeginRange.location, endRange.location - mutatedBeginRange.location + endRange.length - mutationOffset - 1);
625625
NSMutableParagraphStyle *paragraphStyle = [[result attribute:NSParagraphStyleAttributeName atIndex:listItemRangeWithBullet.location effectiveRange:NULL] mutableCopy] ?: [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
626+
CGFloat bulletIndentWidth = standardBulletIndentWidth * baseFont.pointSize / 17;
626627
CGFloat bulletIndent = bulletIndentWidth * bulletLevel;
627628
CGFloat bulletedTextIndent = bulletIndentWidth * (bulletLevel + 1);
628629
NSTextTab *firstTabStop = [[NSTextTab alloc] initWithTextAlignment:NSTextAlignmentLeft location:bulletedTextIndent options:@{}];

0 commit comments

Comments
 (0)