Class: HTML5::InCaptionPhase

Inherits:
Phase
  • Object
show all
Defined in:
lib/html5/html5parser/in_caption_phase.rb

Instance Method Summary collapse

Methods inherited from Phase

#adjust_foreign_attributes, #adjust_mathml_attributes, #assert, end_tag_handlers, handle_end, handle_start, #in_scope?, #initialize, #processComment, #processDoctype, #processEndTag, #processSpaceCharacters, #processStartTag, #process_eof, #remove_open_elements_until, #startTagHtml, start_tag_handlers, tag_handlers

Constructor Details

This class inherits a constructor from HTML5::Phase

Instance Method Details

#endTagCaption(name) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/html5/html5parser/in_caption_phase.rb', line 32

def endTagCaption(name)
  if ignoreEndTagCaption
    # inner_html case
    assert @parser.inner_html
    parse_error "unexpected-end-tag", {"name" => name}
  else
    # AT this code is quite similar to endTagTable in "InTable"
    @tree.generateImpliedEndTags

    unless @tree.open_elements[-1].name == 'caption'
      parse_error("expected-one-end-tag-but-got-another",
                {"gotName" => "caption",
                 "expectedName" => @tree.open_elements.last.name})
    end

    remove_open_elements_until('caption')

    @tree.clearActiveFormattingElements
    @parser.phase = @parser.phases[:inTable]
  end
end

#endTagIgnore(name) ⇒ Object



61
62
63
# File 'lib/html5/html5parser/in_caption_phase.rb', line 61

def endTagIgnore(name)
  parse_error("unexpected-end-tag", {"name" => name})
end

#endTagOther(name) ⇒ Object



65
66
67
# File 'lib/html5/html5parser/in_caption_phase.rb', line 65

def endTagOther(name)
  @parser.phases[:inBody].processEndTag(name)
end

#endTagTable(name) ⇒ Object



54
55
56
57
58
59
# File 'lib/html5/html5parser/in_caption_phase.rb', line 54

def endTagTable(name)
  parse_error "unexpected-end-table-in-caption"
  ignoreEndTag = ignoreEndTagCaption
  @parser.phase.processEndTag('caption')
  @parser.phase.processEndTag(name) unless ignoreEndTag
end

#ignoreEndTagCaptionObject



12
13
14
# File 'lib/html5/html5parser/in_caption_phase.rb', line 12

def ignoreEndTagCaption
  !in_scope?('caption', true)
end

#processCharacters(data) ⇒ Object



16
17
18
# File 'lib/html5/html5parser/in_caption_phase.rb', line 16

def processCharacters(data)
  @parser.phases[:inBody].processCharacters(data)
end

#startTagOther(name, attributes) ⇒ Object



28
29
30
# File 'lib/html5/html5parser/in_caption_phase.rb', line 28

def startTagOther(name, attributes)
  @parser.phases[:inBody].processStartTag(name, attributes)
end

#startTagTableElement(name, attributes) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/html5/html5parser/in_caption_phase.rb', line 20

def startTagTableElement(name, attributes)
  parse_error "unexpected-end-tag", {"name" => name}
  #XXX Have to duplicate logic here to find out if the tag is ignored
  ignoreEndTag = ignoreEndTagCaption
  @parser.phase.processEndTag('caption')
  @parser.phase.processStartTag(name, attributes) unless ignoreEndTag
end