func attachment(_ attachment: NSTextAttachment, range: NSRange? = nil) -> NSAttributedString {
            let mutableAttributedString = NSMutableAttributedString(string: string, attributes: attributes())
            mutableAttributedString.addAttribute(NSAttributedString.Key.attachment, value: attachment, range: attributedStringRange(range))
            return mutableAttributedString as NSAttributedString
        }