class Gammo::Parser::AfterHead

Section 12.2.6.4.5.

Public Instance Methods

comment_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/after_head.rb, line 53
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/after_head.rb, line 63
def default(_)
  parser.parse_implied_token(Tokenizer::StartTagToken, Tags::Body, Tags::Body.to_s)
  parser.frameset_ok = true
  halt false
end
doctype_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/after_head.rb, line 58
def doctype_token(token)
  # ignore the token.
  halt true
end
end_tag_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/after_head.rb, line 41
def end_tag_token(token)
  case token.tag
  when Tags::Body, Tags::Html, Tags::Br
    # drop down to creating an implied <body> tag.
  when Tags::Template
    halt InHead.new(parser).process
  else
    # ignore the token.
    halt true
  end
end
start_tag_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/after_head.rb, line 15
def start_tag_token(token)
  case token.tag
  when Tags::Html then halt InBody.new(parser).process
  when Tags::Body
    parser.add_element
    parser.frameset_ok = false
    parser.insertion_mode = InBody
    halt true
  when Tags::Frameset
    parser.add_element
    parser.insertion_mode = InFrameset
    halt true
  when Tags::Base, Tags::Basefont, Tags::Bgsound, Tags::Link, Tags::Meta,
    Tags::Noframes, Tags::Script, Tags::Style, Tags::Template, Tags::Title
    parser.open_elements << parser.head
    begin
      halt InHead.new(parser).process
    ensure
      parser.open_elements.delete(parser.head)
    end
  when Tags::Head
    # ignore the token
    halt true
  end
end
text_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/after_head.rb, line 5
def text_token(token)
  s = token.data.lstrip
  if s.length < token.data.length
    # add the initial whitespace to the current node.
    parser.add_text token.data.slice(0, token.data.length - s.length)
    halt true if s == ''
    token.data = s
  end
end