codemirror-rails 3.21 → 3.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror.js +89 -43
- data/vendor/assets/javascripts/codemirror/addons/comment/continuecomment.js +16 -3
- data/vendor/assets/javascripts/codemirror/addons/dialog/dialog.js +1 -0
- data/vendor/assets/javascripts/codemirror/addons/display/rulers.js +47 -0
- data/vendor/assets/javascripts/codemirror/addons/edit/closetag.js +1 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/foldcode.js +6 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/markdown-fold.js +34 -0
- data/vendor/assets/javascripts/codemirror/addons/hint/anyword-hint.js +2 -2
- data/vendor/assets/javascripts/codemirror/addons/hint/html-hint.js +0 -0
- data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +25 -18
- data/vendor/assets/javascripts/codemirror/addons/lint/yaml-lint.js +14 -0
- data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +2 -2
- data/vendor/assets/javascripts/codemirror/addons/scroll/scrollpastend.js +2 -0
- data/vendor/assets/javascripts/codemirror/addons/search/search.js +9 -3
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +126 -54
- data/vendor/assets/javascripts/codemirror/modes/clojure.js +6 -5
- data/vendor/assets/javascripts/codemirror/modes/css.js +19 -9
- data/vendor/assets/javascripts/codemirror/modes/gas.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +4 -1
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +11 -3
- data/vendor/assets/javascripts/codemirror/modes/julia.js +47 -23
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +5 -3
- data/vendor/assets/javascripts/codemirror/modes/octave.js +6 -4
- data/vendor/assets/javascripts/codemirror/modes/puppet.js +204 -0
- data/vendor/assets/javascripts/codemirror/modes/python.js +4 -0
- data/vendor/assets/javascripts/codemirror/modes/rst.js +520 -517
- data/vendor/assets/javascripts/codemirror/modes/ruby.js +1 -0
- data/vendor/assets/javascripts/codemirror/modes/solr.js +89 -0
- data/vendor/assets/javascripts/codemirror/modes/sql.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/xml.js +2 -1
- data/vendor/assets/stylesheets/codemirror.css +12 -11
- data/vendor/assets/stylesheets/codemirror/themes/mdn-like.css +44 -0
- data/vendor/assets/stylesheets/codemirror/themes/solarized.css +1 -0
- metadata +8 -2
@@ -2,10 +2,11 @@
|
|
2
2
|
* Author: Hans Engel
|
3
3
|
* Branched from CodeMirror's Scheme mode (by Koh Zi Han, based on implementation by Koh Zi Chun)
|
4
4
|
*/
|
5
|
-
CodeMirror.defineMode("clojure", function () {
|
5
|
+
CodeMirror.defineMode("clojure", function (options) {
|
6
6
|
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", CHARACTER = "string-2",
|
7
7
|
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword";
|
8
|
-
var INDENT_WORD_SKIP = 2;
|
8
|
+
var INDENT_WORD_SKIP = options.indentUnit || 2;
|
9
|
+
var NORMAL_INDENT_UNIT = options.indentUnit || 2;
|
9
10
|
|
10
11
|
function makeKeywords(str) {
|
11
12
|
var obj = {}, words = str.split(" ");
|
@@ -44,7 +45,7 @@ CodeMirror.defineMode("clojure", function () {
|
|
44
45
|
sign: /[+-]/,
|
45
46
|
exponent: /e/i,
|
46
47
|
keyword_char: /[^\s\(\[\;\)\]]/,
|
47
|
-
symbol: /[\w*+!\-\._
|
48
|
+
symbol: /[\w*+!\-\._?:<>\/]/
|
48
49
|
};
|
49
50
|
|
50
51
|
function stateStack(indent, type, prev) { // represents a state stack object
|
@@ -179,8 +180,8 @@ CodeMirror.defineMode("clojure", function () {
|
|
179
180
|
stream.eatSpace();
|
180
181
|
if (stream.eol() || stream.peek() == ";") {
|
181
182
|
// nothing significant after
|
182
|
-
// we restart indentation
|
183
|
-
pushStack(state, indentTemp +
|
183
|
+
// we restart indentation the user defined spaces after
|
184
|
+
pushStack(state, indentTemp + NORMAL_INDENT_UNIT, ch);
|
184
185
|
} else {
|
185
186
|
pushStack(state, indentTemp + stream.current().length, ch); // else we match
|
186
187
|
}
|
@@ -140,6 +140,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
140
140
|
return pushContext(state, stream, "media");
|
141
141
|
} else if (type == "@font-face") {
|
142
142
|
return "font_face_before";
|
143
|
+
} else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) {
|
144
|
+
return "keyframes";
|
143
145
|
} else if (type && type.charAt(0) == "@") {
|
144
146
|
return pushContext(state, stream, "at");
|
145
147
|
} else if (type == "hash") {
|
@@ -264,6 +266,12 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
264
266
|
return "font_face";
|
265
267
|
};
|
266
268
|
|
269
|
+
states.keyframes = function(type, stream, state) {
|
270
|
+
if (type == "word") { override = "variable"; return "keyframes"; }
|
271
|
+
if (type == "{") return pushContext(state, stream, "top");
|
272
|
+
return pass(type, stream, state);
|
273
|
+
};
|
274
|
+
|
267
275
|
states.at = function(type, stream, state) {
|
268
276
|
if (type == ";") return popContext(state);
|
269
277
|
if (type == "{" || type == "}") return popAndPass(type, stream, state);
|
@@ -308,6 +316,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
308
316
|
indent: function(state, textAfter) {
|
309
317
|
var cx = state.context, ch = textAfter && textAfter.charAt(0);
|
310
318
|
var indent = cx.indent;
|
319
|
+
if (cx.type == "prop" && ch == "}") cx = cx.prev;
|
311
320
|
if (cx.prev &&
|
312
321
|
(ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "font_face") ||
|
313
322
|
ch == ")" && (cx.type == "parens" || cx.type == "params" || cx.type == "media_parens") ||
|
@@ -353,10 +362,10 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
353
362
|
var propertyKeywords_ = [
|
354
363
|
"align-content", "align-items", "align-self", "alignment-adjust",
|
355
364
|
"alignment-baseline", "anchor-point", "animation", "animation-delay",
|
356
|
-
"animation-direction", "animation-duration", "animation-
|
357
|
-
"animation-
|
358
|
-
"appearance", "azimuth", "backface-visibility",
|
359
|
-
"background-attachment", "background-clip", "background-color",
|
365
|
+
"animation-direction", "animation-duration", "animation-fill-mode",
|
366
|
+
"animation-iteration-count", "animation-name", "animation-play-state",
|
367
|
+
"animation-timing-function", "appearance", "azimuth", "backface-visibility",
|
368
|
+
"background", "background-attachment", "background-clip", "background-color",
|
360
369
|
"background-image", "background-origin", "background-position",
|
361
370
|
"background-repeat", "background-size", "baseline-shift", "binding",
|
362
371
|
"bleed", "bookmark-label", "bookmark-level", "bookmark-state",
|
@@ -387,10 +396,11 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
387
396
|
"font-stretch", "font-style", "font-synthesis", "font-variant",
|
388
397
|
"font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
|
389
398
|
"font-variant-ligatures", "font-variant-numeric", "font-variant-position",
|
390
|
-
"font-weight", "grid-
|
391
|
-
"grid-
|
392
|
-
"grid-
|
393
|
-
"grid-
|
399
|
+
"font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
|
400
|
+
"grid-auto-position", "grid-auto-rows", "grid-column", "grid-column-end",
|
401
|
+
"grid-column-start", "grid-row", "grid-row-end", "grid-row-start",
|
402
|
+
"grid-template", "grid-template-areas", "grid-template-columns",
|
403
|
+
"grid-template-rows", "hanging-punctuation", "height", "hyphens",
|
394
404
|
"icon", "image-orientation", "image-rendering", "image-resolution",
|
395
405
|
"inline-box-align", "justify-content", "left", "letter-spacing",
|
396
406
|
"line-break", "line-height", "line-stacking", "line-stacking-ruby",
|
@@ -667,7 +677,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
667
677
|
}
|
668
678
|
},
|
669
679
|
"@": function(stream) {
|
670
|
-
if (stream.match(/^(charset|document|font-face|import|keyframes|media|namespace|page|supports)\b/, false)) return false;
|
680
|
+
if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/, false)) return false;
|
671
681
|
stream.eatWhile(/[\w\\\-]/);
|
672
682
|
if (stream.match(/^\s*:/, false))
|
673
683
|
return ["variable-2", "variable-definition"];
|
@@ -211,7 +211,7 @@ CodeMirror.defineMode("gas", function(_config, parserConfig) {
|
|
211
211
|
});
|
212
212
|
}
|
213
213
|
|
214
|
-
var arch = parserConfig.architecture.toLowerCase();
|
214
|
+
var arch = (parserConfig.architecture || "x86").toLowerCase();
|
215
215
|
if (arch === "x86") {
|
216
216
|
x86(parserConfig);
|
217
217
|
} else if (arch === "arm" || arch === "armv6") {
|
@@ -1,5 +1,8 @@
|
|
1
1
|
CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
|
2
|
-
var htmlMode = CodeMirror.getMode(config, {name: "xml",
|
2
|
+
var htmlMode = CodeMirror.getMode(config, {name: "xml",
|
3
|
+
htmlMode: true,
|
4
|
+
multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
|
5
|
+
multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag});
|
3
6
|
var cssMode = CodeMirror.getMode(config, "css");
|
4
7
|
|
5
8
|
var scriptTypes = [], scriptTypesConf = parserConfig && parserConfig.scriptTypes;
|
@@ -3,7 +3,8 @@
|
|
3
3
|
CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
4
4
|
var indentUnit = config.indentUnit;
|
5
5
|
var statementIndent = parserConfig.statementIndent;
|
6
|
-
var
|
6
|
+
var jsonldMode = parserConfig.jsonld;
|
7
|
+
var jsonMode = parserConfig.json || jsonldMode;
|
7
8
|
var isTS = parserConfig.typescript;
|
8
9
|
|
9
10
|
// Tokenizer
|
@@ -53,6 +54,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|
53
54
|
}();
|
54
55
|
|
55
56
|
var isOperatorChar = /[+\-*&%=<>!?|~^]/;
|
57
|
+
var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
|
56
58
|
|
57
59
|
function readRegexp(stream) {
|
58
60
|
var escaped = false, next, inSet = false;
|
@@ -128,6 +130,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|
128
130
|
function tokenString(quote) {
|
129
131
|
return function(stream, state) {
|
130
132
|
var escaped = false, next;
|
133
|
+
if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
|
134
|
+
state.tokenize = tokenBase;
|
135
|
+
return ret("jsonld-keyword", "meta");
|
136
|
+
}
|
131
137
|
while ((next = stream.next()) != null) {
|
132
138
|
if (next == quote && !escaped) break;
|
133
139
|
escaped = !escaped && next == "\\";
|
@@ -195,7 +201,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|
195
201
|
|
196
202
|
// Parser
|
197
203
|
|
198
|
-
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true};
|
204
|
+
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
|
199
205
|
|
200
206
|
function JSLexical(indented, column, type, align, prev, info) {
|
201
207
|
this.indented = indented;
|
@@ -408,7 +414,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|
408
414
|
cx.marked = "property";
|
409
415
|
if (value == "get" || value == "set") return cont(getterSetter);
|
410
416
|
} else if (type == "number" || type == "string") {
|
411
|
-
cx.marked = type + " property";
|
417
|
+
cx.marked = jsonldMode ? "property" : (type + " property");
|
412
418
|
} else if (type == "[") {
|
413
419
|
return cont(expression, expect("]"), afterprop);
|
414
420
|
}
|
@@ -616,6 +622,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|
616
622
|
fold: "brace",
|
617
623
|
|
618
624
|
helperType: jsonMode ? "json" : "javascript",
|
625
|
+
jsonldMode: jsonldMode,
|
619
626
|
jsonMode: jsonMode
|
620
627
|
};
|
621
628
|
});
|
@@ -626,5 +633,6 @@ CodeMirror.defineMIME("application/javascript", "javascript");
|
|
626
633
|
CodeMirror.defineMIME("application/ecmascript", "javascript");
|
627
634
|
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
|
628
635
|
CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
|
636
|
+
CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
|
629
637
|
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
|
630
638
|
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
|
@@ -5,21 +5,22 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
|
|
5
5
|
return new RegExp("^((" + words.join(")|(") + "))\\b");
|
6
6
|
}
|
7
7
|
|
8
|
-
var operators = parserConf.operators ||
|
8
|
+
var operators = parserConf.operators || /^\.?[|&^\\%*+\-<>!=\/]=?|\?|~|:|\$|\.[<>]|<<=?|>>>?=?|\.[<>=]=|->?|\/\/|\bin\b/;
|
9
9
|
var delimiters = parserConf.delimiters || /^[;,()[\]{}]/;
|
10
10
|
var identifiers = parserConf.identifiers|| /^[_A-Za-z][_A-Za-z0-9]*!*/;
|
11
|
-
var blockOpeners = ["begin", "function", "type", "immutable", "let", "macro", "for", "while", "quote", "if", "else", "elseif", "try", "finally", "catch"];
|
11
|
+
var blockOpeners = ["begin", "function", "type", "immutable", "let", "macro", "for", "while", "quote", "if", "else", "elseif", "try", "finally", "catch", "do"];
|
12
12
|
var blockClosers = ["end", "else", "elseif", "catch", "finally"];
|
13
13
|
var keywordList = ['if', 'else', 'elseif', 'while', 'for', 'begin', 'let', 'end', 'do', 'try', 'catch', 'finally', 'return', 'break', 'continue', 'global', 'local', 'const', 'export', 'import', 'importall', 'using', 'function', 'macro', 'module', 'baremodule', 'type', 'immutable', 'quote', 'typealias', 'abstract', 'bitstype', 'ccall'];
|
14
|
-
var builtinList = ['true', 'false', 'enumerate', 'open', 'close', 'nothing', 'NaN', 'Inf', 'print', 'println', 'Int8', 'Uint8', 'Int16', 'Uint16', 'Int32', 'Uint32', 'Int64', 'Uint64', 'Int128', 'Uint128', 'Bool', 'Char', 'Float16', 'Float32', 'Float64', 'Array', 'Vector', 'Matrix', 'String', 'UTF8String', 'ASCIIString', 'error', 'warn', 'info', '@printf'];
|
14
|
+
var builtinList = ['true', 'false', 'enumerate', 'open', 'close', 'nothing', 'NaN', 'Inf', 'print', 'println', 'Int', 'Int8', 'Uint8', 'Int16', 'Uint16', 'Int32', 'Uint32', 'Int64', 'Uint64', 'Int128', 'Uint128', 'Bool', 'Char', 'Float16', 'Float32', 'Float64', 'Array', 'Vector', 'Matrix', 'String', 'UTF8String', 'ASCIIString', 'error', 'warn', 'info', '@printf'];
|
15
15
|
|
16
16
|
//var stringPrefixes = new RegExp("^[br]?('|\")")
|
17
|
-
var stringPrefixes = /^
|
17
|
+
var stringPrefixes = /^(`|'|"{3}|([br]?"))/;
|
18
18
|
var keywords = wordRegexp(keywordList);
|
19
19
|
var builtins = wordRegexp(builtinList);
|
20
20
|
var openers = wordRegexp(blockOpeners);
|
21
21
|
var closers = wordRegexp(blockClosers);
|
22
|
-
var macro =
|
22
|
+
var macro = /^@[_A-Za-z][_A-Za-z0-9]*/;
|
23
|
+
var symbol = /^:[_A-Za-z][_A-Za-z0-9]*/;
|
23
24
|
var indentInfo = null;
|
24
25
|
|
25
26
|
function in_array(state) {
|
@@ -43,14 +44,19 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
|
|
43
44
|
function tokenBase(stream, state) {
|
44
45
|
// Handle scope changes
|
45
46
|
var leaving_expr = state.leaving_expr;
|
47
|
+
if(stream.sol()) {
|
48
|
+
leaving_expr = false;
|
49
|
+
}
|
46
50
|
state.leaving_expr = false;
|
47
51
|
if(leaving_expr) {
|
48
52
|
if(stream.match(/^'+/)) {
|
49
53
|
return 'operator';
|
50
54
|
}
|
51
|
-
|
52
|
-
|
53
|
-
|
55
|
+
|
56
|
+
}
|
57
|
+
|
58
|
+
if(stream.match(/^\.{2,3}/)) {
|
59
|
+
return 'operator';
|
54
60
|
}
|
55
61
|
|
56
62
|
if (stream.eatSpace()) {
|
@@ -83,8 +89,12 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
|
|
83
89
|
state.leaving_expr=true;
|
84
90
|
}
|
85
91
|
|
92
|
+
if(ch===')') {
|
93
|
+
state.leaving_expr = true;
|
94
|
+
}
|
95
|
+
|
86
96
|
var match;
|
87
|
-
if(match=stream.match(openers, false)) {
|
97
|
+
if(!in_array(state) && (match=stream.match(openers, false))) {
|
88
98
|
state.scopes.push(match);
|
89
99
|
}
|
90
100
|
|
@@ -93,25 +103,29 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
|
|
93
103
|
}
|
94
104
|
|
95
105
|
if(in_array(state)) {
|
96
|
-
if(stream.match(
|
106
|
+
if(stream.match(/^end/)) {
|
97
107
|
return 'number';
|
98
108
|
}
|
99
109
|
|
100
110
|
}
|
101
|
-
|
111
|
+
|
112
|
+
if(stream.match(/^=>/)) {
|
102
113
|
return 'operator';
|
103
114
|
}
|
115
|
+
|
116
|
+
|
104
117
|
// Handle Number Literals
|
105
118
|
if (stream.match(/^[0-9\.]/, false)) {
|
106
119
|
var imMatcher = RegExp(/^im\b/);
|
107
120
|
var floatLiteral = false;
|
108
121
|
// Floats
|
109
|
-
if (stream.match(/^\d
|
110
|
-
if (stream.match(/^\d
|
122
|
+
if (stream.match(/^\d*\.(?!\.)\d+([ef][\+\-]?\d+)?/i)) { floatLiteral = true; }
|
123
|
+
if (stream.match(/^\d+\.(?!\.)\d*/)) { floatLiteral = true; }
|
111
124
|
if (stream.match(/^\.\d+/)) { floatLiteral = true; }
|
112
125
|
if (floatLiteral) {
|
113
126
|
// Float literals may be "imaginary"
|
114
127
|
stream.match(imMatcher);
|
128
|
+
state.leaving_expr = true;
|
115
129
|
return 'number';
|
116
130
|
}
|
117
131
|
// Integers
|
@@ -124,9 +138,6 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
|
|
124
138
|
if (stream.match(/^0o[0-7]+/i)) { intLiteral = true; }
|
125
139
|
// Decimal
|
126
140
|
if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) {
|
127
|
-
// Decimal literals may be "imaginary"
|
128
|
-
stream.eat(/J/i);
|
129
|
-
// TODO - Can you have imaginary longs?
|
130
141
|
intLiteral = true;
|
131
142
|
}
|
132
143
|
// Zero by itself with no other piece of number.
|
@@ -134,21 +145,37 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
|
|
134
145
|
if (intLiteral) {
|
135
146
|
// Integer literals may be "long"
|
136
147
|
stream.match(imMatcher);
|
148
|
+
state.leaving_expr = true;
|
137
149
|
return 'number';
|
138
150
|
}
|
139
151
|
}
|
140
152
|
|
153
|
+
if(stream.match(/^(::)|(<:)/)) {
|
154
|
+
return 'operator';
|
155
|
+
}
|
156
|
+
|
157
|
+
// Handle symbols
|
158
|
+
if(!leaving_expr && stream.match(symbol)) {
|
159
|
+
return 'string';
|
160
|
+
}
|
161
|
+
|
162
|
+
// Handle operators and Delimiters
|
163
|
+
if (stream.match(operators)) {
|
164
|
+
return 'operator';
|
165
|
+
}
|
166
|
+
|
167
|
+
|
141
168
|
// Handle Strings
|
142
169
|
if (stream.match(stringPrefixes)) {
|
143
170
|
state.tokenize = tokenStringFactory(stream.current());
|
144
171
|
return state.tokenize(stream, state);
|
145
172
|
}
|
146
173
|
|
147
|
-
|
148
|
-
|
149
|
-
return 'operator';
|
174
|
+
if (stream.match(macro)) {
|
175
|
+
return 'meta';
|
150
176
|
}
|
151
177
|
|
178
|
+
|
152
179
|
if (stream.match(delimiters)) {
|
153
180
|
return null;
|
154
181
|
}
|
@@ -161,9 +188,6 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
|
|
161
188
|
return 'builtin';
|
162
189
|
}
|
163
190
|
|
164
|
-
if (stream.match(macro)) {
|
165
|
-
return 'meta';
|
166
|
-
}
|
167
191
|
|
168
192
|
if (stream.match(identifiers)) {
|
169
193
|
state.leaving_expr=true;
|
@@ -248,7 +272,7 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
|
|
248
272
|
if(textAfter=="end" || textAfter=="]" || textAfter=="}" || textAfter=="else" || textAfter=="elseif" || textAfter=="catch" || textAfter=="finally") {
|
249
273
|
delta = -1;
|
250
274
|
}
|
251
|
-
return (state.scopes.length + delta) *
|
275
|
+
return (state.scopes.length + delta) * 4;
|
252
276
|
},
|
253
277
|
|
254
278
|
lineComment: "#",
|
@@ -239,7 +239,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
239
239
|
styles.push(formatting + "-" + state.formatting[i]);
|
240
240
|
|
241
241
|
if (state.formatting[i] === "header") {
|
242
|
-
styles.push(formatting + "-" + state.formatting[i] + state.header);
|
242
|
+
styles.push(formatting + "-" + state.formatting[i] + "-" + state.header);
|
243
243
|
}
|
244
244
|
|
245
245
|
// Add `formatting-quote` and `formatting-quote-#` for blockquotes
|
@@ -275,7 +275,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
275
275
|
|
276
276
|
if (state.code) { styles.push(code); }
|
277
277
|
|
278
|
-
if (state.header) { styles.push(header); styles.push(header + state.header); }
|
278
|
+
if (state.header) { styles.push(header); styles.push(header + "-" + state.header); }
|
279
279
|
|
280
280
|
if (state.quote) {
|
281
281
|
styles.push(quote);
|
@@ -738,7 +738,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
738
738
|
|
739
739
|
blankLine: blankLine,
|
740
740
|
|
741
|
-
getType: getType
|
741
|
+
getType: getType,
|
742
|
+
|
743
|
+
fold: "markdown"
|
742
744
|
};
|
743
745
|
return mode;
|
744
746
|
}, "xml");
|
@@ -13,17 +13,19 @@ CodeMirror.defineMode("octave", function() {
|
|
13
13
|
|
14
14
|
var builtins = wordRegexp([
|
15
15
|
'error', 'eval', 'function', 'abs', 'acos', 'atan', 'asin', 'cos',
|
16
|
-
'cosh', 'exp', 'log', 'prod', 'log10', 'max', 'min', 'sign', 'sin', 'sinh',
|
16
|
+
'cosh', 'exp', 'log', 'prod', 'sum', 'log10', 'max', 'min', 'sign', 'sin', 'sinh',
|
17
17
|
'sqrt', 'tan', 'reshape', 'break', 'zeros', 'default', 'margin', 'round', 'ones',
|
18
18
|
'rand', 'syn', 'ceil', 'floor', 'size', 'clear', 'zeros', 'eye', 'mean', 'std', 'cov',
|
19
19
|
'det', 'eig', 'inv', 'norm', 'rank', 'trace', 'expm', 'logm', 'sqrtm', 'linspace', 'plot',
|
20
|
-
'title', 'xlabel', 'ylabel', 'legend', 'text', 'meshgrid', 'mesh', 'num2str'
|
20
|
+
'title', 'xlabel', 'ylabel', 'legend', 'text', 'grid', 'meshgrid', 'mesh', 'num2str',
|
21
|
+
'fft', 'ifft', 'arrayfun', 'cellfun', 'input', 'fliplr', 'flipud', 'ismember'
|
21
22
|
]);
|
22
23
|
|
23
24
|
var keywords = wordRegexp([
|
24
25
|
'return', 'case', 'switch', 'else', 'elseif', 'end', 'endif', 'endfunction',
|
25
26
|
'if', 'otherwise', 'do', 'for', 'while', 'try', 'catch', 'classdef', 'properties', 'events',
|
26
|
-
'methods', 'global', 'persistent', 'endfor', 'endwhile', 'printf', '
|
27
|
+
'methods', 'global', 'persistent', 'endfor', 'endwhile', 'printf', 'sprintf', 'disp', 'until',
|
28
|
+
'continue', 'pkg'
|
27
29
|
]);
|
28
30
|
|
29
31
|
|
@@ -59,7 +61,7 @@ CodeMirror.defineMode("octave", function() {
|
|
59
61
|
return 'comment';
|
60
62
|
}
|
61
63
|
|
62
|
-
if (stream.match(/^
|
64
|
+
if (stream.match(/^[%#]/)){
|
63
65
|
stream.skipToEnd();
|
64
66
|
return 'comment';
|
65
67
|
}
|
@@ -0,0 +1,204 @@
|
|
1
|
+
CodeMirror.defineMode("puppet", function () {
|
2
|
+
// Stores the words from the define method
|
3
|
+
var words = {};
|
4
|
+
// Taken, mostly, from the Puppet official variable standards regex
|
5
|
+
var variable_regex = /({)?([a-z][a-z0-9_]*)?((::[a-z][a-z0-9_]*)*::)?[a-zA-Z0-9_]+(})?/;
|
6
|
+
|
7
|
+
// Takes a string of words separated by spaces and adds them as
|
8
|
+
// keys with the value of the first argument 'style'
|
9
|
+
function define(style, string) {
|
10
|
+
var split = string.split(' ');
|
11
|
+
for (var i = 0; i < split.length; i++) {
|
12
|
+
words[split[i]] = style;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
// Takes commonly known puppet types/words and classifies them to a style
|
17
|
+
define('keyword', 'class define site node include import inherits');
|
18
|
+
define('keyword', 'case if else in and elsif default or');
|
19
|
+
define('atom', 'false true running present absent file directory undef');
|
20
|
+
define('builtin', 'action augeas burst chain computer cron destination dport exec ' +
|
21
|
+
'file filebucket group host icmp iniface interface jump k5login limit log_level ' +
|
22
|
+
'log_prefix macauthorization mailalias maillist mcx mount nagios_command ' +
|
23
|
+
'nagios_contact nagios_contactgroup nagios_host nagios_hostdependency ' +
|
24
|
+
'nagios_hostescalation nagios_hostextinfo nagios_hostgroup nagios_service ' +
|
25
|
+
'nagios_servicedependency nagios_serviceescalation nagios_serviceextinfo ' +
|
26
|
+
'nagios_servicegroup nagios_timeperiod name notify outiface package proto reject ' +
|
27
|
+
'resources router schedule scheduled_task selboolean selmodule service source ' +
|
28
|
+
'sport ssh_authorized_key sshkey stage state table tidy todest toports tosource ' +
|
29
|
+
'user vlan yumrepo zfs zone zpool');
|
30
|
+
|
31
|
+
// After finding a start of a string ('|") this function attempts to find the end;
|
32
|
+
// If a variable is encountered along the way, we display it differently when it
|
33
|
+
// is encapsulated in a double-quoted string.
|
34
|
+
function tokenString(stream, state) {
|
35
|
+
var current, prev, found_var = false;
|
36
|
+
while (!stream.eol() && (current = stream.next()) != state.pending) {
|
37
|
+
if (current === '$' && prev != '\\' && state.pending == '"') {
|
38
|
+
found_var = true;
|
39
|
+
break;
|
40
|
+
}
|
41
|
+
prev = current;
|
42
|
+
}
|
43
|
+
if (found_var) {
|
44
|
+
stream.backUp(1);
|
45
|
+
}
|
46
|
+
if (current == state.pending) {
|
47
|
+
state.continueString = false;
|
48
|
+
} else {
|
49
|
+
state.continueString = true;
|
50
|
+
}
|
51
|
+
return "string";
|
52
|
+
}
|
53
|
+
|
54
|
+
// Main function
|
55
|
+
function tokenize(stream, state) {
|
56
|
+
// Matches one whole word
|
57
|
+
var word = stream.match(/[\w]+/, false);
|
58
|
+
// Matches attributes (i.e. ensure => present ; 'ensure' would be matched)
|
59
|
+
var attribute = stream.match(/(\s+)?\w+\s+=>.*/, false);
|
60
|
+
// Matches non-builtin resource declarations
|
61
|
+
// (i.e. "apache::vhost {" or "mycustomclasss {" would be matched)
|
62
|
+
var resource = stream.match(/(\s+)?[\w:_]+(\s+)?{/, false);
|
63
|
+
// Matches virtual and exported resources (i.e. @@user { ; and the like)
|
64
|
+
var special_resource = stream.match(/(\s+)?[@]{1,2}[\w:_]+(\s+)?{/, false);
|
65
|
+
|
66
|
+
// Finally advance the stream
|
67
|
+
var ch = stream.next();
|
68
|
+
|
69
|
+
// Have we found a variable?
|
70
|
+
if (ch === '$') {
|
71
|
+
if (stream.match(variable_regex)) {
|
72
|
+
// If so, and its in a string, assign it a different color
|
73
|
+
return state.continueString ? 'variable-2' : 'variable';
|
74
|
+
}
|
75
|
+
// Otherwise return an invalid variable
|
76
|
+
return "error";
|
77
|
+
}
|
78
|
+
// Should we still be looking for the end of a string?
|
79
|
+
if (state.continueString) {
|
80
|
+
// If so, go through the loop again
|
81
|
+
stream.backUp(1);
|
82
|
+
return tokenString(stream, state);
|
83
|
+
}
|
84
|
+
// Are we in a definition (class, node, define)?
|
85
|
+
if (state.inDefinition) {
|
86
|
+
// If so, return def (i.e. for 'class myclass {' ; 'myclass' would be matched)
|
87
|
+
if (stream.match(/(\s+)?[\w:_]+(\s+)?/)) {
|
88
|
+
return 'def';
|
89
|
+
}
|
90
|
+
// Match the rest it the next time around
|
91
|
+
stream.match(/\s+{/);
|
92
|
+
state.inDefinition = false;
|
93
|
+
}
|
94
|
+
// Are we in an 'include' statement?
|
95
|
+
if (state.inInclude) {
|
96
|
+
// Match and return the included class
|
97
|
+
stream.match(/(\s+)?\S+(\s+)?/);
|
98
|
+
state.inInclude = false;
|
99
|
+
return 'def';
|
100
|
+
}
|
101
|
+
// Do we just have a function on our hands?
|
102
|
+
// In 'ensure_resource("myclass")', 'ensure_resource' is matched
|
103
|
+
if (stream.match(/(\s+)?\w+\(/)) {
|
104
|
+
stream.backUp(1);
|
105
|
+
return 'def';
|
106
|
+
}
|
107
|
+
// Have we matched the prior attribute regex?
|
108
|
+
if (attribute) {
|
109
|
+
stream.match(/(\s+)?\w+/);
|
110
|
+
return 'tag';
|
111
|
+
}
|
112
|
+
// Do we have Puppet specific words?
|
113
|
+
if (word && words.hasOwnProperty(word)) {
|
114
|
+
// Negates the initial next()
|
115
|
+
stream.backUp(1);
|
116
|
+
// Acutally move the stream
|
117
|
+
stream.match(/[\w]+/);
|
118
|
+
// We want to process these words differently
|
119
|
+
// do to the importance they have in Puppet
|
120
|
+
if (stream.match(/\s+\S+\s+{/, false)) {
|
121
|
+
state.inDefinition = true;
|
122
|
+
}
|
123
|
+
if (word == 'include') {
|
124
|
+
state.inInclude = true;
|
125
|
+
}
|
126
|
+
// Returns their value as state in the prior define methods
|
127
|
+
return words[word];
|
128
|
+
}
|
129
|
+
// Is there a match on a reference?
|
130
|
+
if (/(\s+)?[A-Z]/.test(word)) {
|
131
|
+
// Negate the next()
|
132
|
+
stream.backUp(1);
|
133
|
+
// Match the full reference
|
134
|
+
stream.match(/(\s+)?[A-Z][\w:_]+/);
|
135
|
+
return 'def';
|
136
|
+
}
|
137
|
+
// Have we matched the prior resource regex?
|
138
|
+
if (resource) {
|
139
|
+
stream.match(/(\s+)?[\w:_]+/);
|
140
|
+
return 'def';
|
141
|
+
}
|
142
|
+
// Have we matched the prior special_resource regex?
|
143
|
+
if (special_resource) {
|
144
|
+
stream.match(/(\s+)?[@]{1,2}/);
|
145
|
+
return 'special';
|
146
|
+
}
|
147
|
+
// Match all the comments. All of them.
|
148
|
+
if (ch == "#") {
|
149
|
+
stream.skipToEnd();
|
150
|
+
return "comment";
|
151
|
+
}
|
152
|
+
// Have we found a string?
|
153
|
+
if (ch == "'" || ch == '"') {
|
154
|
+
// Store the type (single or double)
|
155
|
+
state.pending = ch;
|
156
|
+
// Perform the looping function to find the end
|
157
|
+
return tokenString(stream, state);
|
158
|
+
}
|
159
|
+
// Match all the brackets
|
160
|
+
if (ch == '{' || ch == '}') {
|
161
|
+
return 'bracket';
|
162
|
+
}
|
163
|
+
// Match characters that we are going to assume
|
164
|
+
// are trying to be regex
|
165
|
+
if (ch == '/') {
|
166
|
+
stream.match(/.*\//);
|
167
|
+
return 'variable-3';
|
168
|
+
}
|
169
|
+
// Match all the numbers
|
170
|
+
if (ch.match(/[0-9]/)) {
|
171
|
+
stream.eatWhile(/[0-9]+/);
|
172
|
+
return 'number';
|
173
|
+
}
|
174
|
+
// Match the '=' and '=>' operators
|
175
|
+
if (ch == '=') {
|
176
|
+
if (stream.peek() == '>') {
|
177
|
+
stream.next();
|
178
|
+
}
|
179
|
+
return "operator";
|
180
|
+
}
|
181
|
+
// Keep advancing through all the rest
|
182
|
+
stream.eatWhile(/[\w-]/);
|
183
|
+
// Return a blank line for everything else
|
184
|
+
return null;
|
185
|
+
}
|
186
|
+
// Start it all
|
187
|
+
return {
|
188
|
+
startState: function () {
|
189
|
+
var state = {};
|
190
|
+
state.inDefinition = false;
|
191
|
+
state.inInclude = false;
|
192
|
+
state.continueString = false;
|
193
|
+
state.pending = false;
|
194
|
+
return state;
|
195
|
+
},
|
196
|
+
token: function (stream, state) {
|
197
|
+
// Strip the spaces, but regex will account for them eitherway
|
198
|
+
if (stream.eatSpace()) return null;
|
199
|
+
// Go through the main process
|
200
|
+
return tokenize(stream, state);
|
201
|
+
}
|
202
|
+
};
|
203
|
+
});
|
204
|
+
CodeMirror.defineMIME("text/x-puppet", "puppet");
|