Skip to content

Commit 1a13ea0

Browse files
committed
Fix bolded name bug.
1 parent 8b9eed4 commit 1a13ea0

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Shared/Supporting Files/Views/SampleLink.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)