: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
})(function(CodeMirror) {
CodeMirror.defineMode("sass", function(config) {
function tokenRegexp(words) {
return new RegExp("^" + words.join("|"));
var keywords = ["true", "false", "null", "auto"];
var keywordsRegexp = new RegExp("^" + keywords.join("|"));
var operators = ["\\(", "\\)", "=", ">", "<", "==", ">=", "<=", "\\+", "-",
"\\!=", "/", "\\*", "%", "and", "or", "not", ";","\\{","\\}",":"];
var opRegexp = tokenRegexp(operators);
var pseudoElementsRegexp = /^::?[a-zA-Z_][\w\-]*/;
function urlTokens(stream, state) {
state.tokenizer = tokenBase;
} else if (ch === "'" || ch === '"') {
state.tokenizer = buildStringTokenizer(stream.next());
state.tokenizer = buildStringTokenizer(")", false);
function comment(indentation, multiLine) {
return function(stream, state) {
if (stream.sol() && stream.indentation() <= indentation) {
state.tokenizer = tokenBase;
return tokenBase(stream, state);
if (multiLine && stream.skipTo("*/")) {
state.tokenizer = tokenBase;
function buildStringTokenizer(quote, greedy) {
if (greedy == null) { greedy = true; }
function stringTokenizer(stream, state) {
var nextChar = stream.next();
var peekChar = stream.peek();
var previousChar = stream.string.charAt(stream.pos-2);
var endingString = ((nextChar !== "\\" && peekChar === quote) || (nextChar === quote && previousChar !== "\\"));
if (nextChar !== quote && greedy) { stream.next(); }
state.tokenizer = tokenBase;
} else if (nextChar === "#" && peekChar === "{") {
state.tokenizer = buildInterpolationTokenizer(stringTokenizer);
function buildInterpolationTokenizer(currentTokenizer) {
return function(stream, state) {
if (stream.peek() === "}") {
state.tokenizer = currentTokenizer;
return tokenBase(stream, state);
if (state.indentCount == 0) {
var lastScopeOffset = state.scopes[0].offset;
var currentOffset = lastScopeOffset + config.indentUnit;
state.scopes.unshift({ offset:currentOffset });
if (state.scopes.length == 1) return;
function tokenBase(stream, state) {
if (stream.match("/*")) {
state.tokenizer = comment(stream.indentation(), true);
return state.tokenizer(stream, state);
if (stream.match("//")) {
state.tokenizer = comment(stream.indentation(), false);
return state.tokenizer(stream, state);
if (stream.match("#{")) {
state.tokenizer = buildInterpolationTokenizer(tokenBase);
if (ch === '"' || ch === "'") {
state.tokenizer = buildStringTokenizer(ch);
if(!state.cursorHalf){// state.cursorHalf === 0
// first half i.e. before : for key-value pairs
if (stream.match(/^[\w-]+/)) {
} else if (stream.peek() === "#") {
if (stream.match(/^[\w-]+/)) {
if (stream.peek() === "#") {
stream.eatWhile(/[\w-]/);
if (stream.match(/^-?[0-9\.]+/))
if (stream.match(/^(px|em|in)\b/))
if (stream.match(keywordsRegexp))
if (stream.match(/^url/) && stream.peek() === "(") {
state.tokenizer = urlTokens;
// Match shortcut mixin definition
if (stream.match(/^=[\w-]+/)) {
// Match shortcut mixin definition
if (stream.match(/^\+[\w-]+/)){
if(stream.match(/@extend/)){
if(!stream.match(/\s*[\w]/))
if (stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)) {
stream.eatWhile(/[\w-]/);
if (stream.eatWhile(/[\w-]/)){
if(stream.match(/ *: *[\w-\+\$#!\("']/,false)){
else if(stream.match(/ *:/,false)){
else if(stream.match(/ *,/,false)){
if (stream.match(pseudoElementsRegexp)){ // could be a pseudo-element
} // cursorHalf===0 ends here
if (stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/)){
if (stream.match(/^-?[0-9\.]+/)){
if (stream.match(/^(px|em|in)\b/)){
if (stream.match(keywordsRegexp)){
if (stream.match(/^url/) && stream.peek() === "(") {
state.tokenizer = urlTokens;
stream.eatWhile(/[\w-]/);
// bang character for !important, !default, etc.
return stream.match(/^[\w]+/) ? "keyword": "operator";
if (stream.match(opRegexp)){
if (stream.eatWhile(/[\w-]/)) {
if (stream.match(opRegexp))
// If we haven't returned by now, we move 1 character
function tokenLexer(stream, state) {
if (stream.sol()) state.indentCount = 0;
var style = state.tokenizer(stream, state);
var current = stream.current();
if (current === "@return" || current === "}"){
var startOfToken = stream.pos - current.length;
var withCurrentIndent = startOfToken + (config.indentUnit * state.indentCount);
for (var i = 0; i < state.scopes.length; i++) {
var scope = state.scopes[i];
if (scope.offset <= withCurrentIndent)
state.scopes = newScopes;
scopes: [{offset: 0, type: "sass"}],
cursorHalf: 0, // cursor half tells us if cursor lies after (1)
// or before (0) colon (well... more or less)
token: function(stream, state) {
var style = tokenLexer(stream, state);
state.lastToken = { style: style, content: stream.current() };
indent: function(state) {
return state.scopes[0].offset;
CodeMirror.defineMIME("text/x-sass", "sass");