         return CGRect(origin: targetPosition, size: targetBounds.size)
     }
 
-    func messageAttributedString() -> NSAttributedString {
+    func messageAttributedString(with attachment: NSTextAttachment) -> NSAttributedString {
         let attributes: [String: Any] = [
             NSForegroundColorAttributeName: textColor,
             NSFontAttributeName: textFont
         ]
 
-        return NSAttributedString(string: defaultText, attributes: attributes)
+        let htmlAttachment = attachment as? HTMLAttachment
+        let displayText = htmlAttachment?.rootTagName.uppercased() ?? defaultText
+
+        return NSAttributedString(string: "[\(displayText)]", attributes: attributes)
     }
 }

    }

    func textView(_ textView: TextView, boundsFor attachment: NSTextAttachment, with lineFragment: CGRect) -> CGRect {
        let message = messageAttributedString()

        let size = CGSize(width: lineFragment.size.width, height: lineFragment.size.height)
        var rect = boundingRect(for: message, size: size)

    func textView(_ textView: TextView, imageFor attachment: NSTextAttachment, with size: CGSize) -> UIImage? {
        UIGraphicsBeginImageContextWithOptions(size, false, 0)

        let message = messageAttributedString(with: attachment)
        let targetRect = boundingRect(for: message, size: size)

        message.draw(in: targetRect)
