A module containing regular expressions used for lexing tokens in an SCSS document. Most of these are taken from [the CSS3 spec](www.w3.org/TR/css3-syntax/#lexical), although some have been modified for various reasons.
This is more liberal than the spec’s definition, but that definition didn’t work well with the greediness rules
Defined in www.w3.org/TR/css3-selectors/#lex
Custom
Can’t use IDENT here, because it seems to take exponential time on 1.8. We could use it for 1.9 only, but I don’t want to introduce a cross-version behavior difference. In any case, almost all CSS idents will be matched by this.
Escapes a single character for a CSS identifier.
@param c [String] The character to escape. Should have length 1 @return [String] The escaped character @private
# File lib/sass/scss/rx.rb, line 33 33: def self.escape_char(c) 34: return "\\%06x" % Haml::Util.ord(c) unless c =~ /[ -\/:-~]/ 35: return "\\#{c}" 36: end
Takes a string and returns a CSS identifier that will have the value of the given string.
@param str [String] The string to escape @return [String] The escaped string
# File lib/sass/scss/rx.rb, line 13 13: def self.escape_ident(str) 14: return "" if str.empty? 15: return "\\#{str}" if str == '-' || str == '_' 16: out = "" 17: value = str.dup 18: out << value.slice!(0...1) if value =~ /^[-_]/ 19: if value[0...1] =~ NMSTART 20: out << value.slice!(0...1) 21: else 22: out << escape_char(value.slice!(0...1)) 23: end 24: out << value.gsub(/[^a-zA-Z0-9_-]/) {|c| escape_char c} 25: return out 26: end
Creates a Regexp from a plain text string, escaping all significant characters.
@param str [String] The text of the regexp @param flags [Fixnum] Flags for the created regular expression @return [Regexp] @private
# File lib/sass/scss/rx.rb, line 45 45: def self.quote(str, flags = 0) 46: Regexp.new(Regexp.quote(str), flags) 47: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.