class Gammo::Parser::BeforeHTML

Section 12.2.6.4.2

Public Instance Methods

comment_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/before_html.rb, line 34
def comment_token(token)
  parser.document.append_child Node::Comment.new(data: token.data)
  halt true
end
default(_) click to toggle source
# File lib/gammo/parser/insertion_mode/before_html.rb, line 39
def default(_)
  parser.parse_implied_token Tokenizer::StartTagToken, Tags::Html, Tags::Html.to_s
  halt false
end
doctype_token(_) click to toggle source

Ignores the token.

# File lib/gammo/parser/insertion_mode/before_html.rb, line 6
def doctype_token(_)
  halt true
end
end_tag_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/before_html.rb, line 23
def end_tag_token(token)
  case token.tag
  when Tags::Head, Tags::Body, Tags::Html, Tags::Br
    parser.parse_implied_token Tokenizer::StartTagToken, Tags::Html, Tags::Html.to_s
    halt false
  else
    # ignore the token.
    halt true
  end
end
start_tag_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/before_html.rb, line 16
def start_tag_token(token)
  return unless token.tag == Tags::Html
  parser.add_element
  parser.insertion_mode = BeforeHead
  halt true
end
text_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/before_html.rb, line 10
def text_token(token)
  token.data = token.data.lstrip
  # it's all whitespace so ignore it.
  halt true if token.data.length.zero?
end