Skip to content

Commit

Permalink
Set background color for code blocks on iOS (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekzaw authored Jan 16, 2024
1 parent e8cae9c commit eafc739
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ios/RCTMarkdownUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ - (NSAttributedString *)parseMarkdown:(nullable NSAttributedString *)input
[_quoteRanges addObject:[NSValue valueWithRange:range]];
} else if ([type isEqualToString:@"pre"]) {
[attributedString addAttribute:NSForegroundColorAttributeName value:_markdownStyle.preColor range:range];
NSRange rangeForBackground = [inputString characterAtIndex:range.location] == '\n' ? NSMakeRange(range.location + 1, range.length - 1) : range;
[attributedString addAttribute:NSBackgroundColorAttributeName value:_markdownStyle.preBackgroundColor range:rangeForBackground];
// TODO: pass background color and ranges to layout manager
} else if ([type isEqualToString:@"h1"]) {
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
Expand Down

0 comments on commit eafc739

Please sign in to comment.