// // String+HtmlAttributed.swift // CovidSafe // // Copyright © 2021 Australian Government. All rights reserved. // import UIKit extension String { func htmlDocumentString(font: UIFont, withAdditionalCSS: String = "") -> String { let htmlTemplate = """ \(self) """ return htmlTemplate } func htmlDocumentAttributedString(font: UIFont, withAdditionalCSS: String = "") -> NSAttributedString? { let htmlTemplate = """ \(self) """ guard let data = htmlTemplate.data(using: .unicode) else { return nil } guard let attributedString = try? NSAttributedString( data: data, options: [.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil ) else { return nil } return attributedString } }