Simplified lexer output for CDATA tags.

This commit is contained in:
Yorick Peterse 2014-03-24 21:33:05 +01:00
parent 470be5a839
commit eaf1669b07
2 changed files with 8 additions and 8 deletions

View File

@ -320,7 +320,7 @@ module Oga
action start_cdata {
emit_buffer
t(:T_CDATA_START)
add_token(:T_CDATA_START, nil)
start_buffer
@ -332,7 +332,7 @@ module Oga
cdata := |*
cdata_end => {
emit_buffer
t(:T_CDATA_END)
add_token(:T_CDATA_END, nil)
fret;
};

View File

@ -4,25 +4,25 @@ describe Oga::Lexer do
context 'cdata tags' do
example 'lex a cdata tag' do
lex('<![CDATA[foo]]>').should == [
[:T_CDATA_START, '<![CDATA[', 1],
[:T_CDATA_START, nil, 1],
[:T_TEXT, 'foo', 1],
[:T_CDATA_END, ']]>', 1]
[:T_CDATA_END, nil, 1]
]
end
example 'lex tags inside CDATA tags as regular text' do
lex('<![CDATA[<p>Foo</p>]]>').should == [
[:T_CDATA_START, '<![CDATA[', 1],
[:T_CDATA_START, nil, 1],
[:T_TEXT, '<p>Foo</p>', 1],
[:T_CDATA_END, ']]>', 1]
[:T_CDATA_END, nil, 1]
]
end
example 'lex double brackets inside a CDATA tag' do
lex('<![CDATA[]]]]>').should == [
[:T_CDATA_START, '<![CDATA[', 1],
[:T_CDATA_START, nil, 1],
[:T_TEXT, ']]', 1],
[:T_CDATA_END, ']]>', 1]
[:T_CDATA_END, nil, 1]
]
end
end