All the sample code i have comea cross with just does not work with bold tags anymore. This also include italic html tags.
I am using the code from hacking swift as string extension.
var htmlAttributedString: NSAttributedString? {
if let attributedString = try? NSAttributedString(data: Data(self.utf8), options: [.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil) {
return attributedString
}
else {
return nil
}
}
var htmlString: String {
return htmlAttributedString?.string ?? ""
}
Then try
let string = "<b>sample</b>"
Text(string.htmlString)
The code looks about right. Just that the bold tag does not get rendered. Anyone know of a workaround? I tried the adding html style system hardcoding font trick but it did not work as well.
I tried the markdown alternative , no luck either (but this is a different topic).