codemirror-rails 3.19 → 3.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/lib/codemirror/rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/codemirror.js +61 -27
  4. data/vendor/assets/javascripts/codemirror/addons/dialog/dialog.js +42 -1
  5. data/vendor/assets/javascripts/codemirror/addons/display/fullscreen.js +2 -1
  6. data/vendor/assets/javascripts/codemirror/addons/display/placeholder.js +0 -6
  7. data/vendor/assets/javascripts/codemirror/addons/edit/closetag.js +13 -11
  8. data/vendor/assets/javascripts/codemirror/addons/edit/matchbrackets.js +2 -1
  9. data/vendor/assets/javascripts/codemirror/addons/fold/foldgutter.js +4 -4
  10. data/vendor/assets/javascripts/codemirror/addons/fold/indent-fold.js +25 -21
  11. data/vendor/assets/javascripts/codemirror/addons/hint/javascript-hint.js +1 -0
  12. data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +20 -8
  13. data/vendor/assets/javascripts/codemirror/addons/tern/tern.js +7 -7
  14. data/vendor/assets/javascripts/codemirror/keymaps/vim.js +3 -4
  15. data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +13 -8
  16. data/vendor/assets/javascripts/codemirror/modes/css.js +3 -3
  17. data/vendor/assets/javascripts/codemirror/modes/go.js +1 -1
  18. data/vendor/assets/javascripts/codemirror/modes/haskell.js +1 -1
  19. data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +1 -1
  20. data/vendor/assets/javascripts/codemirror/modes/javascript.js +216 -79
  21. data/vendor/assets/javascripts/codemirror/modes/julia.js +262 -0
  22. data/vendor/assets/javascripts/codemirror/modes/less.js +4 -2
  23. data/vendor/assets/javascripts/codemirror/modes/markdown.js +16 -7
  24. data/vendor/assets/javascripts/codemirror/modes/pegjs.js +103 -0
  25. data/vendor/assets/javascripts/codemirror/modes/pig.js +1 -1
  26. data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +1 -1
  27. data/vendor/assets/stylesheets/codemirror/themes/mbo.css +3 -1
  28. metadata +3 -1
