Class: Gammo::Parser::AfterBody

Inherits:
InsertionMode show all
Defined in:
lib/gammo/parser/insertion_mode/after_body.rb

Overview

Section 12.2.6.4.19.

Instance Attribute Summary

Attributes inherited from InsertionMode

#parser

Instance Method Summary collapse

Methods inherited from InsertionMode

#initialize, #process

Constructor Details

This class inherits a constructor from Gammo::Parser::InsertionMode

Instance Method Details

#character_token(token) ⇒ Object



11
12
13
14
# File 'lib/gammo/parser/insertion_mode/after_body.rb', line 11

def character_token(token)
  s = token.data.lstrip
  halt InBody.new(parser).process if s.length.zero?
end

#comment_token(token) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/gammo/parser/insertion_mode/after_body.rb', line 31

def comment_token(token)
  open_elements = parser.open_elements
  if open_elements.length < 1 || open_elements.first.tag != Tags::Html
    raise ParseError, 'bad parser state: <html> element not found, in the after-body insertion mode'
  end
  open_elements.first.append_child Node::Comment.new(data: token.data)
  halt true
end

#default(_) ⇒ Object



40
41
42
43
# File 'lib/gammo/parser/insertion_mode/after_body.rb', line 40

def default(_)
  parser.insertion_mode = InBody
  halt false
end

#end_tag_token(token) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/gammo/parser/insertion_mode/after_body.rb', line 23

def end_tag_token(token)
  case token.tag
  when Tags::Html
    parser.insertion_mode = AfterAfterBody unless parser.fragment?
    halt true
  end
end

#error_token(_) ⇒ Object



6
7
8
9
# File 'lib/gammo/parser/insertion_mode/after_body.rb', line 6

def error_token(_)
  # ignore the token
  true
end

#start_tag_token(token) ⇒ Object



16
17
18
19
20
21
# File 'lib/gammo/parser/insertion_mode/after_body.rb', line 16

def start_tag_token(token)
  case token.tag
  when Tags::Html
    halt InBody.new(parser).process
  end
end