diff --git a/lib/oga/lexer.rl b/lib/oga/lexer.rl index bb037e6..a922a46 100644 --- a/lib/oga/lexer.rl +++ b/lib/oga/lexer.rl @@ -264,7 +264,13 @@ module Oga element_start = '<' element_name; element_text := |* - ^'<' => buffer_text; + newline => { + emit_text_buffer + t(:T_TEXT) + advance_line + }; + + ^('<' | newline) => buffer_text; '<' => { emit_text_buffer @@ -284,7 +290,8 @@ module Oga advance_column(2) # Advance the column for the closing name. - advance_column(@te - p) + advance_column(text.length) + fret; }; diff --git a/spec/oga/lexer/documents_spec.rb b/spec/oga/lexer/documents_spec.rb new file mode 100644 index 0000000..5cd305c --- /dev/null +++ b/spec/oga/lexer/documents_spec.rb @@ -0,0 +1,54 @@ +require 'spec_helper' + +describe Oga::Parser do + context 'HTML documents' do + example 'lex a basic HTML document' do + html = <<-EOF + + +
+