Class: Kramdown::Parser::Html

### Home Classes Methods

### In Files

- lib/kramdown/parser/html.rb

### Parent

Kramdown::Parser::Base

### Namespace

- MODULE Kramdown::Parser::Html::Constants
- MODULE Kramdown::Parser::Html::Parser
- CLASS Kramdown::Parser::Html::ElementConverter

### Methods

- #parse

### Included Modules

- Kramdown::Parser::Html::Parser

### Class/Module Index

Quicksearch

- Kramdown
- Kramdown::Converter
- Kramdown::Converter::Base
- Kramdown::Converter::Html
- Kramdown::Converter::Kramdown
- Kramdown::Converter::Latex
- Kramdown::Converter::RemoveHtmlTags
- Kramdown::Converter::Toc
- Kramdown::Document
- Kramdown::Element
- Kramdown::Error
- Kramdown::Options
- Kramdown::Options::Boolean
- Kramdown::Parser
- Kramdown::Parser::Base
- Kramdown::Parser::Html
- Kramdown::Parser::Html::Constants
- Kramdown::Parser::Html::ElementConverter
- Kramdown::Parser::Html::Parser
- Kramdown::Parser::Kramdown
- Kramdown::Parser::Markdown
- Kramdown::Utils
- Kramdown::Utils::Entities
- Kramdown::Utils::Entities::Entity
- Kramdown::Utils::Html
- Kramdown::Utils::OrderedHash

No matching classes.

# 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, line 546
    def parse
      @stack, @tree = [], @root
      @src = StringScanner.new(adapt_source(source))

      while true
        if result = @src.scan(/\s*#{HTML_INSTRUCTION_RE}/)
          @tree.children << Element.new(:xml_pi, result.strip, nil, :category => :block)
        elsif result = @src.scan(/\s*#{HTML_DOCTYPE_RE}/)
          # ignore the doctype
        elsif result = @src.scan(/\s*#{HTML_COMMENT_RE}/)
          @tree.children << Element.new(:xml_comment, result.strip, nil, :category => :block)
        else
          break
        end
      end

      tag_handler = lambda do |c, closed, handle_body|
        parse_raw_html(c, &tag_handler) if !closed && handle_body
      end
      parse_raw_html(@tree, &tag_handler)

      ElementConverter.convert(@tree)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.