Class: Gammo::Parser::Text

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

Overview

Section 12.2.6.4.7.

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



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gammo/parser/insertion_mode/text.rb', line 9

def character_token(token)
  d = token.data
  n = parser.open_elements.last
  if n.tag == Tags::Textarea && n.first_child.nil?
    d = d.slice(1..-1) if d != "" && d.start_with?(?\r)
    d = d.slice(1..-1) if d != "" && d.start_with?(?\n)
  end
  halt true if d == ""
  parser.add_text(d)
  halt true
end

#default(token) ⇒ Object



25
26
27
28
29
# File 'lib/gammo/parser/insertion_mode/text.rb', line 25

def default(token)
  parser.insertion_mode = parser.original_insertion_mode
  parser.original_insertion_mode = nil
  halt token.instance_of?(Tokenizer::EndTagToken)
end

#end_tag_token(token) ⇒ Object



21
22
23
# File 'lib/gammo/parser/insertion_mode/text.rb', line 21

def end_tag_token(token)
  parser.open_elements.pop
end

#error_token(token) ⇒ Object



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

def error_token(token)
  parser.open_elements.pop
end