Class: Gammo::Parser::InTemplate
- Inherits:
-
InsertionMode
- Object
- InsertionMode
- Gammo::Parser::InTemplate
- Defined in:
- lib/gammo/parser/insertion_mode/in_template.rb
Overview
Section 12.2.6.4.18.
Instance Attribute Summary
Attributes inherited from InsertionMode
Instance Method Summary collapse
- #comment_token(token) ⇒ Object
- #default(_) ⇒ Object
- #doctype_token(token) ⇒ Object
- #end_tag_token(token) ⇒ Object
- #error_token(token) ⇒ Object
- #start_tag_token(token) ⇒ Object
- #text_token(token) ⇒ Object
Methods inherited from InsertionMode
Constructor Details
This class inherits a constructor from Gammo::Parser::InsertionMode
Instance Method Details
#comment_token(token) ⇒ Object
9 10 11 |
# File 'lib/gammo/parser/insertion_mode/in_template.rb', line 9 def comment_token(token) halt InBody.new(parser).process end |
#default(_) ⇒ Object
75 76 77 |
# File 'lib/gammo/parser/insertion_mode/in_template.rb', line 75 def default(_) halt false end |
#doctype_token(token) ⇒ Object
13 14 15 |
# File 'lib/gammo/parser/insertion_mode/in_template.rb', line 13 def doctype_token(token) halt InBody.new(parser).process end |
#end_tag_token(token) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/gammo/parser/insertion_mode/in_template.rb', line 49 def end_tag_token(token) case token.tag when Tags::Template halt InHead.new(parser).process else # ignore the token halt true end end |
#error_token(token) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/gammo/parser/insertion_mode/in_template.rb', line 59 def error_token(token) halt true unless parser.open_elements.any? {|elm| elm.tag == Tags::Template } # remove this divergence from the html5 spec parser. parser.open_elements.reverse_each_with_index do |elm, index| if !elm.namespace && elm.tag == Tags::Template parser.open_elements = parser.open_elements.slice(0, index) break end end parser.clear_active_formatting_elements parser.template_stack.pop parser.reset_insertion_mode halt false end |
#start_tag_token(token) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gammo/parser/insertion_mode/in_template.rb', line 17 def start_tag_token(token) case token.tag when Tags::Base, Tags::Basefont, Tags::Bgsound, Tags::Link, Tags::Meta, Tags::Noframes, Tags::Script, Tags::Style, Tags::Template, Tags::Title halt InHead.new(parser).process when Tags::Caption, Tags::Colgroup, Tags::Tbody, Tags::Tfoot, Tags::Thead parser.template_stack.pop parser.template_stack << InTable parser.insertion_mode = InTable halt false when Tags::Col parser.template_stack.pop parser.template_stack << InColumnGroup parser.insertion_mode = InColumnGroup halt false when Tags::Tr parser.template_stack.pop parser.template_stack << InTableBody parser.insertion_mode = InTableBody halt false when Tags::Td, Tags::Th parser.template_stack.pop parser.template_stack << InRow parser.insertion_mode = InRow halt false else parser.template_stack.pop parser.template_stack << InBody parser.insertion_mode = InBody halt false end end |