Class: Gammo::Parser::InHeadNoscript

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

Overview

12.2.6.4.5.

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

#character_token(token) ⇒ Object



39
40
41
# File 'lib/gammo/parser/insertion_mode/in_head_noscript.rb', line 39

def character_token(token)
  halt InHead.new(parser).process if token.data.lstrip == ''
end

#comment_token(_) ⇒ Object



10
11
12
# File 'lib/gammo/parser/insertion_mode/in_head_noscript.rb', line 10

def comment_token(_)
  halt InHead.new(parser).process
end

#default(token) ⇒ Object

Raises:



43
44
45
46
47
48
49
# File 'lib/gammo/parser/insertion_mode/in_head_noscript.rb', line 43

def default(token)
  parser.open_elements.pop
  raise ParseError, 'the new current node will be a head element.'\
    if parser.top.tag != Tags::Head
  parser.insertion_mode = InHead
  halt false
end

#doctype_token(_) ⇒ Object



5
6
7
8
# File 'lib/gammo/parser/insertion_mode/in_head_noscript.rb', line 5

def doctype_token(_)
  # ignore the token.
  halt true
end

#end_tag_token(token) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/gammo/parser/insertion_mode/in_head_noscript.rb', line 25

def end_tag_token(token)
  case token.tag
  when Tags::Noscript
    parser.open_elements.pop
    parser.insertion_mode = InHead
    halt true
  when Tags::Br
    # no-op
  else
    # ignore the token.
    halt true
  end
end

#start_tag_token(token) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/gammo/parser/insertion_mode/in_head_noscript.rb', line 14

def start_tag_token(token)
  case token.tag
  when Tags::Html then halt InBody.new(parser).process
  when Tags::Basefont, Tags::Bgsound, Tags::Link, Tags::Meta, Tags::Noframes, Tags::Style
    halt InHead.new(parser).process
  when Tags::Head, Tags::Noscript
    # ignore the token.
    halt true
  end
end