Class: Gammo::Parser::InColumnGroup

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

Overview

Section 12.2.6.4.12.

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



5
6
7
8
9
10
11
12
13
# File 'lib/gammo/parser/insertion_mode/in_column_group.rb', line 5

def character_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

#comment_token(token) ⇒ Object



15
16
17
18
# File 'lib/gammo/parser/insertion_mode/in_column_group.rb', line 15

def comment_token(token)
  parser.add_child(Node::Comment.new(data: token.data))
  halt true
end

#default(_) ⇒ Object



58
59
60
61
62
63
# File 'lib/gammo/parser/insertion_mode/in_column_group.rb', line 58

def default(_)
  halt true if parser.top.tag != Tags::Colgroup
  parser.open_elements.pop
  parser.insertion_mode = InTable
  halt false
end

#doctype_token(_) ⇒ Object



20
21
22
# File 'lib/gammo/parser/insertion_mode/in_column_group.rb', line 20

def doctype_token(_)
  halt true
end

#end_tag_token(token) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/gammo/parser/insertion_mode/in_column_group.rb', line 38

def end_tag_token(token)
  case token.tag
  when Tags::Colgroup
    if parser.top.tag == Tags::Colgroup
      parser.open_elements.pop
      parser.insertion_mode = InTable
    end
    halt true
  when Tags::Col
    # ignore the token
    halt true
  when Tags::Template
    halt InHead.new(parser).process
  end
end

#error_token(_) ⇒ Object



54
55
56
# File 'lib/gammo/parser/insertion_mode/in_column_group.rb', line 54

def error_token(_)
  halt InBody.new(parser).process
end

#start_tag_token(token) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/gammo/parser/insertion_mode/in_column_group.rb', line 24

def start_tag_token(token)
  case token.tag
  when Tags::Html
    halt InBody.new(parser).process
  when Tags::Col
    parser.add_element
    parser.open_elements.pop
    parser.acknowledge_self_closing_tag
    halt true
  when Tags::Template
    halt InHead.new(parser).process
  end
end