module Kramdown::Parser::Html::Parser
def parse_raw_html(el, &block)
When an HTML start tag is found, processing is deferred to #handle_html_start_tag,
element).
- The matching end tag for the element +el+ is found (only used if +el+ is an HTML
- The end of the document is reached.
Parsing continues until one of the following criteria are fulfilled:
Parse raw HTML from the current source position, storing the found elements in +el+.
def parse_raw_html(el, &block) @stack.push(@tree) @tree = el done = false while !@src.eos? && !done if (result = @src.scan_until(HTML_RAW_START)) add_text(result, @tree, :text) line = @src.current_line_number if (result = @src.scan(HTML_COMMENT_RE)) @tree.children << Element.new(:xml_comment, result, nil, category: :block, location: line) elsif (result = @src.scan(HTML_INSTRUCTION_RE)) @tree.children << Element.new(:xml_pi, result, nil, category: :block, location: line) elsif @src.scan(HTML_CDATA_RE) @tree.children << Element.new(:text, @src[1], nil, cdata: true, location: line) elsif @src.scan(HTML_TAG_RE) if method(:handle_html_start_tag).arity.abs >= 1 handle_html_start_tag(line, &block) else handle_html_start_tag(&block) # DEPRECATED: method needs to accept line number in 2.0 end elsif @src.scan(HTML_TAG_CLOSE_RE) if @tree.value == (HTML_ELEMENT[@tree.value] ? @src[1].downcase : @src[1]) done = true else add_text(@src.matched, @tree, :text) warning("Found invalidly used HTML closing tag for '#{@src[1]}' on " \ "line #{line} - ignoring it") end else add_text(@src.getch, @tree, :text) end else add_text(@src.rest, @tree, :text) @src.terminate if @tree.type == :html_element warning("Found no end tag for '#{@tree.value}' on line " \ "#{@tree.options[:location]} - auto-closing it") end done = true end end @tree = @stack.pop end