Class: Gammo::Parser::InCaption

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

Overview

Section 12.2.6.4.10.

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



42
43
44
# File 'lib/gammo/parser/insertion_mode/in_caption.rb', line 42

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

#end_tag_token(token) ⇒ Object



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

def end_tag_token(token)
  case token.tag
  when Tags::Caption
    if parser.pop_until(TABLE_SCOPE, Tags::Caption)
      parser.clear_active_formatting_elements
      parser.insertion_mode = InTable
    end
    halt true
  when Tags::Table
    # ignore the token
    halt true unless parser.pop_until(TABLE_SCOPE, Tags::Caption)
    parser.clear_active_formatting_elements
    parser.insertion_mode = InTable
    halt false
  when Tags::Body, Tags::Col, Tags::Colgroup, Tags::Html, Tags::Tbody, Tags::Td, Tags::Tfoot, Tags::Th, Tags::Thead, Tags::Tr
    # 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
20
# File 'lib/gammo/parser/insertion_mode/in_caption.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::Thead, Tags::Tr
    # ignore the token
    halt true unless parser.pop_until(TABLE_SCOPE, Tags::Caption)
    parser.clear_active_formatting_elements
    parser.insertion_mode = InTable
    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