Simplified the lexer output for doctypes.
This commit is contained in:
parent
ac775918ee
commit
470be5a839
|
@ -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;
|
||||||
};
|
};
|
||||||
*|;
|
*|;
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue