Class Index [+]

Quicksearch

Sass::SCSS::RX

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.

Constants

H
NL
UNICODE
NONASCII
ESCAPE
NMSTART
NMCHAR
STRING1
STRING2
IDENT
NAME
NUM
STRING
URLCHAR
URL
W
RANGE

This is more liberal than the spec’s definition, but that definition didn’t work well with the greediness rules

S
COMMENT
SINGLE_LINE_COMMENT
CDO
CDC
INCLUDES
DASHMATCH
PREFIXMATCH
SUFFIXMATCH
SUBSTRINGMATCH
HASH
IMPORTANT
DEFAULT
NUMBER
URI
FUNCTION
UNICODERANGE
PLUS

Defined in www.w3.org/TR/css3-selectors/#lex

GREATER
TILDE
NOT
HEXCOLOR

Custom

INTERP_START
MOZ_ANY
STRING1_NOINTERP
STRING2_NOINTERP
STRING_NOINTERP
STATIC_VALUE

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

Public Class Methods

escape_char(c) click to toggle source

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
escape_ident(str) click to toggle source

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
quote(str, flags = 0) click to toggle source

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.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.