Add a convenience initializer for attributed strings from an html string
This commit is contained in:
parent
2a00b4a4a9
commit
d84ed6068f
@ -81,4 +81,9 @@ extension NSAttributedString {
|
||||
return mutable.copy() as! NSAttributedString
|
||||
}
|
||||
|
||||
convenience init(html: String) {
|
||||
let data = html.data(using: .utf8)!
|
||||
self.init(html: data, options: [.characterEncoding: String.Encoding.utf8.rawValue], documentAttributes: nil)!
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -85,8 +85,7 @@ struct ArticleStringFormatter {
|
||||
|
||||
static func attributedTruncatedTitle(_ article: Article) -> NSAttributedString {
|
||||
let title = truncatedTitle(article, forHTML: true)
|
||||
let data = title.data(using: .utf8)!
|
||||
let attributed = NSAttributedString(html: data, options: [.characterEncoding: String.Encoding.utf8.rawValue], documentAttributes: nil)!
|
||||
let attributed = NSAttributedString(html: title)
|
||||
return attributed
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user