Method: Sass::Util#normalize_ident_escapes

Defined in:
lib/sass/util.rb

#normalize_ident_escapes(ident, start: true) ⇒ String

Parameters:

  • ident (String)

Returns:

  • (String)


267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/sass/util.rb', line 267

def normalize_ident_escapes(ident, start: true)
  ident.gsub(/(^)?(#{Sass::SCSS::RX::ESCAPE})/) do |s|
    at_start = start && $1
    char = escaped_char(s)
    next char if char =~ (at_start ? Sass::SCSS::RX::NMSTART : Sass::SCSS::RX::NMCHAR)
    if char =~ (at_start ? /[\x0-\x1F\x7F0-9]/ : /[\x0-\x1F\x7F]/)
      "\\#{char.ord.to_s(16)} "
    else
      "\\#{char}"
    end
  end
end