Class: Gammo::Parser::InCell

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

Overview

Section 12.2.6.4.15.

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

#default(_) ⇒ Object



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

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

#end_tag_token(token) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gammo/parser/insertion_mode/in_cell.rb', line 21

def end_tag_token(token)
  case token.tag
  when Tags::Td, Tags::Th
    # ignore the token
    halt true unless parser.pop_until(TABLE_SCOPE, token.tag)
    parser.clear_active_formatting_elements
    parser.insertion_mode = InRow
    halt true
  when Tags::Body, Tags::Caption, Tags::Col, Tags::Colgroup, Tags::Html
    # ignore the token
    halt true
  when Tags::Table, Tags::Tbody, Tags::Tfoot, Tags::Thead, Tags::Tr
    # ignore the token
    halt true unless parser.element_in_scope?(TABLE_SCOPE, token.tag)
    parser.clear_active_formatting_elements if parser.pop_until(TABLE_SCOPE, Tags::Td, Tags::Th)
    parser.insertion_mode = InRow
    halt false
  end
end

#start_tag_token(token) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gammo/parser/insertion_mode/in_cell.rb', line 5

def start_tag_token(token)
  case token.tag
  when Tags::Caption, Tags::Col, Tags::Colgroup, Tags::Tbody, Tags::Td, Tags::Tfoot, Tags::Th, Tags::Thead, Tags::Tr
    halt true unless parser.pop_until(TABLE_SCOPE, Tags::Td, Tags::Th)
    parser.clear_active_formatting_elements
    parser.insertion_mode = InRow
    halt false
  when Tags::Select
    parser.reconstruct_active_formatting_elements
    parser.add_element
    parser.frameset_ok = false
    parser.insertion_mode = InSelectInTable
    halt true
  end
end