diff --git a/lib/oga/css/lexer.rl b/lib/oga/css/lexer.rl index db04853..0ae936c 100644 --- a/lib/oga/css/lexer.rl +++ b/lib/oga/css/lexer.rl @@ -155,7 +155,7 @@ module Oga # Identifiers are used for element and attribute names. Identifiers have # to start with a letter. - identifier = '*' | [a-zA-Z]+ [a-zA-Z\-_0-9]*; + identifier = '*' | [a-zA-Z_]+ [a-zA-Z\-_0-9]*; action emit_identifier { emit(:T_IDENT, ts, te) diff --git a/spec/oga/css/lexer/paths_spec.rb b/spec/oga/css/lexer/paths_spec.rb index 8bcd30d..9bc3183 100644 --- a/spec/oga/css/lexer/paths_spec.rb +++ b/spec/oga/css/lexer/paths_spec.rb @@ -6,6 +6,10 @@ describe Oga::CSS::Lexer do lex_css('h3').should == [[:T_IDENT, 'h3']] end + example 'lex a simple path starting with an underscore' do + lex_css('_h3').should == [[:T_IDENT, '_h3']] + end + example 'lex a path with two members' do lex_css('div h3').should == [ [:T_IDENT, 'div'],