Simplified the lexer output for doctypes.

This commit is contained in:
Yorick Peterse 2014-03-24 21:32:16 +01:00
parent ac775918ee
commit 470be5a839
3 changed files with 10 additions and 10 deletions

View File

@ -282,7 +282,7 @@ module Oga
action start_doctype { action start_doctype {
emit_buffer emit_buffer
t(:T_DOCTYPE_START) add_token(:T_DOCTYPE_START, nil)
fcall doctype; fcall doctype;
} }
@ -300,7 +300,7 @@ module Oga
whitespace; whitespace;
'>' => { '>' => {
t(:T_DOCTYPE_END) add_token(:T_DOCTYPE_END, nil)
fret; fret;
}; };
*|; *|;

View File

@ -4,28 +4,28 @@ describe Oga::Lexer do
context 'doctypes' do context 'doctypes' do
example 'lex the HTML5 doctype' do example 'lex the HTML5 doctype' do
lex('<!DOCTYPE html>').should == [ lex('<!DOCTYPE html>').should == [
[:T_DOCTYPE_START, '<!DOCTYPE html', 1], [:T_DOCTYPE_START, nil, 1],
[:T_DOCTYPE_END, '>', 1] [:T_DOCTYPE_END, nil, 1]
] ]
end end
example 'lex a doctype with a public and system ID' do example 'lex a doctype with a public and system ID' do
lex('<!DOCTYPE HTML PUBLIC "foobar" "baz">').should == [ lex('<!DOCTYPE HTML PUBLIC "foobar" "baz">').should == [
[:T_DOCTYPE_START, '<!DOCTYPE HTML', 1], [:T_DOCTYPE_START, nil, 1],
[:T_DOCTYPE_TYPE, 'PUBLIC', 1], [:T_DOCTYPE_TYPE, 'PUBLIC', 1],
[:T_STRING, 'foobar', 1], [:T_STRING, 'foobar', 1],
[:T_STRING, 'baz', 1], [:T_STRING, 'baz', 1],
[:T_DOCTYPE_END, '>', 1] [:T_DOCTYPE_END, nil, 1]
] ]
end end
example 'lex a doctype with a public and system ID using single quotes' do example 'lex a doctype with a public and system ID using single quotes' do
lex("<!DOCTYPE HTML PUBLIC 'foobar' 'baz'>").should == [ lex("<!DOCTYPE HTML PUBLIC 'foobar' 'baz'>").should == [
[:T_DOCTYPE_START, '<!DOCTYPE HTML', 1], [:T_DOCTYPE_START, nil, 1],
[:T_DOCTYPE_TYPE, 'PUBLIC', 1], [:T_DOCTYPE_TYPE, 'PUBLIC', 1],
[:T_STRING, 'foobar', 1], [:T_STRING, 'foobar', 1],
[:T_STRING, 'baz', 1], [:T_STRING, 'baz', 1],
[:T_DOCTYPE_END, '>', 1] [:T_DOCTYPE_END, nil, 1]
] ]
end end
end end

View File

@ -14,8 +14,8 @@ describe Oga::Lexer do
EOF EOF
lex(html).should == [ lex(html).should == [
[:T_DOCTYPE_START, '<!DOCTYPE html', 1], [:T_DOCTYPE_START, nil, 1],
[:T_DOCTYPE_END, '>', 1], [:T_DOCTYPE_END, nil, 1],
[:T_TEXT, "\n", 1], [:T_TEXT, "\n", 1],
# <html> # <html>