@@ -113,12 +113,14 @@ public struct BBBuilder {
113113 let isNextNodeMedia = nodes [ safe: index + 1 ] ? . isMedia ?? false
114114 if isNextNodeTextable || isNextNodeMedia {
115115 logger. info ( " Next node is textable OR media, unwrapping " )
116- var isAttachmentDelimeneter = false
117- if case . attachment = nodes [ safe: index - 1 ] { isAttachmentDelimeneter = true }
116+ var isAttachmentDelimeter = false
117+ if case . attachment = nodes [ safe: index - 1 ] {
118+ isAttachmentDelimeter = true
119+ }
118120 mergedNodes [ mergedNodes. count - 1 ] = unwrap (
119121 node: node,
120122 with: mutableText,
121- isAttachmentDelimeter: isAttachmentDelimeneter ,
123+ isAttachmentDelimeter: isAttachmentDelimeter ,
122124 listType: listType
123125 )
124126 if listType != nil ,
@@ -156,11 +158,15 @@ public struct BBBuilder {
156158 mergedNodes. lastOrAppend = unwrap ( node: textNode, with: mutableText)
157159 continue
158160 }
159- let attachmentType = attachments [ attachmentIndex ] . type
160- switch attachmentType {
161+
162+ switch attachments [ attachmentIndex ] . type {
161163 case . file:
162164 logger. info ( " FILE attachment " )
163- let textNode = unwrap ( node: node, with: mutableText)
165+ var isAttachmentDelimeter = false
166+ if case let . text( text) = mergedNodes. last, text. string. last != " \n " {
167+ isAttachmentDelimeter = true
168+ }
169+ let textNode = unwrap ( node: node, with: mutableText, isAttachmentDelimeter: isAttachmentDelimeter)
164170 if !textNode. isEmptyText {
165171 mergedNodes. lastOrAppend = textNode
166172 } else {
@@ -169,7 +175,7 @@ public struct BBBuilder {
169175 continue
170176
171177 case . image:
172- break
178+ break // TODO: Move image attachment below here
173179 }
174180
175181 logger. info ( " IMAGE attachment " )
@@ -392,6 +398,10 @@ public struct BBBuilder {
392398 . foregroundColor: UIColor ( resource: . Labels. teritary)
393399 ] ) )
394400 }
401+
402+ if isAttachmentDelimeter {
403+ mutableString. insert ( NSAttributedString ( string: " \n " ) , at: 0 )
404+ }
395405
396406 attachmentString = mutableString
397407 }
0 commit comments