Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/ruby
File: ruby.js
// CodeMirror, copyright (c) by Marijn Haverbeke and others
[0] Fix | Delete
// Distributed under an MIT license: http://codemirror.net/LICENSE
[1] Fix | Delete
[2] Fix | Delete
(function(mod) {
[3] Fix | Delete
if (typeof exports == "object" && typeof module == "object") // CommonJS
[4] Fix | Delete
mod(require("../../lib/codemirror"));
[5] Fix | Delete
else if (typeof define == "function" && define.amd) // AMD
[6] Fix | Delete
define(["../../lib/codemirror"], mod);
[7] Fix | Delete
else // Plain browser env
[8] Fix | Delete
mod(CodeMirror);
[9] Fix | Delete
})(function(CodeMirror) {
[10] Fix | Delete
"use strict";
[11] Fix | Delete
[12] Fix | Delete
CodeMirror.defineMode("ruby", function(config) {
[13] Fix | Delete
function wordObj(words) {
[14] Fix | Delete
var o = {};
[15] Fix | Delete
for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true;
[16] Fix | Delete
return o;
[17] Fix | Delete
}
[18] Fix | Delete
var keywords = wordObj([
[19] Fix | Delete
"alias", "and", "BEGIN", "begin", "break", "case", "class", "def", "defined?", "do", "else",
[20] Fix | Delete
"elsif", "END", "end", "ensure", "false", "for", "if", "in", "module", "next", "not", "or",
[21] Fix | Delete
"redo", "rescue", "retry", "return", "self", "super", "then", "true", "undef", "unless",
[22] Fix | Delete
"until", "when", "while", "yield", "nil", "raise", "throw", "catch", "fail", "loop", "callcc",
[23] Fix | Delete
"caller", "lambda", "proc", "public", "protected", "private", "require", "load",
[24] Fix | Delete
"require_relative", "extend", "autoload", "__END__", "__FILE__", "__LINE__", "__dir__"
[25] Fix | Delete
]);
[26] Fix | Delete
var indentWords = wordObj(["def", "class", "case", "for", "while", "until", "module", "then",
[27] Fix | Delete
"catch", "loop", "proc", "begin"]);
[28] Fix | Delete
var dedentWords = wordObj(["end", "until"]);
[29] Fix | Delete
var matching = {"[": "]", "{": "}", "(": ")"};
[30] Fix | Delete
var curPunc;
[31] Fix | Delete
[32] Fix | Delete
function chain(newtok, stream, state) {
[33] Fix | Delete
state.tokenize.push(newtok);
[34] Fix | Delete
return newtok(stream, state);
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
function tokenBase(stream, state) {
[38] Fix | Delete
if (stream.sol() && stream.match("=begin") && stream.eol()) {
[39] Fix | Delete
state.tokenize.push(readBlockComment);
[40] Fix | Delete
return "comment";
[41] Fix | Delete
}
[42] Fix | Delete
if (stream.eatSpace()) return null;
[43] Fix | Delete
var ch = stream.next(), m;
[44] Fix | Delete
if (ch == "`" || ch == "'" || ch == '"') {
[45] Fix | Delete
return chain(readQuoted(ch, "string", ch == '"' || ch == "`"), stream, state);
[46] Fix | Delete
} else if (ch == "/") {
[47] Fix | Delete
var currentIndex = stream.current().length;
[48] Fix | Delete
if (stream.skipTo("/")) {
[49] Fix | Delete
var search_till = stream.current().length;
[50] Fix | Delete
stream.backUp(stream.current().length - currentIndex);
[51] Fix | Delete
var balance = 0; // balance brackets
[52] Fix | Delete
while (stream.current().length < search_till) {
[53] Fix | Delete
var chchr = stream.next();
[54] Fix | Delete
if (chchr == "(") balance += 1;
[55] Fix | Delete
else if (chchr == ")") balance -= 1;
[56] Fix | Delete
if (balance < 0) break;
[57] Fix | Delete
}
[58] Fix | Delete
stream.backUp(stream.current().length - currentIndex);
[59] Fix | Delete
if (balance == 0)
[60] Fix | Delete
return chain(readQuoted(ch, "string-2", true), stream, state);
[61] Fix | Delete
}
[62] Fix | Delete
return "operator";
[63] Fix | Delete
} else if (ch == "%") {
[64] Fix | Delete
var style = "string", embed = true;
[65] Fix | Delete
if (stream.eat("s")) style = "atom";
[66] Fix | Delete
else if (stream.eat(/[WQ]/)) style = "string";
[67] Fix | Delete
else if (stream.eat(/[r]/)) style = "string-2";
[68] Fix | Delete
else if (stream.eat(/[wxq]/)) { style = "string"; embed = false; }
[69] Fix | Delete
var delim = stream.eat(/[^\w\s=]/);
[70] Fix | Delete
if (!delim) return "operator";
[71] Fix | Delete
if (matching.propertyIsEnumerable(delim)) delim = matching[delim];
[72] Fix | Delete
return chain(readQuoted(delim, style, embed, true), stream, state);
[73] Fix | Delete
} else if (ch == "#") {
[74] Fix | Delete
stream.skipToEnd();
[75] Fix | Delete
return "comment";
[76] Fix | Delete
} else if (ch == "<" && (m = stream.match(/^<-?[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) {
[77] Fix | Delete
return chain(readHereDoc(m[1]), stream, state);
[78] Fix | Delete
} else if (ch == "0") {
[79] Fix | Delete
if (stream.eat("x")) stream.eatWhile(/[\da-fA-F]/);
[80] Fix | Delete
else if (stream.eat("b")) stream.eatWhile(/[01]/);
[81] Fix | Delete
else stream.eatWhile(/[0-7]/);
[82] Fix | Delete
return "number";
[83] Fix | Delete
} else if (/\d/.test(ch)) {
[84] Fix | Delete
stream.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+\-]?[\d_]+)?/);
[85] Fix | Delete
return "number";
[86] Fix | Delete
} else if (ch == "?") {
[87] Fix | Delete
while (stream.match(/^\\[CM]-/)) {}
[88] Fix | Delete
if (stream.eat("\\")) stream.eatWhile(/\w/);
[89] Fix | Delete
else stream.next();
[90] Fix | Delete
return "string";
[91] Fix | Delete
} else if (ch == ":") {
[92] Fix | Delete
if (stream.eat("'")) return chain(readQuoted("'", "atom", false), stream, state);
[93] Fix | Delete
if (stream.eat('"')) return chain(readQuoted('"', "atom", true), stream, state);
[94] Fix | Delete
[95] Fix | Delete
// :> :>> :< :<< are valid symbols
[96] Fix | Delete
if (stream.eat(/[\<\>]/)) {
[97] Fix | Delete
stream.eat(/[\<\>]/);
[98] Fix | Delete
return "atom";
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
// :+ :- :/ :* :| :& :! are valid symbols
[102] Fix | Delete
if (stream.eat(/[\+\-\*\/\&\|\:\!]/)) {
[103] Fix | Delete
return "atom";
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
// Symbols can't start by a digit
[107] Fix | Delete
if (stream.eat(/[a-zA-Z$@_\xa1-\uffff]/)) {
[108] Fix | Delete
stream.eatWhile(/[\w$\xa1-\uffff]/);
[109] Fix | Delete
// Only one ? ! = is allowed and only as the last character
[110] Fix | Delete
stream.eat(/[\?\!\=]/);
[111] Fix | Delete
return "atom";
[112] Fix | Delete
}
[113] Fix | Delete
return "operator";
[114] Fix | Delete
} else if (ch == "@" && stream.match(/^@?[a-zA-Z_\xa1-\uffff]/)) {
[115] Fix | Delete
stream.eat("@");
[116] Fix | Delete
stream.eatWhile(/[\w\xa1-\uffff]/);
[117] Fix | Delete
return "variable-2";
[118] Fix | Delete
} else if (ch == "$") {
[119] Fix | Delete
if (stream.eat(/[a-zA-Z_]/)) {
[120] Fix | Delete
stream.eatWhile(/[\w]/);
[121] Fix | Delete
} else if (stream.eat(/\d/)) {
[122] Fix | Delete
stream.eat(/\d/);
[123] Fix | Delete
} else {
[124] Fix | Delete
stream.next(); // Must be a special global like $: or $!
[125] Fix | Delete
}
[126] Fix | Delete
return "variable-3";
[127] Fix | Delete
} else if (/[a-zA-Z_\xa1-\uffff]/.test(ch)) {
[128] Fix | Delete
stream.eatWhile(/[\w\xa1-\uffff]/);
[129] Fix | Delete
stream.eat(/[\?\!]/);
[130] Fix | Delete
if (stream.eat(":")) return "atom";
[131] Fix | Delete
return "ident";
[132] Fix | Delete
} else if (ch == "|" && (state.varList || state.lastTok == "{" || state.lastTok == "do")) {
[133] Fix | Delete
curPunc = "|";
[134] Fix | Delete
return null;
[135] Fix | Delete
} else if (/[\(\)\[\]{}\\;]/.test(ch)) {
[136] Fix | Delete
curPunc = ch;
[137] Fix | Delete
return null;
[138] Fix | Delete
} else if (ch == "-" && stream.eat(">")) {
[139] Fix | Delete
return "arrow";
[140] Fix | Delete
} else if (/[=+\-\/*:\.^%<>~|]/.test(ch)) {
[141] Fix | Delete
var more = stream.eatWhile(/[=+\-\/*:\.^%<>~|]/);
[142] Fix | Delete
if (ch == "." && !more) curPunc = ".";
[143] Fix | Delete
return "operator";
[144] Fix | Delete
} else {
[145] Fix | Delete
return null;
[146] Fix | Delete
}
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
function tokenBaseUntilBrace(depth) {
[150] Fix | Delete
if (!depth) depth = 1;
[151] Fix | Delete
return function(stream, state) {
[152] Fix | Delete
if (stream.peek() == "}") {
[153] Fix | Delete
if (depth == 1) {
[154] Fix | Delete
state.tokenize.pop();
[155] Fix | Delete
return state.tokenize[state.tokenize.length-1](stream, state);
[156] Fix | Delete
} else {
[157] Fix | Delete
state.tokenize[state.tokenize.length - 1] = tokenBaseUntilBrace(depth - 1);
[158] Fix | Delete
}
[159] Fix | Delete
} else if (stream.peek() == "{") {
[160] Fix | Delete
state.tokenize[state.tokenize.length - 1] = tokenBaseUntilBrace(depth + 1);
[161] Fix | Delete
}
[162] Fix | Delete
return tokenBase(stream, state);
[163] Fix | Delete
};
[164] Fix | Delete
}
[165] Fix | Delete
function tokenBaseOnce() {
[166] Fix | Delete
var alreadyCalled = false;
[167] Fix | Delete
return function(stream, state) {
[168] Fix | Delete
if (alreadyCalled) {
[169] Fix | Delete
state.tokenize.pop();
[170] Fix | Delete
return state.tokenize[state.tokenize.length-1](stream, state);
[171] Fix | Delete
}
[172] Fix | Delete
alreadyCalled = true;
[173] Fix | Delete
return tokenBase(stream, state);
[174] Fix | Delete
};
[175] Fix | Delete
}
[176] Fix | Delete
function readQuoted(quote, style, embed, unescaped) {
[177] Fix | Delete
return function(stream, state) {
[178] Fix | Delete
var escaped = false, ch;
[179] Fix | Delete
[180] Fix | Delete
if (state.context.type === 'read-quoted-paused') {
[181] Fix | Delete
state.context = state.context.prev;
[182] Fix | Delete
stream.eat("}");
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
while ((ch = stream.next()) != null) {
[186] Fix | Delete
if (ch == quote && (unescaped || !escaped)) {
[187] Fix | Delete
state.tokenize.pop();
[188] Fix | Delete
break;
[189] Fix | Delete
}
[190] Fix | Delete
if (embed && ch == "#" && !escaped) {
[191] Fix | Delete
if (stream.eat("{")) {
[192] Fix | Delete
if (quote == "}") {
[193] Fix | Delete
state.context = {prev: state.context, type: 'read-quoted-paused'};
[194] Fix | Delete
}
[195] Fix | Delete
state.tokenize.push(tokenBaseUntilBrace());
[196] Fix | Delete
break;
[197] Fix | Delete
} else if (/[@\$]/.test(stream.peek())) {
[198] Fix | Delete
state.tokenize.push(tokenBaseOnce());
[199] Fix | Delete
break;
[200] Fix | Delete
}
[201] Fix | Delete
}
[202] Fix | Delete
escaped = !escaped && ch == "\\";
[203] Fix | Delete
}
[204] Fix | Delete
return style;
[205] Fix | Delete
};
[206] Fix | Delete
}
[207] Fix | Delete
function readHereDoc(phrase) {
[208] Fix | Delete
return function(stream, state) {
[209] Fix | Delete
if (stream.match(phrase)) state.tokenize.pop();
[210] Fix | Delete
else stream.skipToEnd();
[211] Fix | Delete
return "string";
[212] Fix | Delete
};
[213] Fix | Delete
}
[214] Fix | Delete
function readBlockComment(stream, state) {
[215] Fix | Delete
if (stream.sol() && stream.match("=end") && stream.eol())
[216] Fix | Delete
state.tokenize.pop();
[217] Fix | Delete
stream.skipToEnd();
[218] Fix | Delete
return "comment";
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
return {
[222] Fix | Delete
startState: function() {
[223] Fix | Delete
return {tokenize: [tokenBase],
[224] Fix | Delete
indented: 0,
[225] Fix | Delete
context: {type: "top", indented: -config.indentUnit},
[226] Fix | Delete
continuedLine: false,
[227] Fix | Delete
lastTok: null,
[228] Fix | Delete
varList: false};
[229] Fix | Delete
},
[230] Fix | Delete
[231] Fix | Delete
token: function(stream, state) {
[232] Fix | Delete
curPunc = null;
[233] Fix | Delete
if (stream.sol()) state.indented = stream.indentation();
[234] Fix | Delete
var style = state.tokenize[state.tokenize.length-1](stream, state), kwtype;
[235] Fix | Delete
var thisTok = curPunc;
[236] Fix | Delete
if (style == "ident") {
[237] Fix | Delete
var word = stream.current();
[238] Fix | Delete
style = state.lastTok == "." ? "property"
[239] Fix | Delete
: keywords.propertyIsEnumerable(stream.current()) ? "keyword"
[240] Fix | Delete
: /^[A-Z]/.test(word) ? "tag"
[241] Fix | Delete
: (state.lastTok == "def" || state.lastTok == "class" || state.varList) ? "def"
[242] Fix | Delete
: "variable";
[243] Fix | Delete
if (style == "keyword") {
[244] Fix | Delete
thisTok = word;
[245] Fix | Delete
if (indentWords.propertyIsEnumerable(word)) kwtype = "indent";
[246] Fix | Delete
else if (dedentWords.propertyIsEnumerable(word)) kwtype = "dedent";
[247] Fix | Delete
else if ((word == "if" || word == "unless") && stream.column() == stream.indentation())
[248] Fix | Delete
kwtype = "indent";
[249] Fix | Delete
else if (word == "do" && state.context.indented < state.indented)
[250] Fix | Delete
kwtype = "indent";
[251] Fix | Delete
}
[252] Fix | Delete
}
[253] Fix | Delete
if (curPunc || (style && style != "comment")) state.lastTok = thisTok;
[254] Fix | Delete
if (curPunc == "|") state.varList = !state.varList;
[255] Fix | Delete
[256] Fix | Delete
if (kwtype == "indent" || /[\(\[\{]/.test(curPunc))
[257] Fix | Delete
state.context = {prev: state.context, type: curPunc || style, indented: state.indented};
[258] Fix | Delete
else if ((kwtype == "dedent" || /[\)\]\}]/.test(curPunc)) && state.context.prev)
[259] Fix | Delete
state.context = state.context.prev;
[260] Fix | Delete
[261] Fix | Delete
if (stream.eol())
[262] Fix | Delete
state.continuedLine = (curPunc == "\\" || style == "operator");
[263] Fix | Delete
return style;
[264] Fix | Delete
},
[265] Fix | Delete
[266] Fix | Delete
indent: function(state, textAfter) {
[267] Fix | Delete
if (state.tokenize[state.tokenize.length-1] != tokenBase) return 0;
[268] Fix | Delete
var firstChar = textAfter && textAfter.charAt(0);
[269] Fix | Delete
var ct = state.context;
[270] Fix | Delete
var closing = ct.type == matching[firstChar] ||
[271] Fix | Delete
ct.type == "keyword" && /^(?:end|until|else|elsif|when|rescue)\b/.test(textAfter);
[272] Fix | Delete
return ct.indented + (closing ? 0 : config.indentUnit) +
[273] Fix | Delete
(state.continuedLine ? config.indentUnit : 0);
[274] Fix | Delete
},
[275] Fix | Delete
[276] Fix | Delete
electricInput: /^\s*(?:end|rescue|\})$/,
[277] Fix | Delete
lineComment: "#"
[278] Fix | Delete
};
[279] Fix | Delete
});
[280] Fix | Delete
[281] Fix | Delete
CodeMirror.defineMIME("text/x-ruby", "ruby");
[282] Fix | Delete
[283] Fix | Delete
});
[284] Fix | Delete
[285] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function