Added more HTML closing rules for colgroup/caption

This commit is contained in:
Yorick Peterse 2015-05-12 23:14:48 +02:00
parent 7d9604fd93
commit 1c095ddaff
3 changed files with 45 additions and 2 deletions

View File

@ -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}),

View File

@ -0,0 +1,27 @@
require 'spec_helper'
describe Oga::XML::Lexer do
describe 'HTML caption elements' do
it 'lexes an unclosed <caption> followed by another <caption>' do
lex_html('<caption>foo<caption>bar').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 <caption> followed by a <colgroup>' do
lex_html('<caption>foo<colgroup>bar').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

View File

@ -0,0 +1,16 @@
require 'spec_helper'
describe Oga::XML::Lexer do
describe 'HTML colgroup elements' do
it 'lexes an unclosed <colgroup> followed by another <colgroup>' do
lex_html('<colgroup>foo<colgroup>bar').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