# class Kramdown::Parser::Html

Used for parsing a 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
    570 def parse
    571   @stack, @tree = [], @root
    572   @src = Kramdown::Utils::StringScanner.new(adapt_source(source))
    573
    574   while true
    575     if result = @src.scan(/\s*#{HTML_INSTRUCTION_RE}/)
    576       @tree.children << Element.new(:xml_pi, result.strip, nil, :category => :block)
    577     elsif result = @src.scan(/\s*#{HTML_DOCTYPE_RE}/)
    578       # ignore the doctype
    579     elsif result = @src.scan(/\s*#{HTML_COMMENT_RE}/)
    580       @tree.children << Element.new(:xml_comment, result.strip, nil, :category => :block)
    581     else
    582       break
    583     end
    584   end
    585
    586   tag_handler = lambda do |c, closed, handle_body|
    587     parse_raw_html(c, &tag_handler) if !closed && handle_body
    588   end
    589   parse_raw_html(@tree, &tag_handler)
    590
    591   ElementConverter.convert(@tree)
    592 end