class ReeText::Highlight

def call(text, phrases = nil, **opts, &block)

def call(text, phrases = nil, **opts, &block)
  options = DEFAULTS.merge(opts)
  text = sanitize_html(text) if options[:sanitize]
  if !phrases
    text
  else
    match = Array(phrases).map do |p|
      Regexp === p ? p.to_s : Regexp.escape(p)
    end.join("|")
    if block_given?
      text.gsub(/(#{match})(?![^<]*?>)/i, &block)
    else
      highlighter = options[:highlighter]
      text.gsub(/(#{match})(?![^<]*?>)/i, highlighter)
    end
  end
end