Class: Gammo::Parser::BeforeHTML
- Inherits:
-
InsertionMode
- Object
- InsertionMode
- Gammo::Parser::BeforeHTML
- Defined in:
- lib/gammo/parser/insertion_mode/before_html.rb
Overview
Section 12.2.6.4.2
Instance Attribute Summary
Attributes inherited from InsertionMode
Instance Method Summary collapse
- #character_token(token) ⇒ Object
- #comment_token(token) ⇒ Object
- #default(_) ⇒ Object
-
#doctype_token(_) ⇒ Object
Ignores the token.
- #end_tag_token(token) ⇒ Object
- #start_tag_token(token) ⇒ Object
Methods inherited from InsertionMode
Constructor Details
This class inherits a constructor from Gammo::Parser::InsertionMode
Instance Method Details
#character_token(token) ⇒ Object
10 11 12 13 14 |
# File 'lib/gammo/parser/insertion_mode/before_html.rb', line 10 def character_token(token) token.data = token.data.lstrip # it's all whitespace so ignore it. halt true if token.data.length.zero? end |
#comment_token(token) ⇒ Object
34 35 36 37 |
# File 'lib/gammo/parser/insertion_mode/before_html.rb', line 34 def comment_token(token) parser.document.append_child Node::Comment.new(data: token.data) halt true end |
#default(_) ⇒ Object
39 40 41 42 |
# File 'lib/gammo/parser/insertion_mode/before_html.rb', line 39 def default(_) parser.parse_implied_token Tokenizer::StartTagToken, Tags::Html, Tags::Html.to_s halt false end |
#doctype_token(_) ⇒ Object
Ignores the token.
6 7 8 |
# File 'lib/gammo/parser/insertion_mode/before_html.rb', line 6 def doctype_token(_) halt true end |
#end_tag_token(token) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gammo/parser/insertion_mode/before_html.rb', line 23 def end_tag_token(token) case token.tag when Tags::Head, Tags::Body, Tags::Html, Tags::Br parser.parse_implied_token Tokenizer::StartTagToken, Tags::Html, Tags::Html.to_s halt false else # ignore the token. halt true end end |
#start_tag_token(token) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/gammo/parser/insertion_mode/before_html.rb', line 16 def start_tag_token(token) return unless token.tag == Tags::Html parser.add_element parser.insertion_mode = BeforeHead halt true end |