@@ -4,11 +4,13 @@ extension InlineNode {
4
4
func renderAttributedString(
5
5
baseURL: URL ? ,
6
6
textStyles: InlineTextStyles ,
7
+ softBreakMode: SoftBreak . Mode ,
7
8
attributes: AttributeContainer
8
9
) -> AttributedString {
9
10
var renderer = AttributedStringInlineRenderer (
10
11
baseURL: baseURL,
11
12
textStyles: textStyles,
13
+ softBreakMode: softBreakMode,
12
14
attributes: attributes
13
15
)
14
16
renderer. render ( self )
@@ -21,12 +23,19 @@ private struct AttributedStringInlineRenderer {
21
23
22
24
private let baseURL : URL ?
23
25
private let textStyles : InlineTextStyles
26
+ private let softBreakMode : SoftBreak . Mode
24
27
private var attributes : AttributeContainer
25
28
private var shouldSkipNextWhitespace = false
26
29
27
- init ( baseURL: URL ? , textStyles: InlineTextStyles , attributes: AttributeContainer ) {
30
+ init (
31
+ baseURL: URL ? ,
32
+ textStyles: InlineTextStyles ,
33
+ softBreakMode: SoftBreak . Mode ,
34
+ attributes: AttributeContainer
35
+ ) {
28
36
self . baseURL = baseURL
29
37
self . textStyles = textStyles
38
+ self . softBreakMode = softBreakMode
30
39
self . attributes = attributes
31
40
}
32
41
@@ -67,10 +76,13 @@ private struct AttributedStringInlineRenderer {
67
76
}
68
77
69
78
private mutating func renderSoftBreak( ) {
70
- if self . shouldSkipNextWhitespace {
79
+ switch softBreakMode {
80
+ case . space where self . shouldSkipNextWhitespace:
71
81
self . shouldSkipNextWhitespace = false
72
- } else {
82
+ case . space :
73
83
self . result += . init( " " , attributes: self . attributes)
84
+ case . lineBreak:
85
+ self . renderLineBreak ( )
74
86
}
75
87
}
76
88
0 commit comments