diff --git a/lib/oga/xml/lexer.rb b/lib/oga/xml/lexer.rb index 3fbb00b..dabbbaf 100644 --- a/lib/oga/xml/lexer.rb +++ b/lib/oga/xml/lexer.rb @@ -66,8 +66,8 @@ module Oga 'rp' => NodeNameSet.new(%w{rb rt rtc rp}), 'optgroup' => NodeNameSet.new(%w{optgroup}), 'option' => NodeNameSet.new(%w{option optgroup}), - 'colgroup' => NodeNameSet.new(%w{thead tbody tfoot}), - 'caption' => NodeNameSet.new(%w{thead tbody tfoot}), + 'colgroup' => NodeNameSet.new(%w{thead tbody tfoot colgroup tr}), + 'caption' => NodeNameSet.new(%w{thead tbody tfoot colgroup tr caption}), 'thead' => NodeNameSet.new(%w{thead tbody tfoot}), 'tbody' => NodeNameSet.new(%w{thead tbody tfoot}), 'tfoot' => NodeNameSet.new(%w{thead tbody tfoot}), diff --git a/spec/oga/xml/lexer/html_closing_rules/caption_spec.rb b/spec/oga/xml/lexer/html_closing_rules/caption_spec.rb new file mode 100644 index 0000000..e660dac --- /dev/null +++ b/spec/oga/xml/lexer/html_closing_rules/caption_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe Oga::XML::Lexer do + describe 'HTML caption elements' do + it 'lexes an unclosed followed by another ' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'caption', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'caption', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes an unclosed followed by a ' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'caption', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'colgroup', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + end +end diff --git a/spec/oga/xml/lexer/html_closing_rules/colgroup_spec.rb b/spec/oga/xml/lexer/html_closing_rules/colgroup_spec.rb new file mode 100644 index 0000000..79837b5 --- /dev/null +++ b/spec/oga/xml/lexer/html_closing_rules/colgroup_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe Oga::XML::Lexer do + describe 'HTML colgroup elements' do + it 'lexes an unclosed followed by another ' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'colgroup', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'colgroup', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + end +end