class Gammo::Parser::BeforeHead

Section 12.2.6.4.3

Public Instance Methods

comment_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/before_head.rb, line 33
def comment_token(token)
  parser.add_child(Node::Comment.new(data: token.data))
  halt true
end
default(_) click to toggle source
# File lib/gammo/parser/insertion_mode/before_head.rb, line 43
def default(_)
  parser.parse_implied_token Tokenizer::StartTagToken, Tags::Head, Tags::Head.to_s
  halt false
end
doctype_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/before_head.rb, line 38
def doctype_token(token)
  # ignore the token.
  halt true
end
end_tag_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/before_head.rb, line 22
def end_tag_token(token)
  case token.tag
  when Tags::Head, Tags::Body, Tags::Html, Tags::Br
    parser.parse_implied_token Tokenizer::StartTagToken, Tags::Head, Tags::Head.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_head.rb, line 10
def start_tag_token(token)
  case token.tag
  when Tags::Head
    parser.add_element
    parser.head = parser.top
    parser.insertion_mode = InHead
    halt true
  when Tags::Html
    halt InBody.new(parser).process
  end
end
text_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/before_head.rb, line 5
def text_token(token)
  token.data = token.data.lstrip
  halt true if token.data.length.zero?
end