@@ -0,0 +1,262 @@
1
+ CodeMirror.defineMode("julia", function(_conf, parserConf) {
2
+ var ERRORCLASS = 'error';
3
+
4
+ function wordRegexp(words) {
5
+ return new RegExp("^((" + words.join(")|(") + "))\\b");
6
+ }
7
+
8
+ var operators = parserConf.operators || /^(?:\.?[|&^\\%*+\-<>!=\/]=?|\?|~|:|\$|<:|\.[<>]|<<=?|>>>?=?|\.[<>=]=|->?|\/\/|\bin\b|\.{3})/;
9
+ var delimiters = parserConf.delimiters || /^[;,()[\]{}]/;
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"];
12
+ var blockClosers = ["end", "else", "elseif", "catch", "finally"];
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'];
15
+
16
+ //var stringPrefixes = new RegExp("^[br]?('|\")")
17
+ var stringPrefixes = /^[br]?('|"{3}|")/;
18
+ var keywords = wordRegexp(keywordList);
19
+ var builtins = wordRegexp(builtinList);
20
+ var openers = wordRegexp(blockOpeners);
21
+ var closers = wordRegexp(blockClosers);
22
+ var macro = /@[_A-Za-z][_A-Za-z0-9]*!*/;
23
+ var indentInfo = null;
24
+
25
+ function in_array(state) {
26
+ var ch = cur_scope(state);
27
+ if(ch=="[" || ch=="{") {
28
+ return true;
29
+ }
30
+ else {
31
+ return false;
32
+ }
33
+ }
34
+
35
+ function cur_scope(state) {
36
+ if(state.scopes.length==0) {
37
+ return null;
38
+ }
39
+ return state.scopes[state.scopes.length - 1];
40
+ }
41
+
42
+ // tokenizers
43
+ function tokenBase(stream, state) {
44
+ // Handle scope changes
45
+ var leaving_expr = state.leaving_expr;
46
+ state.leaving_expr = false;
47
+ if(leaving_expr) {
48
+ if(stream.match(/^'+/)) {
49
+ return 'operator';
50
+ }
51
+ if(stream.match("...")) {
52
+ return 'operator';
53
+ }
54
+ }
55
+
56
+ if (stream.eatSpace()) {
57
+ return null;
58
+ }
59
+
60
+ var ch = stream.peek();
61
+ // Handle Comments
62
+ if (ch === '#') {
63
+ stream.skipToEnd();
64
+ return 'comment';
65
+ }
66
+ if(ch==='[') {
67
+ state.scopes.push("[");
68
+ }
69
+
70
+ if(ch==='{') {
71
+ state.scopes.push("{");
72
+ }
73
+
74
+ var scope=cur_scope(state);
75
+
76
+ if(scope==='[' && ch===']') {
77
+ state.scopes.pop();
78
+ state.leaving_expr=true;
79
+ }
80
+
81
+ if(scope==='{' && ch==='}') {
82
+ state.scopes.pop();
83
+ state.leaving_expr=true;
84
+ }
85
+
86
+ var match;
87
+ if(match=stream.match(openers, false)) {
88
+ state.scopes.push(match);
89
+ }
90
+
91
+ if(!in_array(state) && stream.match(closers, false)) {
92
+ state.scopes.pop();
93
+ }
94
+
95
+ if(in_array(state)) {
96
+ if(stream.match("end")) {
97
+ return 'number';
98
+ }
99
+
100
+ }
101
+ if(stream.match("=>")) {
102
+ return 'operator';
103
+ }
104
+ // Handle Number Literals
105
+ if (stream.match(/^[0-9\.]/, false)) {
106
+ var imMatcher = RegExp(/^im\b/);
107
+ var floatLiteral = false;
108
+ // Floats
109
+ if (stream.match(/^\d*\.\d+([ef][\+\-]?\d+)?/i)) { floatLiteral = true; }
110
+ if (stream.match(/^\d+\.\d*/)) { floatLiteral = true; }
111
+ if (stream.match(/^\.\d+/)) { floatLiteral = true; }
112
+ if (floatLiteral) {
113
+ // Float literals may be "imaginary"
114
+ stream.match(imMatcher);
115
+ return 'number';
116
+ }
117
+ // Integers
118
+ var intLiteral = false;
119
+ // Hex
120
+ if (stream.match(/^0x[0-9a-f]+/i)) { intLiteral = true; }
121
+ // Binary
122
+ if (stream.match(/^0b[01]+/i)) { intLiteral = true; }
123
+ // Octal
124
+ if (stream.match(/^0o[0-7]+/i)) { intLiteral = true; }
125
+ // Decimal
126
+ 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
+ intLiteral = true;
131
+ }
132
+ // Zero by itself with no other piece of number.
133
+ if (stream.match(/^0(?![\dx])/i)) { intLiteral = true; }
134
+ if (intLiteral) {
135
+ // Integer literals may be "long"
136
+ stream.match(imMatcher);
137
+ return 'number';
138
+ }
139
+ }
140
+
141
+ // Handle Strings
142
+ if (stream.match(stringPrefixes)) {
143
+ state.tokenize = tokenStringFactory(stream.current());
144
+ return state.tokenize(stream, state);
145
+ }
146
+
147
+ // Handle operators and Delimiters
148
+ if (stream.match(operators)) {
149
+ return 'operator';
150
+ }
151
+
152
+ if (stream.match(delimiters)) {
153
+ return null;
154
+ }
155
+
156
+ if (stream.match(keywords)) {
157
+ return 'keyword';
158
+ }
159
+
160
+ if (stream.match(builtins)) {
161
+ return 'builtin';
162
+ }
163
+
164
+ if (stream.match(macro)) {
165
+ return 'meta';
166
+ }
167
+
168
+ if (stream.match(identifiers)) {
169
+ state.leaving_expr=true;
170
+ return 'variable';
171
+ }
172
+ // Handle non-detected items
173
+ stream.next();
174
+ return ERRORCLASS;
175
+ }
176
+
177
+ function tokenStringFactory(delimiter) {
178
+ while ('rub'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) {
179
+ delimiter = delimiter.substr(1);
180
+ }
181
+ var singleline = delimiter.length == 1;
182
+ var OUTCLASS = 'string';
183
+
184
+ function tokenString(stream, state) {
185
+ while (!stream.eol()) {
186
+ stream.eatWhile(/[^'"\\]/);
187
+ if (stream.eat('\\')) {
188
+ stream.next();
189
+ if (singleline && stream.eol()) {
190
+ return OUTCLASS;
191
+ }
192
+ } else if (stream.match(delimiter)) {
193
+ state.tokenize = tokenBase;
194
+ return OUTCLASS;
195
+ } else {
196
+ stream.eat(/['"]/);
197
+ }
198
+ }
199
+ if (singleline) {
200
+ if (parserConf.singleLineStringErrors) {
201
+ return ERRORCLASS;
202
+ } else {
203
+ state.tokenize = tokenBase;
204
+ }
205
+ }
206
+ return OUTCLASS;
207
+ }
208
+ tokenString.isString = true;
209
+ return tokenString;
210
+ }
211
+
212
+ function tokenLexer(stream, state) {
213
+ indentInfo = null;
214
+ var style = state.tokenize(stream, state);
215
+ var current = stream.current();
216
+
217
+ // Handle '.' connected identifiers
218
+ if (current === '.') {
219
+ style = stream.match(identifiers, false) ? null : ERRORCLASS;
220
+ if (style === null && state.lastStyle === 'meta') {
221
+ // Apply 'meta' style to '.' connected identifiers when
222
+ // appropriate.
223
+ style = 'meta';
224
+ }
225
+ return style;
226
+ }
227
+
228
+ return style;
229
+ }
230
+
231
+ var external = {
232
+ startState: function() {
233
+ return {
234
+ tokenize: tokenBase,
235
+ scopes: [],
236
+ leaving_expr: false
237
+ };
238
+ },
239
+
240
+ token: function(stream, state) {
241
+ var style = tokenLexer(stream, state);
242
+ state.lastStyle = style;
243
+ return style;
244
+ },
245
+
246
+ indent: function(state, textAfter) {
247
+ var delta = 0;
248
+ if(textAfter=="end" || textAfter=="]" || textAfter=="}" || textAfter=="else" || textAfter=="elseif" || textAfter=="catch" || textAfter=="finally") {
249
+ delta = -1;
250
+ }
251
+ return (state.scopes.length + delta) * 2;
252
+ },
253
+
254
+ lineComment: "#",
255
+ fold: "indent",
256
+ electricChars: "edlsifyh]}"
257
+ };
258
+ return external;
259
+ });
260
+
261
+
262
+ CodeMirror.defineMIME("text/x-julia", "julia");
@@ -70,7 +70,9 @@ CodeMirror.defineMode("less", function(config) {
70
70
  stream.eatWhile(/[\a-zA-Z0-9\-_]/);
71
71
  if(stream.peek() === " ")stream.eatSpace();
72
72
  if(stream.peek() === ")" || type === ":")return ret("number", "unit");//rgba(0,0,0,.25);
73
- else if(state.stack[state.stack.length-1] === "rule" && stream.peek().match(/{|,|\+|\(/) === null)return ret("number", "unit");
73
+ else if(stream.current().length >1){
74
+ if(state.stack[state.stack.length-1] === "rule" && stream.peek().match(/{|,|\+|\(/) === null)return ret("number", "unit");
75
+ }
74
76
  return ret("tag", "tag");
75
77
  } else if (ch == "#") {
76
78
  //we don't eat white-space, we want the hex color and or id only
@@ -204,7 +206,7 @@ CodeMirror.defineMode("less", function(config) {
204
206
  else if(type === "unit" && state.stack[state.stack.length-1] === "rule")return ret(null, "unit");
205
207
  else if(type === "unit" && state.stack[state.stack.length-1] === ";")return ret(null, "unit");
206
208
  else if(type === ")" && state.stack[state.stack.length-1] === "rule")return ret(null, "unit");
207
- else if(type.match("@") !== null && state.stack[state.stack.length-1] === "rule")return ret(null, "unit");
209
+ else if(type && type.match("@") !== null && state.stack[state.stack.length-1] === "rule")return ret(null, "unit");
208
210
  //else if(type === "unit" && state.stack[state.stack.length-1] === "rule")return ret(null, stream.current());
209
211
 
210
212
  else if((type === ";" || type === "}" || type === ",") && state.stack[state.stack.length-1] === ";")return ret("tag", stream.current());
@@ -74,7 +74,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
74
74
  , ulRE = /^[*\-+]\s+/
75
75
  , olRE = /^[0-9]+\.\s+/
76
76
  , taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
77
- , headerRE = /^(?:\={1,}|-{1,})$/
77
+ , atxHeaderRE = /^#+/
78
+ , setextHeaderRE = /^(?:\={1,}|-{1,})$/
78
79
  , textRE = /^[^!\[\]*_\\<>` "'(]+/;
79
80
 
80
81
  function switchInline(stream, state, f) {
@@ -127,14 +128,17 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
127
128
  state.listDepth = 0;
128
129
  }
129
130
 
131
+ var match = null;
130
132
  if (state.indentationDiff >= 4) {
131
133
  state.indentation -= 4;
132
134
  stream.skipToEnd();
133
135
  return code;
134
136
  } else if (stream.eatSpace()) {
135
137
  return null;
136
- } else if (stream.peek() === '#' || (state.prevLineHasContent && stream.match(headerRE)) ) {
137
- state.header = true;
138
+ } else if (match = stream.match(atxHeaderRE)) {
139
+ state.header = match[0].length <= 6 ? match[0].length : 6;
140
+ } else if (state.prevLineHasContent && (match = stream.match(setextHeaderRE))) {
141
+ state.header = match[0].charAt(0) == '=' ? 1 : 2;
138
142
  } else if (stream.eat('>')) {
139
143
  state.indentation++;
140
144
  state.quote = 1;
@@ -207,7 +211,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
207
211
 
208
212
  if (state.code) { styles.push(code); }
209
213
 
210
- if (state.header) { styles.push(header); }
214
+ if (state.header) { styles.push(header); styles.push(header + state.header); }
211
215
  if (state.quote) { styles.push(state.quote % 2 ? quote1 : quote2); }
212
216
  if (state.list !== false) {
213
217
  var listMod = (state.listDepth - 1) % 3;
@@ -257,6 +261,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
257
261
  state.taskOpen = false;
258
262
  state.taskClosed = false;
259
263
 
264
+ // Get sol() value now, before character is consumed
265
+ var sol = stream.sol();
266
+
260
267
  var ch = stream.next();
261
268
 
262
269
  if (ch === '\\') {
@@ -355,7 +362,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
355
362
  }
356
363
  var t = getType(state);
357
364
  if (ch === '*' || (ch === '_' && !ignoreUnderscore)) {
358
- if (state.strong === ch && stream.eat(ch)) { // Remove STRONG
365
+ if (sol && stream.peek() === ' ') {
366
+ // Do nothing, surrounded by newline and space
367
+ } else if (state.strong === ch && stream.eat(ch)) { // Remove STRONG
359
368
  state.strong = false;
360
369
  return t;
361
370
  } else if (!state.strong && stream.eat(ch)) { // Add STRONG
@@ -466,7 +475,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
466
475
  linkTitle: false,
467
476
  em: false,
468
477
  strong: false,
469
- header: false,
478
+ header: 0,
470
479
  taskList: false,
471
480
  list: false,
472
481
  listDepth: 0,
@@ -517,7 +526,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
517
526
  }
518
527
 
519
528
  // Reset state.header
520
- state.header = false;
529
+ state.header = 0;
521
530
 
522
531
  // Reset state.taskList
523
532
  state.taskList = false;
@@ -0,0 +1,103 @@
1
+ CodeMirror.defineMode("pegjs", function (config) {
2
+ var jsMode = CodeMirror.getMode(config, "javascript");
3
+
4
+ function identifier(stream) {
5
+ return stream.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);
6
+ }
7
+
8
+ return {
9
+ startState: function () {
10
+ return {
11
+ inString: false,
12
+ stringType: null,
13
+ inComment: false,
14
+ inChracterClass: false,
15
+ braced: 0,
16
+ lhs: true,
17
+ localState: null
18
+ };
19
+ },
20
+ token: function (stream, state) {
21
+ if (stream)
22
+
23
+ //check for state changes
24
+ if (!state.inString && !state.inComment && ((stream.peek() == '"') || (stream.peek() == "'"))) {
25
+ state.stringType = stream.peek();
26
+ stream.next(); // Skip quote
27
+ state.inString = true; // Update state
28
+ }
29
+ if (!state.inString && !state.inComment && stream.match(/^\/\*/)) {
30
+ state.inComment = true;
31
+ }
32
+
33
+ //return state
34
+ if (state.inString) {
35
+ while (state.inString && !stream.eol()) {
36
+ if (stream.peek() === state.stringType) {
37
+ stream.next(); // Skip quote
38
+ state.inString = false; // Clear flag
39
+ } else if (stream.peek() === '\\') {
40
+ stream.next();
41
+ stream.next();
42
+ } else {
43
+ stream.match(/^.[^\\\"\']*/);
44
+ }
45
+ }
46
+ return state.lhs ? "property string" : "string"; // Token style
47
+ } else if (state.inComment) {
48
+ while (state.inComment && !stream.eol()) {
49
+ if (stream.match(/\*\//)) {
50
+ state.inComment = false; // Clear flag
51
+ } else {
52
+ stream.match(/^.[^\*]*/);
53
+ }
54
+ }
55
+ return "comment";
56
+ } else if (state.inChracterClass) {
57
+ if (stream.match(/^[^\]\\]+/)) {
58
+ return;
59
+ } else if (stream.match(/^\\./)) {
60
+ return;
61
+ } else {
62
+ stream.next();
63
+ state.inChracterClass = false;
64
+ return 'bracket';
65
+ }
66
+ } else if (stream.peek() === '[') {
67
+ stream.next();
68
+ state.inChracterClass = true;
69
+ return 'bracket';
70
+ } else if (stream.match(/^\/\//)) {
71
+ stream.skipToEnd();
72
+ return "comment";
73
+ } else if (state.braced || stream.peek() === '{') {
74
+ if (state.localState === null) {
75
+ state.localState = jsMode.startState();
76
+ }
77
+ var token = jsMode.token(stream, state.localState);
78
+ var text = stream.current();
79
+ if (!token) {
80
+ for (var i = 0; i < text.length; i++) {
81
+ if (text[i] === '{') {
82
+ state.braced++;
83
+ } else if (text[i] === '}') {
84
+ state.braced--;
85
+ }
86
+ };
87
+ }
88
+ return token;
89
+ } else if (identifier(stream)) {
90
+ if (stream.peek() === ':') {
91
+ return 'variable';
92
+ }
93
+ return 'variable-2';
94
+ } else if (['[', ']', '(', ')'].indexOf(stream.peek()) != -1) {
95
+ stream.next();
96
+ return 'bracket';
97
+ } else if (!stream.eatSpace()) {
98
+ stream.next();
99
+ }
100
+ return null;
101
+ }
102
+ };
103
+ }, "javascript");