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)
  if el.type == :a
    el.attr['href'] = href
  else
    el.attr['src'] = href
    el.attr['alt'] = alt_text
    el.children.clear
  end
  el.attr['title'] = title if title
  @tree.children << el
end