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 598 def parse 599 @stack_counter = 0 600 @stack, @tree = [], @root 601 @src = Kramdown::Utils::StringScanner.new(adapt_source(source)) 602 603 while true 604 if (result = @src.scan(/\s*#{HTML_INSTRUCTION_RE}/o)) 605 @tree.children << Element.new(:xml_pi, result.strip, nil, category: :block) 606 elsif (result = @src.scan(/\s*#{HTML_DOCTYPE_RE}/o)) 607 # ignore the doctype 608 elsif (result = @src.scan(/\s*#{HTML_COMMENT_RE}/o)) 609 @tree.children << Element.new(:xml_comment, result.strip, nil, category: :block) 610 else 611 break 612 end 613 end 614 615 tag_handler = lambda do |c, closed, handle_body| 616 parse_raw_html(c, &tag_handler) if !closed && handle_body 617 end 618 parse_raw_html(@tree, &tag_handler) 619 620 ElementConverter.convert(@tree) 621 end