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, nil, :category => :span)
  elsif result = @src.scan(HTML_INSTRUCTION_RE)
    @tree.children << Element.new(:xml_pi, result, nil, :category => :span)
  elsif result = @src.scan(HTML_TAG_CLOSE_RE)
    warning("Found invalidly used HTML closing tag for '#{@src[1]}'")
    add_text(result)
  elsif result = @src.scan(HTML_TAG_RE)
    if HTML_BLOCK_ELEMENTS.include?(@src[1])
      warning("Found block HTML tag '#{@src[1]}' in span level text")
      add_text(result)
      return
    end
    reset_pos = @src.pos
    attrs = Utils::OrderedHash.new
    @src[2].scan(HTML_ATTRIBUTE_RE).each {|name,sep,val| attrs[name] = val.gsub(/\n+/, ' ')}
    do_parsing = (HTML_PARSE_AS_RAW.include?(@src[1]) || @tree.options[:parse_type] == :raw ? false : @doc.options[:parse_span_html])
    if val = html_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
        do_parsing = !HTML_PARSE_AS_RAW.include?(@src[1])
      elsif val == :raw
        do_parsing = false
      end
    end
    el = Element.new(:html_element, @src[1], attrs, :category => :span, :parse_type => (do_parsing ? :span : :raw))
    @tree.children << el
    stop_re = /<\/#{Regexp.escape(@src[1])}\s*>/
    if !@src[4] && HTML_ELEMENTS_WITHOUT_BODY.include?(el.value)
      warning("The HTML tag '#{el.value}' cannot have any content - auto-closing it")
    elsif !@src[4]
      if parse_spans(el, stop_re, (do_parsing ? nil : [:span_html]))
        @src.scan(stop_re)
      else
        warning("Found no end tag for '#{el.value}' - auto-closing it")
        add_text(@src.scan(/.*/m), el)
      end
    end
    Kramdown::Parser::Html::ElementConverter.new(@doc).process(el) if @doc.options[:html_to_native]
  else
    add_text(@src.scan(/./))
  end
end