@@ -6,14 +6,16 @@ extension Sequence where Element == InlineNode {
66 textStyles: InlineTextStyles ,
77 images: [ String : Image ] ,
88 softBreakMode: SoftBreak . Mode ,
9- attributes: AttributeContainer
9+ attributes: AttributeContainer ,
10+ placeholderImage: Text ?
1011 ) -> Text {
1112 var renderer = TextInlineRenderer (
1213 baseURL: baseURL,
1314 textStyles: textStyles,
1415 images: images,
1516 softBreakMode: softBreakMode,
16- attributes: attributes
17+ attributes: attributes,
18+ placeholderImage: placeholderImage
1719 )
1820 renderer. render ( self )
1921 return renderer. result
@@ -28,20 +30,23 @@ private struct TextInlineRenderer {
2830 private let images : [ String : Image ]
2931 private let softBreakMode : SoftBreak . Mode
3032 private let attributes : AttributeContainer
33+ private let placeholderImage : Text ?
3134 private var shouldSkipNextWhitespace = false
3235
3336 init (
3437 baseURL: URL ? ,
3538 textStyles: InlineTextStyles ,
3639 images: [ String : Image ] ,
3740 softBreakMode: SoftBreak . Mode ,
38- attributes: AttributeContainer
41+ attributes: AttributeContainer ,
42+ placeholderImage: Text ?
3943 ) {
4044 self . baseURL = baseURL
4145 self . textStyles = textStyles
4246 self . images = images
4347 self . softBreakMode = softBreakMode
4448 self . attributes = attributes
49+ self . placeholderImage = placeholderImage
4550 }
4651
4752 mutating func render< S: Sequence > ( _ inlines: S ) where S. Element == InlineNode {
@@ -103,6 +108,8 @@ private struct TextInlineRenderer {
103108 private mutating func renderImage( _ source: String ) {
104109 if let image = self . images [ source] {
105110 self . result = self . result + Text( image)
111+ } else if let placeholderImage {
112+ self . result = self . result + placeholderImage
106113 }
107114 }
108115
0 commit comments