Permalink
Browse files

[Sass] Properly parse identifiers beginning with identifier operators.

Closes gh-199
Closes gh-200
  • Loading branch information...
1 parent fdc2887 commit 6478ab823ec2b8bf2d6f5c99892c20fe98d41d19 @nex3 nex3 committed Jun 23, 2010
Showing with 13 additions and 1 deletion.
  1. +1 −1 lib/sass/script/lexer.rb
  2. +12 −0 test/sass/script_test.rb
@@ -92,7 +92,7 @@ class Lexer
:number => /(-)?(?:(\d*\.\d+)|(\d+))([a-zA-Z%]+)?/,
:color => HEXCOLOR,
:bool => /(true|false)\b/,
- :ident_op => %r{(#{Regexp.union(*IDENT_OP_NAMES.map{|s| Regexp.new(Regexp.escape(s) + '(?:\b|$)')})})},
+ :ident_op => %r{(#{Regexp.union(*IDENT_OP_NAMES.map{|s| Regexp.new(Regexp.escape(s) + "(?!#{NMCHAR}|$)")})})},
:op => %r{(#{Regexp.union(*OP_NAMES)})},
}
@@ -390,6 +390,18 @@ def test_misplaced_comma_in_funcall
'Invalid CSS after "foo(bar, ": expected function argument, was ")"') {eval('foo(bar, )')}
end
+ def test_color_prefixed_identifier
+ assert_equal "tealbang", resolve("tealbang")
+ assert_equal "teal-bang", resolve("teal-bang")
+ end
+
+ def test_op_prefixed_identifier
+ assert_equal "notbang", resolve("notbang")
+ assert_equal "not-bang", resolve("not-bang")
+ assert_equal "or-bang", resolve("or-bang")
+ assert_equal "and-bang", resolve("and-bang")
+ end
+
private
def resolve(str, opts = {}, environment = env)

0 comments on commit 6478ab8

Please sign in to comment.