class Kramdown::Parser::Kramdown

def parse_span_html

Parse the HTML at the current position as span level HTML.
def parse_span_html
  if result = @src.scan(HTML_COMMENT_RE)
    @tree.children << Element.new(:xml_comment, result, :type => :span)
  elsif result = @src.scan(HTML_INSTRUCTION_RE)
    @tree.children << Element.new(:xml_pi, result, :type => :span)
  elsif result = @src.scan(HTML_TAG_CLOSE_RE)
    warning("Found invalidly used HTML closing tag for '#{@src[1]}' - ignoring it")
  elsif result = @src.scan(HTML_TAG_RE)
    return if HTML_BLOCK_ELEMENTS.include?(@src[1])
    reset_pos = @src.pos
    attrs = {}
    @src[2].scan(HTML_ATTRIBUTE_RE).each {|name,sep,val| attrs[name] = val.gsub(/\n+/, ' ')}
    do_parsing = (HTML_PARSE_AS_RAW.include?(@src[1]) ? false : @doc.options[:parse_span_html])
    if val = get_parse_type(attrs.delete('markdown'))
      if val == :block
        warning("Cannot use block level parsing in span level HTML tag - using default mode")
      elsif val == :span
        do_parsing = true
      elsif val == :default
        (HTML_PARSE_AS_RAW.include?(@src[1]) ? false : true)
      elsif val == :raw
        do_parsing = false
      end
    end
    el = Element.new(:html_element, @src[1], :attr => attrs, :type => :span)
    stop_re = /<\/#{Regexp.escape(@src[1])}\s*>/
    if @src[4]
      @tree.children << el
    elsif HTML_ELEMENTS_WITHOUT_BODY.include?(el.value)
      warning("The HTML tag '#{el.value}' cannot have any content - auto-closing it")
      @tree.children << el
    else
      if parse_spans(el, stop_re, (do_parsing ? nil : [:span_html]), (do_parsing ? :text : :html_text))
        end_pos = @src.pos
        @src.scan(stop_re)
      else
        warning("Found no end tag for '#{el.value}' - auto-closing it")
        add_text(@src.scan(/.*/m))
      end
      @tree.children << el
    end
  else
    add_text(@src.scan(/./))
  end
end