Skip to content

Commit dba08f8

Browse files
authored
Apply the current text style foreground color to code blocks (#228)
1 parent e3d6678 commit dba08f8

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Sources/MarkdownUI/Views/Blocks/CodeBlockView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ struct CodeBlockView: View {
2525
private var label: some View {
2626
self.codeSyntaxHighlighter.highlightCode(self.content, language: self.fenceInfo)
2727
.textStyleFont()
28+
.textStyleForegroundColor()
2829
}
2930
}

Sources/MarkdownUI/Views/Environment/Environment+TextStyle.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ extension View {
2121
}
2222
}
2323

24+
func textStyleForegroundColor() -> some View {
25+
TextStyleAttributesReader { attributes in
26+
self.foregroundColor(attributes.foregroundColor)
27+
}
28+
}
29+
2430
func textStyle(_ textStyle: TextStyle) -> some View {
2531
self.transformEnvironment(\.textStyle) {
2632
$0 = $0.appending(textStyle)

0 commit comments

Comments
 (0)