malcommac / SwiftRichString

👩‍🎨 Elegant Attributed String composition in Swift sauce
MIT License
3.1k stars 211 forks source link

StyleXML's imageProvider callback provide parsed attributes #103

Closed malcommac closed 4 years ago

malcommac commented 4 years ago

imageProvider callback should provide a list of parsed attributes along with the image name.

let xmlText = """
- <img named="check" myAttribute="5" otherAttribute="test"/> Performed!
"""
let base = Style {
  $0.font = UIFont.boldSystemFont(ofSize: 14)
  $0.color = UIColor(hexString: "#8E8E8E")
}

let xmlStyle = StyleXML(base: base)
xmlStyle.imageProvider = { imageName, attributes in
  // attributes contains named, myAttribute and otherAttribute
}

self.textView?.attributedText = xmlText.set(style: xmlStyle)