Class: HTML5::InHeadPhase
- Inherits:
-
Phase
- Object
- Phase
- HTML5::InHeadPhase
show all
- Defined in:
- lib/html5/html5parser/in_head_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, #remove_open_elements_until, #startTagHtml, start_tag_handlers, tag_handlers
Constructor Details
This class inherits a constructor from HTML5::Phase
Instance Method Details
#anything_else ⇒ Object
123
124
125
126
127
128
129
|
# File 'lib/html5/html5parser/in_head_phase.rb', line 123
def anything_else
if @tree.open_elements.last.name == 'head'
endTagHead('head')
else
@parser.phase = @parser.phases[:afterHead]
end
end
|
#endTagHead(name) ⇒ Object
97
98
99
100
101
102
103
104
|
# File 'lib/html5/html5parser/in_head_phase.rb', line 97
def endTagHead(name)
if @tree.open_elements.last.name == 'head'
@tree.open_elements.pop
else
parse_error("unexpected-end-tag", {"name" => "head"})
end
@parser.phase = @parser.phases[:afterHead]
end
|
#endTagImplyAfterHead(name) ⇒ Object
106
107
108
109
|
# File 'lib/html5/html5parser/in_head_phase.rb', line 106
def endTagImplyAfterHead(name)
anything_else
@parser.phase.processEndTag(name)
end
|
#endTagOther(name) ⇒ Object
119
120
121
|
# File 'lib/html5/html5parser/in_head_phase.rb', line 119
def endTagOther(name)
anything_else
end
|
#endTagTitleStyleScriptNoscript(name) ⇒ Object
111
112
113
114
115
116
117
|
# File 'lib/html5/html5parser/in_head_phase.rb', line 111
def endTagTitleStyleScriptNoscript(name)
if @tree.open_elements.last.name == name
@tree.open_elements.pop
else
parse_error("unexpected-end-tag", {"name" => name})
end
end
|
#process_eof ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/html5/html5parser/in_head_phase.rb', line 13
def process_eof
if ['title', 'style', 'script'].include?(name = @tree.open_elements.last.name)
parse_error("expected-named-closing-tag-but-got-eof", {"name" => @tree.open_elements.last.name})
@tree.open_elements.pop
end
anything_else
@parser.phase.process_eof
end
|
#processCharacters(data) ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/html5/html5parser/in_head_phase.rb', line 22
def processCharacters(data)
if %w[title style script noscript].include?(@tree.open_elements.last.name)
@tree.insertText(data)
else
anything_else
@parser.phase.processCharacters(data)
end
end
|
82
83
84
85
86
87
88
89
90
|
# File 'lib/html5/html5parser/in_head_phase.rb', line 82
def startTagBaseLinkMeta(name, attributes)
if @tree.head_pointer != nil and @parser.phase == @parser.phases[:inHead]
element = @tree.createElement(name, attributes)
appendToHead(element)
else
@tree.insert_element(name, attributes)
@tree.open_elements.pop
end
end
|
#startTagHead(name, attributes) ⇒ Object
31
32
33
|
# File 'lib/html5/html5parser/in_head_phase.rb', line 31
def startTagHead(name, attributes)
parse_error("two-heads-are-not-better-than-one")
end
|
#startTagNoscript(name, attributes) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/html5/html5parser/in_head_phase.rb', line 57
def startTagNoscript(name, attributes)
element = @tree.createElement(name, attributes)
if @tree.head_pointer !=nil and @parser.phase == @parser.phases[:inHead]
appendToHead(element)
else
@tree.open_elements.last.appendChild(element)
end
@tree.open_elements.push(element)
@parser.tokenizer.content_model_flag = :CDATA
end
|
#startTagOther(name, attributes) ⇒ Object
92
93
94
95
|
# File 'lib/html5/html5parser/in_head_phase.rb', line 92
def startTagOther(name, attributes)
anything_else
@parser.phase.processStartTag(name, attributes)
end
|
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/html5/html5parser/in_head_phase.rb', line 69
def startTagScript(name, attributes)
element = @tree.createElement(name, attributes)
element.flags.push("parser-inserted")
if @tree.head_pointer != nil and @parser.phase == @parser.phases[:inHead]
appendToHead(element)
else
@tree.open_elements.last.appendChild(element)
end
@tree.open_elements.push(element)
@parser.tokenizer.content_model_flag = :CDATA
end
|
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/html5/html5parser/in_head_phase.rb', line 46
def startTagStyle(name, attributes)
if @tree.head_pointer != nil and @parser.phase == @parser.phases[:inHead]
element = @tree.createElement(name, attributes)
appendToHead(element)
@tree.open_elements.push(element)
else
@tree.insert_element(name, attributes)
end
@parser.tokenizer.content_model_flag = :CDATA
end
|
#startTagTitle(name, attributes) ⇒ Object
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/html5/html5parser/in_head_phase.rb', line 35
def startTagTitle(name, attributes)
if @tree.head_pointer != nil && @parser.phase == @parser.phases[:inHead]
element = @tree.createElement(name, attributes)
appendToHead(element)
@tree.open_elements << element
else
@tree.insert_element(name, attributes)
end
@parser.tokenizer.content_model_flag = :RCDATA
end
|