   }
 }
 
+protocol ContextLabelDelegate: class {
+  
+  func contextLabel(_ sender: ContextLabel, textFontForLinkResult linkResult: LinkResult) -> UIFont
+  
+  func contextLabel(_ sender: ContextLabel, foregroundColorForLinkResult linkResult: LinkResult) -> UIColor
+  
+  func contextLabel(_ sender: ContextLabel, foregroundHighlightedColorForLinkResult linkResult: LinkResult) -> UIColor
+  
+  func contextLabel(_ sender: ContextLabel, underlineStyleForLinkResult linkResult: LinkResult) -> NSUnderlineStyle
+
+  func contextLabel(_ sender: ContextLabel, modifiedAttributedString: NSAttributedString) -> NSAttributedString
+
+  func contextLabel(_ sender: ContextLabel, colorForTextAttachment textAttachment: NSTextAttachment) -> UIColor
+
+  func contextLabel(_ sender: ContextLabel, prefixForTextAttachment textAttachment: NSTextAttachment) -> String
+
+  func contextLabel(_ sender: ContextLabel, suffixForTextAttachment textAttachment: NSTextAttachment) -> String
+
+  func contextLabel(_ sender: ContextLabel, didTouchWithTouchResult touchResult: TouchResult)
+  
+  func contextLabel(_ sender: ContextLabel, didCopy text: String!)
+}
+
 open class ContextLabel: UILabel, NSLayoutManagerDelegate, UIGestureRecognizerDelegate {
   
   public enum LinkDetectionType {

  
  open override func copy(_ sender: Any?) {
    UIPasteboard.general.string = text
    didCopy(text)
  }
  
  open override var intrinsicContentSize : CGSize {

  fileprivate func addLinkAttributesTo(_ attributedString: NSAttributedString, with linkResults: [LinkResult], highlighted: Bool = false) -> NSAttributedString {
    let mutableAttributedString = NSMutableAttributedString(attributedString: attributedString)
    for linkResult in linkResults {
      
      var font = self.font
      if let delegate = delegate {
        font = delegate.contextLabel(self, textFontForLinkResult: linkResult)
      } else if let textFont = textFont?(linkResult) {
        font = textFont
      }
      
      var textColor = foregroundColor(linkResult)
      if let delegate = delegate {
        textColor = delegate.contextLabel(self, foregroundColorForLinkResult: linkResult)
      }
      
      var highlightedTextColor = foregroundHighlightedColor(linkResult)
      if let delegate = delegate {
        highlightedTextColor = delegate.contextLabel(self, foregroundHighlightedColorForLinkResult: linkResult)
      }
      
      let color = (highlighted) ? highlightedTextColor ?? self.highlightedTextColor(textColor) : textColor
      
      var underlineStyle = self.underlineStyle(linkResult)
      if let delegate = delegate {
        underlineStyle = delegate.contextLabel(self, underlineStyleForLinkResult: linkResult)
      }
      
      let attributes = self.attributes(with: font, textColor: color, underlineStyle: underlineStyle)
      
      mutableAttributedString.setAttributes(attributes, range: linkResult.range)
    }
