Method: MaRuKu::Out::HTML#to_html_link

Defined in:
lib/maruku/output/to_html.rb


641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
# File 'lib/maruku/output/to_html.rb', line 641

def to_html_link
  a = {}
  id = self.ref_id || children_to_s

  if ref = @doc.refs[sanitize_ref_id(id)] || @doc.refs[sanitize_ref_id(children_to_s)]
    a['href'] = ref[:url] if ref[:url]
    a['title'] = ref[:title] if ref[:title]
  else
    maruku_error "Could not find ref_id = #{id.inspect} for #{self.inspect}\n" +
      "Available refs are #{@doc.refs.keys.inspect}"
    tell_user "Not creating a link for ref_id = #{id.inspect}.\n"
    if (self.ref_id)
      return "[#{children_to_s}][#{id}]"
    else
      return "[#{children_to_s}]"
    end
  end

  wrap_as_element('a', a)
end