diff --git a/spec/oga/xml/lexer/html_closing_rules/option_spec.rb b/spec/oga/xml/lexer/html_closing_rules/option_spec.rb new file mode 100644 index 0000000..424dc36 --- /dev/null +++ b/spec/oga/xml/lexer/html_closing_rules/option_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe Oga::XML::Lexer do + describe 'using HTML as separate elements' do + lex_html('bar').should == [ + [:T_ELEM_NAME, 'option', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'optgroup', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + end +end diff --git a/spec/oga/xml/lexer/html_closing_rules/p_spec.rb b/spec/oga/xml/lexer/html_closing_rules/p_spec.rb new file mode 100644 index 0000000..604b7c7 --- /dev/null +++ b/spec/oga/xml/lexer/html_closing_rules/p_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe Oga::XML::Lexer do + describe 'using HTML

elements' do + it 'lexes two unclosed

elements following each other as separate elements' do + lex_html('

foo

bar').should == [ + [:T_ELEM_NAME, 'p', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'p', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes an unclosed

followed by a

as separate elements' do + lex_html('

foo

bar').should == [ + [:T_ELEM_NAME, 'p', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'address', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + end +end diff --git a/spec/oga/xml/lexer/html_closing_rules/rb_spec.rb b/spec/oga/xml/lexer/html_closing_rules/rb_spec.rb new file mode 100644 index 0000000..f8e61ce --- /dev/null +++ b/spec/oga/xml/lexer/html_closing_rules/rb_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe Oga::XML::Lexer do + describe 'using HTML elements' do + it 'lexes two unclosed elements following each other as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'rb', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'rb', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes an unclosed followed by a as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'rb', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'rt', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + end +end diff --git a/spec/oga/xml/lexer/html_closing_rules/rp_spec.rb b/spec/oga/xml/lexer/html_closing_rules/rp_spec.rb new file mode 100644 index 0000000..765fd20 --- /dev/null +++ b/spec/oga/xml/lexer/html_closing_rules/rp_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe Oga::XML::Lexer do + describe 'using HTML elements' do + it 'lexes two unclosed elements following each other as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'rp', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'rp', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes an unclosed followed by a as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'rp', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'rb', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + end +end diff --git a/spec/oga/xml/lexer/html_closing_rules/rt_spec.rb b/spec/oga/xml/lexer/html_closing_rules/rt_spec.rb new file mode 100644 index 0000000..ec3a60b --- /dev/null +++ b/spec/oga/xml/lexer/html_closing_rules/rt_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe Oga::XML::Lexer do + describe 'using HTML elements' do + it 'lexes two unclosed elements following each other as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'rt', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'rt', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes an unclosed followed by a as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'rt', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'rtc', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + end +end diff --git a/spec/oga/xml/lexer/html_closing_rules/rtc_spec.rb b/spec/oga/xml/lexer/html_closing_rules/rtc_spec.rb new file mode 100644 index 0000000..2ed7cce --- /dev/null +++ b/spec/oga/xml/lexer/html_closing_rules/rtc_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe Oga::XML::Lexer do + describe 'using HTML elements' do + it 'lexes two unclosed elements following each other as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'rtc', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'rtc', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes an unclosed followed by a as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'rtc', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'rb', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + end +end diff --git a/spec/oga/xml/lexer/html_closing_rules/tbody_spec.rb b/spec/oga/xml/lexer/html_closing_rules/tbody_spec.rb new file mode 100644 index 0000000..f024f1c --- /dev/null +++ b/spec/oga/xml/lexer/html_closing_rules/tbody_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe Oga::XML::Lexer do + describe 'using HTML elements' do + it 'lexes two unclosed elements following each other as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'tbody', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'tbody', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes an unclosed followed by a as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'tbody', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'tfoot', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes a following an unclosed as a child element' do + lex_html('foo').should == [ + [:T_ELEM_NAME, 'tbody', 1], + [:T_ELEM_NAME, 'tr', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_END, nil, 1] + ] + end + end +end diff --git a/spec/oga/xml/lexer/html_closing_rules/td_spec.rb b/spec/oga/xml/lexer/html_closing_rules/td_spec.rb new file mode 100644 index 0000000..0e4de3c --- /dev/null +++ b/spec/oga/xml/lexer/html_closing_rules/td_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe Oga::XML::Lexer do + describe 'using HTML elements' do + it 'lexes two unclosed elements following each other as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'td', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'td', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes an unclosed followed by a as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'td', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'thead', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes a

followed an unclosed as a child element' do + lex_html('

foo').should == [ + [:T_ELEM_NAME, 'td', 1], + [:T_ELEM_NAME, 'p', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_END, nil, 1] + ] + end + end +end diff --git a/spec/oga/xml/lexer/html_closing_rules/tfoot_spec.rb b/spec/oga/xml/lexer/html_closing_rules/tfoot_spec.rb new file mode 100644 index 0000000..4acb170 --- /dev/null +++ b/spec/oga/xml/lexer/html_closing_rules/tfoot_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe Oga::XML::Lexer do + describe 'using HTML elements' do + it 'lexes two unclosed elements following each other as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'tfoot', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'tfoot', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes an unclosed followed by a as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'tfoot', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'tbody', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes a following an unclosed as a child element' do + lex_html('foo').should == [ + [:T_ELEM_NAME, 'tfoot', 1], + [:T_ELEM_NAME, 'tr', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_END, nil, 1] + ] + end + end +end diff --git a/spec/oga/xml/lexer/html_closing_rules/th_spec.rb b/spec/oga/xml/lexer/html_closing_rules/th_spec.rb new file mode 100644 index 0000000..e4096a1 --- /dev/null +++ b/spec/oga/xml/lexer/html_closing_rules/th_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe Oga::XML::Lexer do + describe 'using HTML elements' do + it 'lexes two unclosed elements following each other as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'th', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'th', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes an unclosed followed by a as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'th', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'thead', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes a

followed an unclosed as a child element' do + lex_html('

foo').should == [ + [:T_ELEM_NAME, 'th', 1], + [:T_ELEM_NAME, 'p', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_END, nil, 1] + ] + end + end +end diff --git a/spec/oga/xml/lexer/html_closing_rules/thead_spec.rb b/spec/oga/xml/lexer/html_closing_rules/thead_spec.rb new file mode 100644 index 0000000..efcaf27 --- /dev/null +++ b/spec/oga/xml/lexer/html_closing_rules/thead_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe Oga::XML::Lexer do + describe 'using HTML elements' do + it 'lexes two unclosed elements following each other as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'thead', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'thead', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes an unclosed followed by a as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'thead', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'tbody', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes a following an unclosed as a child element' do + lex_html('foo').should == [ + [:T_ELEM_NAME, 'thead', 1], + [:T_ELEM_NAME, 'tr', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_END, nil, 1] + ] + end + end +end diff --git a/spec/oga/xml/lexer/html_closing_rules/tr_spec.rb b/spec/oga/xml/lexer/html_closing_rules/tr_spec.rb new file mode 100644 index 0000000..5dd1f56 --- /dev/null +++ b/spec/oga/xml/lexer/html_closing_rules/tr_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +describe Oga::XML::Lexer do + describe 'using HTML elements' do + it 'lexes two unclosed elements following each other as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'tr', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'tr', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes a followed an unclosed as a child element' do + lex_html('foo').should == [ + [:T_ELEM_NAME, 'tr', 1], + [:T_ELEM_NAME, 'td', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes a followed an unclosed as a child element' do + lex_html('foo').should == [ + [:T_ELEM_NAME, 'tr', 1], + [:T_ELEM_NAME, 'th', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_END, nil, 1] + ] + end + end +end