Module Sass::SCSS::RX
In: lib/sass/scss/rx.rb

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.

Methods

Constants

H = /[0-9a-fA-F]/
NL = /\n|\r\n|\r|\f/
UNICODE = /\\#{H}{1,6}[ \t\r\n\f]?/
NONASCII = /[#{s}]/
ESCAPE = /#{UNICODE}|\\[ -~#{s}]/
NMSTART = /[_a-zA-Z]|#{NONASCII}|#{ESCAPE}/
NMCHAR = /[a-zA-Z0-9_-]|#{NONASCII}|#{ESCAPE}/
STRING1 = /\"((?:[^\n\r\f\\"]|\\#{NL}|#{ESCAPE})*)\"/
STRING2 = /\'((?:[^\n\r\f\\']|\\#{NL}|#{ESCAPE})*)\'/
IDENT = /-?#{NMSTART}#{NMCHAR}*/
NAME = /#{NMCHAR}+/
NUM = /[0-9]+|[0-9]*\.[0-9]+/
STRING = /#{STRING1}|#{STRING2}/
URLCHAR = /[#%&*-~]|#{NONASCII}|#{ESCAPE}/
URL = /(#{URLCHAR}*)/
W = /[ \t\r\n\f]*/
RANGE = /(?:#{H}|\?){1,6}/   This is more liberal than the spec‘s definition, but that definition didn‘t work well with the greediness rules
S = /[ \t\r\n\f]+/  
COMMENT = /\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\//
SINGLE_LINE_COMMENT = /\/\/.*(\n[ \t]*\/\/.*)*/
CDO = quote("<!--")
CDC = quote("-->")
INCLUDES = quote("~=")
DASHMATCH = quote("|=")
PREFIXMATCH = quote("^=")
SUFFIXMATCH = quote("$=")
SUBSTRINGMATCH = quote("*=")
HASH = /##{NAME}/
IMPORTANT = /!#{W}important/i
DEFAULT = /!#{W}default/i
NUMBER = /#{NUM}(?:#{IDENT}|%)?/
URI = /url\(#{W}(?:#{STRING}|#{URL})#{W}\)/i
FUNCTION = /#{IDENT}\(/
UNICODERANGE = /u\+(?:#{H}{1,6}-#{H}{1,6}|#{RANGE})/i
PLUS = /#{W}\+/   Defined in www.w3.org/TR/css3-selectors/#lex
GREATER = /#{W}>/
TILDE = /#{W}~/
NOT = quote(":not(", Regexp::IGNORECASE)
HEXCOLOR = /\#[0-9a-fA-F]+/   Custom
INTERP_START = /#\{/
MOZ_ANY = quote(":-moz-any(", Regexp::IGNORECASE)
STRING1_NOINTERP = /\"((?:[^\n\r\f\\"#]|#(?!\{)|\\#{NL}|#{ESCAPE})*)\"/
STRING2_NOINTERP = /\'((?:[^\n\r\f\\'#]|#(?!\{)|\\#{NL}|#{ESCAPE})*)\'/
STRING_NOINTERP = /#{STRING1_NOINTERP}|#{STRING2_NOINTERP}/
STATIC_VALUE = /(-?#{NMSTART}|#{STRING_NOINTERP}|\s(?!%)|#[a-f0-9]|[,%]|#{NUM}|\!important)+(?=[;}])/i   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.
STATIC_SELECTOR = /(#{NMCHAR}|\s|[,>+*]|[:#.]#{NMSTART})+(?=[{])/i

Public Class methods

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

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

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

[Validate]