From 7ef5d5e0cf4ffe0d44780192f8438db6daf5f4ef Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Tue, 10 Nov 2009 23:01:13 -0800 Subject: [PATCH] [Sass] Allow hyphens in identifiers. --- doc-src/SASS_CHANGELOG.md | 7 +++++++ lib/sass/script/lexer.rb | 14 ++------------ test/sass/script_test.rb | 18 ++---------------- 3 files changed, 11 insertions(+), 28 deletions(-) diff --git a/doc-src/SASS_CHANGELOG.md b/doc-src/SASS_CHANGELOG.md index 31453eac..bbd71d83 100644 --- a/doc-src/SASS_CHANGELOG.md +++ b/doc-src/SASS_CHANGELOG.md @@ -13,6 +13,13 @@ Sass now supports functions that return the values of the and {Sass::Script::Functions#green green} components of colors. +### Variable Names + +SassScript variable names may now contain hyphens. +For example: + + !prettiest-color = #542FA9 + ### Error Backtraces Numerous bugs were fixed with the backtraces given for Sass errors, diff --git a/lib/sass/script/lexer.rb b/lib/sass/script/lexer.rb index e662369b..56ec2a08 100644 --- a/lib/sass/script/lexer.rb +++ b/lib/sass/script/lexer.rb @@ -52,8 +52,8 @@ module Sass # A hash of regular expressions that are used for tokenizing. REGULAR_EXPRESSIONS = { :whitespace => /\s*/, - :variable => /!(\w+)/, - :ident => /(\\.|\#\{|[^\s\\+\-*\/%(),=!])+/, + :variable => /!([\w-]+)/, + :ident => /(\\.|\#\{|[^\s\\+*\/%(),=!])+/, :string_end => /((?:\\.|\#[^{]|[^"\\#])*)(?:"|(?=#\{))/, :number => /(-)?(?:(\d*\.\d+)|(\d+))([a-zA-Z%]+)?/, :color => /\##{"([0-9a-fA-F]{1,2})" * 3}|(#{Color::HTML4_COLORS.keys.join("|")})(?!\()/, @@ -162,16 +162,6 @@ module Sass def op prev_chr = @scanner.string[@scanner.pos - 1].chr return unless op = @scanner.scan(REGULAR_EXPRESSIONS[:op]) - if @prev && op == '-' && prev_chr !~ /\s/ && - [:bool, :ident, :const].include?(@prev.type) - warn(< a, "b" => b))} -DEPRECATION WARNING: -On line 1, character 3 of 'test_hyphen_warning_inline.sass' -- will be allowed as part of variable names in version 2.4. -Please add whitespace to separate it from the previous token. -WARN - - assert_warning(< Sass::Script::String.new("a-b")))) end def test_ruby_equality