From 61801fe56239c79818acf66c15b71f119ae345f9 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Wed, 5 Nov 2014 00:37:30 +0100 Subject: [PATCH] Allow CSS identifiers to start with an underscore. --- lib/oga/css/lexer.rl | 2 +- spec/oga/css/lexer/paths_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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'],