class Kramdown::Parser::Kramdown

def add_link(el, href, title, alt_text = nil)

and the element itself to the @tree.
This helper methods adds the approriate attributes to the element +el+ of type +a+ or +img+
def add_link(el, href, title, alt_text = nil)
  el.options[:attr] ||= {}
  el.options[:attr]['title'] = title if title
  if el.type == :a
    el.options[:attr]['href'] = href
  else
    el.options[:attr]['src'] = href
    el.options[:attr]['alt'] = alt_text
    el.children.clear
  end
  @tree.children << el
end