File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Shared/Supporting Files/Views Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -131,11 +131,18 @@ private extension String {
131131 /// - Parameter substring: The substring to bold.
132132 /// - Returns: The attributed string with the bolded substring.
133133 func boldingFirstOccurrence( of substring: String ) -> AttributedString {
134- if let range = localizedStandardRange ( of: substring. trimmingCharacters ( in: . whitespacesAndNewlines) ) ,
135- let boldedString = try ? AttributedString ( markdown: replacingCharacters ( in: range, with: " ** \( self [ range] ) ** " ) ) {
136- return boldedString
137- } else {
138- return AttributedString ( self )
134+ var attributedString = AttributedString ( self )
135+
136+ let trimmedSubstring = substring. trimmingCharacters ( in: . whitespacesAndNewlines)
137+ if let range = localizedStandardRange ( of: trimmedSubstring) {
138+ let substring = self [ range]
139+
140+ if let boldedSubstring = try ? AttributedString ( markdown: " ** \( substring) ** " ) ,
141+ let attributedRange = attributedString. range ( of: substring) {
142+ attributedString. replaceSubrange ( attributedRange, with: boldedSubstring)
143+ }
139144 }
145+
146+ return attributedString
140147 }
141148}
You can’t perform that action at this time.
0 commit comments