Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/livescri...
File: livescript.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
/**
[3] Fix | Delete
* Link to the project's GitHub page:
[4] Fix | Delete
* https://github.com/duralog/CodeMirror
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
(function(mod) {
[8] Fix | Delete
if (typeof exports == "object" && typeof module == "object") // CommonJS
[9] Fix | Delete
mod(require("../../lib/codemirror"));
[10] Fix | Delete
else if (typeof define == "function" && define.amd) // AMD
[11] Fix | Delete
define(["../../lib/codemirror"], mod);
[12] Fix | Delete
else // Plain browser env
[13] Fix | Delete
mod(CodeMirror);
[14] Fix | Delete
})(function(CodeMirror) {
[15] Fix | Delete
"use strict";
[16] Fix | Delete
[17] Fix | Delete
CodeMirror.defineMode('livescript', function(){
[18] Fix | Delete
var tokenBase = function(stream, state) {
[19] Fix | Delete
var next_rule = state.next || "start";
[20] Fix | Delete
if (next_rule) {
[21] Fix | Delete
state.next = state.next;
[22] Fix | Delete
var nr = Rules[next_rule];
[23] Fix | Delete
if (nr.splice) {
[24] Fix | Delete
for (var i$ = 0; i$ < nr.length; ++i$) {
[25] Fix | Delete
var r = nr[i$];
[26] Fix | Delete
if (r.regex && stream.match(r.regex)) {
[27] Fix | Delete
state.next = r.next || state.next;
[28] Fix | Delete
return r.token;
[29] Fix | Delete
}
[30] Fix | Delete
}
[31] Fix | Delete
stream.next();
[32] Fix | Delete
return 'error';
[33] Fix | Delete
}
[34] Fix | Delete
if (stream.match(r = Rules[next_rule])) {
[35] Fix | Delete
if (r.regex && stream.match(r.regex)) {
[36] Fix | Delete
state.next = r.next;
[37] Fix | Delete
return r.token;
[38] Fix | Delete
} else {
[39] Fix | Delete
stream.next();
[40] Fix | Delete
return 'error';
[41] Fix | Delete
}
[42] Fix | Delete
}
[43] Fix | Delete
}
[44] Fix | Delete
stream.next();
[45] Fix | Delete
return 'error';
[46] Fix | Delete
};
[47] Fix | Delete
var external = {
[48] Fix | Delete
startState: function(){
[49] Fix | Delete
return {
[50] Fix | Delete
next: 'start',
[51] Fix | Delete
lastToken: {style: null, indent: 0, content: ""}
[52] Fix | Delete
};
[53] Fix | Delete
},
[54] Fix | Delete
token: function(stream, state){
[55] Fix | Delete
while (stream.pos == stream.start)
[56] Fix | Delete
var style = tokenBase(stream, state);
[57] Fix | Delete
state.lastToken = {
[58] Fix | Delete
style: style,
[59] Fix | Delete
indent: stream.indentation(),
[60] Fix | Delete
content: stream.current()
[61] Fix | Delete
};
[62] Fix | Delete
return style.replace(/\./g, ' ');
[63] Fix | Delete
},
[64] Fix | Delete
indent: function(state){
[65] Fix | Delete
var indentation = state.lastToken.indent;
[66] Fix | Delete
if (state.lastToken.content.match(indenter)) {
[67] Fix | Delete
indentation += 2;
[68] Fix | Delete
}
[69] Fix | Delete
return indentation;
[70] Fix | Delete
}
[71] Fix | Delete
};
[72] Fix | Delete
return external;
[73] Fix | Delete
});
[74] Fix | Delete
[75] Fix | Delete
var identifier = '(?![\\d\\s])[$\\w\\xAA-\\uFFDC](?:(?!\\s)[$\\w\\xAA-\\uFFDC]|-[A-Za-z])*';
[76] Fix | Delete
var indenter = RegExp('(?:[({[=:]|[-~]>|\\b(?:e(?:lse|xport)|d(?:o|efault)|t(?:ry|hen)|finally|import(?:\\s*all)?|const|var|let|new|catch(?:\\s*' + identifier + ')?))\\s*$');
[77] Fix | Delete
var keywordend = '(?![$\\w]|-[A-Za-z]|\\s*:(?![:=]))';
[78] Fix | Delete
var stringfill = {
[79] Fix | Delete
token: 'string',
[80] Fix | Delete
regex: '.+'
[81] Fix | Delete
};
[82] Fix | Delete
var Rules = {
[83] Fix | Delete
start: [
[84] Fix | Delete
{
[85] Fix | Delete
token: 'comment.doc',
[86] Fix | Delete
regex: '/\\*',
[87] Fix | Delete
next: 'comment'
[88] Fix | Delete
}, {
[89] Fix | Delete
token: 'comment',
[90] Fix | Delete
regex: '#.*'
[91] Fix | Delete
}, {
[92] Fix | Delete
token: 'keyword',
[93] Fix | Delete
regex: '(?:t(?:h(?:is|row|en)|ry|ypeof!?)|c(?:on(?:tinue|st)|a(?:se|tch)|lass)|i(?:n(?:stanceof)?|mp(?:ort(?:\\s+all)?|lements)|[fs])|d(?:e(?:fault|lete|bugger)|o)|f(?:or(?:\\s+own)?|inally|unction)|s(?:uper|witch)|e(?:lse|x(?:tends|port)|val)|a(?:nd|rguments)|n(?:ew|ot)|un(?:less|til)|w(?:hile|ith)|o[fr]|return|break|let|var|loop)' + keywordend
[94] Fix | Delete
}, {
[95] Fix | Delete
token: 'constant.language',
[96] Fix | Delete
regex: '(?:true|false|yes|no|on|off|null|void|undefined)' + keywordend
[97] Fix | Delete
}, {
[98] Fix | Delete
token: 'invalid.illegal',
[99] Fix | Delete
regex: '(?:p(?:ackage|r(?:ivate|otected)|ublic)|i(?:mplements|nterface)|enum|static|yield)' + keywordend
[100] Fix | Delete
}, {
[101] Fix | Delete
token: 'language.support.class',
[102] Fix | Delete
regex: '(?:R(?:e(?:gExp|ferenceError)|angeError)|S(?:tring|yntaxError)|E(?:rror|valError)|Array|Boolean|Date|Function|Number|Object|TypeError|URIError)' + keywordend
[103] Fix | Delete
}, {
[104] Fix | Delete
token: 'language.support.function',
[105] Fix | Delete
regex: '(?:is(?:NaN|Finite)|parse(?:Int|Float)|Math|JSON|(?:en|de)codeURI(?:Component)?)' + keywordend
[106] Fix | Delete
}, {
[107] Fix | Delete
token: 'variable.language',
[108] Fix | Delete
regex: '(?:t(?:hat|il|o)|f(?:rom|allthrough)|it|by|e)' + keywordend
[109] Fix | Delete
}, {
[110] Fix | Delete
token: 'identifier',
[111] Fix | Delete
regex: identifier + '\\s*:(?![:=])'
[112] Fix | Delete
}, {
[113] Fix | Delete
token: 'variable',
[114] Fix | Delete
regex: identifier
[115] Fix | Delete
}, {
[116] Fix | Delete
token: 'keyword.operator',
[117] Fix | Delete
regex: '(?:\\.{3}|\\s+\\?)'
[118] Fix | Delete
}, {
[119] Fix | Delete
token: 'keyword.variable',
[120] Fix | Delete
regex: '(?:@+|::|\\.\\.)',
[121] Fix | Delete
next: 'key'
[122] Fix | Delete
}, {
[123] Fix | Delete
token: 'keyword.operator',
[124] Fix | Delete
regex: '\\.\\s*',
[125] Fix | Delete
next: 'key'
[126] Fix | Delete
}, {
[127] Fix | Delete
token: 'string',
[128] Fix | Delete
regex: '\\\\\\S[^\\s,;)}\\]]*'
[129] Fix | Delete
}, {
[130] Fix | Delete
token: 'string.doc',
[131] Fix | Delete
regex: '\'\'\'',
[132] Fix | Delete
next: 'qdoc'
[133] Fix | Delete
}, {
[134] Fix | Delete
token: 'string.doc',
[135] Fix | Delete
regex: '"""',
[136] Fix | Delete
next: 'qqdoc'
[137] Fix | Delete
}, {
[138] Fix | Delete
token: 'string',
[139] Fix | Delete
regex: '\'',
[140] Fix | Delete
next: 'qstring'
[141] Fix | Delete
}, {
[142] Fix | Delete
token: 'string',
[143] Fix | Delete
regex: '"',
[144] Fix | Delete
next: 'qqstring'
[145] Fix | Delete
}, {
[146] Fix | Delete
token: 'string',
[147] Fix | Delete
regex: '`',
[148] Fix | Delete
next: 'js'
[149] Fix | Delete
}, {
[150] Fix | Delete
token: 'string',
[151] Fix | Delete
regex: '<\\[',
[152] Fix | Delete
next: 'words'
[153] Fix | Delete
}, {
[154] Fix | Delete
token: 'string.regex',
[155] Fix | Delete
regex: '//',
[156] Fix | Delete
next: 'heregex'
[157] Fix | Delete
}, {
[158] Fix | Delete
token: 'string.regex',
[159] Fix | Delete
regex: '\\/(?:[^[\\/\\n\\\\]*(?:(?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[\\/\\n\\\\]*)*)\\/[gimy$]{0,4}',
[160] Fix | Delete
next: 'key'
[161] Fix | Delete
}, {
[162] Fix | Delete
token: 'constant.numeric',
[163] Fix | Delete
regex: '(?:0x[\\da-fA-F][\\da-fA-F_]*|(?:[2-9]|[12]\\d|3[0-6])r[\\da-zA-Z][\\da-zA-Z_]*|(?:\\d[\\d_]*(?:\\.\\d[\\d_]*)?|\\.\\d[\\d_]*)(?:e[+-]?\\d[\\d_]*)?[\\w$]*)'
[164] Fix | Delete
}, {
[165] Fix | Delete
token: 'lparen',
[166] Fix | Delete
regex: '[({[]'
[167] Fix | Delete
}, {
[168] Fix | Delete
token: 'rparen',
[169] Fix | Delete
regex: '[)}\\]]',
[170] Fix | Delete
next: 'key'
[171] Fix | Delete
}, {
[172] Fix | Delete
token: 'keyword.operator',
[173] Fix | Delete
regex: '\\S+'
[174] Fix | Delete
}, {
[175] Fix | Delete
token: 'text',
[176] Fix | Delete
regex: '\\s+'
[177] Fix | Delete
}
[178] Fix | Delete
],
[179] Fix | Delete
heregex: [
[180] Fix | Delete
{
[181] Fix | Delete
token: 'string.regex',
[182] Fix | Delete
regex: '.*?//[gimy$?]{0,4}',
[183] Fix | Delete
next: 'start'
[184] Fix | Delete
}, {
[185] Fix | Delete
token: 'string.regex',
[186] Fix | Delete
regex: '\\s*#{'
[187] Fix | Delete
}, {
[188] Fix | Delete
token: 'comment.regex',
[189] Fix | Delete
regex: '\\s+(?:#.*)?'
[190] Fix | Delete
}, {
[191] Fix | Delete
token: 'string.regex',
[192] Fix | Delete
regex: '\\S+'
[193] Fix | Delete
}
[194] Fix | Delete
],
[195] Fix | Delete
key: [
[196] Fix | Delete
{
[197] Fix | Delete
token: 'keyword.operator',
[198] Fix | Delete
regex: '[.?@!]+'
[199] Fix | Delete
}, {
[200] Fix | Delete
token: 'identifier',
[201] Fix | Delete
regex: identifier,
[202] Fix | Delete
next: 'start'
[203] Fix | Delete
}, {
[204] Fix | Delete
token: 'text',
[205] Fix | Delete
regex: '',
[206] Fix | Delete
next: 'start'
[207] Fix | Delete
}
[208] Fix | Delete
],
[209] Fix | Delete
comment: [
[210] Fix | Delete
{
[211] Fix | Delete
token: 'comment.doc',
[212] Fix | Delete
regex: '.*?\\*/',
[213] Fix | Delete
next: 'start'
[214] Fix | Delete
}, {
[215] Fix | Delete
token: 'comment.doc',
[216] Fix | Delete
regex: '.+'
[217] Fix | Delete
}
[218] Fix | Delete
],
[219] Fix | Delete
qdoc: [
[220] Fix | Delete
{
[221] Fix | Delete
token: 'string',
[222] Fix | Delete
regex: ".*?'''",
[223] Fix | Delete
next: 'key'
[224] Fix | Delete
}, stringfill
[225] Fix | Delete
],
[226] Fix | Delete
qqdoc: [
[227] Fix | Delete
{
[228] Fix | Delete
token: 'string',
[229] Fix | Delete
regex: '.*?"""',
[230] Fix | Delete
next: 'key'
[231] Fix | Delete
}, stringfill
[232] Fix | Delete
],
[233] Fix | Delete
qstring: [
[234] Fix | Delete
{
[235] Fix | Delete
token: 'string',
[236] Fix | Delete
regex: '[^\\\\\']*(?:\\\\.[^\\\\\']*)*\'',
[237] Fix | Delete
next: 'key'
[238] Fix | Delete
}, stringfill
[239] Fix | Delete
],
[240] Fix | Delete
qqstring: [
[241] Fix | Delete
{
[242] Fix | Delete
token: 'string',
[243] Fix | Delete
regex: '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"',
[244] Fix | Delete
next: 'key'
[245] Fix | Delete
}, stringfill
[246] Fix | Delete
],
[247] Fix | Delete
js: [
[248] Fix | Delete
{
[249] Fix | Delete
token: 'string',
[250] Fix | Delete
regex: '[^\\\\`]*(?:\\\\.[^\\\\`]*)*`',
[251] Fix | Delete
next: 'key'
[252] Fix | Delete
}, stringfill
[253] Fix | Delete
],
[254] Fix | Delete
words: [
[255] Fix | Delete
{
[256] Fix | Delete
token: 'string',
[257] Fix | Delete
regex: '.*?\\]>',
[258] Fix | Delete
next: 'key'
[259] Fix | Delete
}, stringfill
[260] Fix | Delete
]
[261] Fix | Delete
};
[262] Fix | Delete
for (var idx in Rules) {
[263] Fix | Delete
var r = Rules[idx];
[264] Fix | Delete
if (r.splice) {
[265] Fix | Delete
for (var i = 0, len = r.length; i < len; ++i) {
[266] Fix | Delete
var rr = r[i];
[267] Fix | Delete
if (typeof rr.regex === 'string') {
[268] Fix | Delete
Rules[idx][i].regex = new RegExp('^' + rr.regex);
[269] Fix | Delete
}
[270] Fix | Delete
}
[271] Fix | Delete
} else if (typeof rr.regex === 'string') {
[272] Fix | Delete
Rules[idx].regex = new RegExp('^' + r.regex);
[273] Fix | Delete
}
[274] Fix | Delete
}
[275] Fix | Delete
[276] Fix | Delete
CodeMirror.defineMIME('text/x-livescript', 'livescript');
[277] Fix | Delete
[278] Fix | Delete
});
[279] Fix | Delete
[280] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function