From eaf1669b07eb65498888f0e5fc73453d39064ba9 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 24 Mar 2014 21:33:05 +0100 Subject: [PATCH] Simplified lexer output for CDATA tags. --- lib/oga/lexer.rl | 4 ++-- spec/oga/lexer/cdata_spec.rb | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/oga/lexer.rl b/lib/oga/lexer.rl index 3f27445..aedf3e9 100644 --- a/lib/oga/lexer.rl +++ b/lib/oga/lexer.rl @@ -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; }; diff --git a/spec/oga/lexer/cdata_spec.rb b/spec/oga/lexer/cdata_spec.rb index bf41f24..f641a4f 100644 --- a/spec/oga/lexer/cdata_spec.rb +++ b/spec/oga/lexer/cdata_spec.rb @@ -4,25 +4,25 @@ describe Oga::Lexer do context 'cdata tags' do example 'lex a cdata tag' do lex('').should == [ - [:T_CDATA_START, '', 1] + [:T_CDATA_END, nil, 1] ] end example 'lex tags inside CDATA tags as regular text' do lex('Foo

]]>').should == [ - [:T_CDATA_START, 'Foo

', 1], - [:T_CDATA_END, ']]>', 1] + [:T_CDATA_END, nil, 1] ] end example 'lex double brackets inside a CDATA tag' do lex('').should == [ - [:T_CDATA_START, '', 1] + [:T_CDATA_END, nil, 1] ] end end