@@ -11,7 +11,7 @@ extension NSAttributedString
1111 static let lengthOfTextAttachment = NSAttributedString ( attachment: NSTextAttachment ( ) ) . length
1212
1313 // MARK: - Initializers
14-
14+
1515 /// Helper Initializer: returns an Attributed String, with the specified attachment, styled with a given
1616 /// collection of attributes.
1717 ///
@@ -21,24 +21,24 @@ extension NSAttributedString
2121
2222 self . init ( . textAttachment, attributes: attributesWithAttachment)
2323 }
24-
24+
2525 public convenience init ( attachment: NSTextAttachment , caption: NSAttributedString , attributes: [ NSAttributedString . Key : Any ] ) {
2626 let figure = Figure ( )
2727 let figcaption = Figcaption ( defaultFont: UIFont . systemFont ( ofSize: 14 ) , storing: nil )
28-
28+
2929 let figureAttributes = attributes. appending ( figure)
3030 let finalString = NSMutableAttributedString ( attachment: attachment, attributes: figureAttributes)
31-
31+
3232 let mutableCaption = NSMutableAttributedString ( attributedString: caption)
3333 mutableCaption. append ( paragraphProperty: figure)
3434 mutableCaption. append ( paragraphProperty: figcaption)
35-
35+
3636 let paragraphSeparator = NSAttributedString ( . paragraphSeparator, attributes: [ : ] )
37-
37+
3838 finalString. append ( paragraphSeparator)
3939 finalString. append ( mutableCaption)
4040 finalString. append ( paragraphSeparator)
41-
41+
4242 self . init ( attributedString: finalString)
4343 }
4444
@@ -103,47 +103,47 @@ extension NSAttributedString
103103 guard let captionRange = self . captionRange ( for: attachment) else {
104104 return nil
105105 }
106-
106+
107107 let string = attributedSubstring ( from: captionRange) . mutableCopy ( ) as! NSMutableAttributedString
108-
108+
109109 for character in Character . paragraphBreakingCharacters {
110110 string. replaceOcurrences ( of: String ( character) , with: " " )
111111 }
112-
112+
113113 return NSAttributedString ( attributedString: string)
114114 }
115115
116116 public func captionRange( for attachment: NSTextAttachment ) -> NSRange ? {
117117 guard let figureRange = self . figureRange ( for: attachment) else {
118118 return nil
119119 }
120-
120+
121121 return figcaptionRanges ( within: figureRange) . first
122122 }
123123
124124 // MARK: - Captions: Figure and Figcaption property ranges
125125
126126 private func figcaptionRanges( within range: NSRange ) -> [ NSRange ] {
127127 var ranges = [ NSRange] ( )
128-
128+
129129 enumerateParagraphRanges ( spanning: range) { ( _, enclosingRange) in
130130 guard let paragraphStyle = attribute ( . paragraphStyle, at: enclosingRange. lowerBound, effectiveRange: nil ) as? ParagraphStyle else {
131131 return
132132 }
133-
133+
134134 if paragraphStyle. hasProperty ( where: { $0 is Figcaption } ) {
135135 ranges. append ( enclosingRange)
136136 }
137137 }
138-
138+
139139 return ranges
140140 }
141141
142142 private func figureRange( for attachment: NSTextAttachment ) -> NSRange ? {
143143 guard let attachmentRange = ranges ( forAttachment: attachment) . first else {
144144 return nil
145145 }
146-
146+
147147 let paragraphRange = self . paragraphRange ( for: attachmentRange)
148148
149149 guard let paragraphStyle = self . attribute ( . paragraphStyle, at: paragraphRange. lowerBound, effectiveRange: nil ) as? ParagraphStyle ,
0 commit comments