Class: Gammo::Parser::InRow

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

Overview

Section 12.2.6.4.14.

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



48
49
50
# File 'lib/gammo/parser/insertion_mode/in_row.rb', line 48

def default(_)
  halt InTable.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
40
41
42
43
44
45
46
# File 'lib/gammo/parser/insertion_mode/in_row.rb', line 21

def end_tag_token(token)
  case token.tag
  when  Tags::Tr
    # ignore the token
    halt true unless parser.pop_until(TABLE_SCOPE, Tags::Tr)
    parser.insertion_mode = InTableBody
    halt true
  when Tags::Table
    if parser.pop_until(TABLE_SCOPE, Tags::Tr)
      parser.insertion_mode = InTableBody
      halt false
    end
    # ignore the token
    halt true
  when Tags::Tbody, Tags::Tfoot, Tags::Thead
    if parser.element_in_scope?(TABLE_SCOPE, token.tag)
      parser.parse_implied_token(Tokenizer::EndTagToken, Tags::Tr, Tags::Tr.to_s)
      halt false
    end
    # ignore the token
    halt true
  when Tags::Body, Tags::Caption, Tags::Col, Tags::Colgroup, Tags::Html, Tags::Td, Tags::Th
    # ignore the token
    halt true
  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_row.rb', line 5

def start_tag_token(token)
  case token.tag
  when Tags::Td, Tags::Th
    parser.clear_stack_to_context(TABLE_ROW_SCOPE)
    parser.add_element
    parser.active_formatting_elements << Node::DEFAULT_SCOPE_MARKER
    parser.insertion_mode = InCell
    halt true
  when Tags::Caption, Tags::Col, Tags::Colgroup, Tags::Tbody, Tags::Tfoot, Tags::Thead, Tags::Tr
    # ignore the token
    halt true unless parser.pop_until(TABLE_SCOPE, Tags::Tr)
    parser.insertion_mode = InTableBody
    halt false
  end
end