Simply convert HTML to readable strings or attributed string in Swift!
Installation can be done via Swift Package Manager or by dragging Sources/DecodeHTML into your project.
dependencies: [
.package(url: "https://github.com/flowbe/DecodeHTML.git", .upToNextMajor(from: "1.0.0"))
]
This package adds 2 properties to String
.
htmlToString
:
let myHtmlString = "C’est la France"
print("\(myHtmlString.htmlToString)") // prints "C'est la France"
htmlToAttributedString
:
let myHtmlString = "C’est la France"
let label = UILabel()
label.attributedText = myHtmlString.htmlToAttributedString