# class Kramdown::Parser::Html

Used for parsing an HTML document.

The parsing code is in the `Parser` module that can also be used by other parsers.

### Public Instance Methods

parse() click to toggle source

Parse the source string provided on initialization as HTML document.

        # File lib/kramdown/parser/html.rb
    592 def parse
    593   @stack, @tree = [], @root
    594   @src = Kramdown::Utils::StringScanner.new(adapt_source(source))
    595
    596   while true
    597     if (result = @src.scan(/\s*#{HTML_INSTRUCTION_RE}/o))
    598       @tree.children << Element.new(:xml_pi, result.strip, nil, category: :block)
    599     elsif (result = @src.scan(/\s*#{HTML_DOCTYPE_RE}/o))
    600       # ignore the doctype
    601     elsif (result = @src.scan(/\s*#{HTML_COMMENT_RE}/o))
    602       @tree.children << Element.new(:xml_comment, result.strip, nil, category: :block)
    603     else
    604       break
    605     end
    606   end
    607
    608   tag_handler = lambda do |c, closed, handle_body|
    609     parse_raw_html(c, &tag_handler) if !closed && handle_body
    610   end
    611   parse_raw_html(@tree, &tag_handler)
    612
    613   ElementConverter.convert(@tree)
    614 end