class RDoc::Markup::ToHtmlCrossref

def link name, text, code = true, rdoc_ref: false

def link name, text, code = true, rdoc_ref: false
  if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])?@/
    name = $1
    label = $'
  end
  ref = @cross_reference.resolve name, text if name
  case ref
  when String then
    if rdoc_ref && @options.warn_missing_rdoc_ref
      puts "#{@from_path}: `rdoc-ref:#{name}` can't be resolved for `#{text}`"
    end
    ref
  else
    path = ref ? ref.as_href(@from_path) : +""
    if code and RDoc::CodeObject === ref and !(RDoc::TopLevel === ref)
      text = "<code>#{CGI.escapeHTML text}</code>"
    end
    if label
      if path =~ /#/
        path << "-label-#{label}"
      elsif ref&.sections&.any? { |section| label == section.title }
        path << "##{label}"
      elsif ref.respond_to?(:aref)
        path << "##{ref.aref}-label-#{label}"
      else
        path << "#label-#{label}"
      end
    end
    "<a href=\"#{path}\">#{text}</a>"
  end
end