codemirror-rails 5.3 → 5.4

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 +26 -36
  4. data/vendor/assets/javascripts/codemirror/addons/edit/continuelist.js +4 -4
  5. data/vendor/assets/javascripts/codemirror/addons/hint/sql-hint.js +3 -3
  6. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +69 -11
  7. data/vendor/assets/javascripts/codemirror/addons/tern/tern.js +4 -2
  8. data/vendor/assets/javascripts/codemirror/keymaps/vim.js +24 -3
  9. data/vendor/assets/javascripts/codemirror/modes/clike.js +60 -25
  10. data/vendor/assets/javascripts/codemirror/modes/elm.js +205 -0
  11. data/vendor/assets/javascripts/codemirror/modes/factor.js +83 -0
  12. data/vendor/assets/javascripts/codemirror/modes/groovy.js +8 -5
  13. data/vendor/assets/javascripts/codemirror/modes/javascript.js +5 -2
  14. data/vendor/assets/javascripts/codemirror/modes/kotlin.js +5 -2
  15. data/vendor/assets/javascripts/codemirror/modes/markdown.js +37 -23
  16. data/vendor/assets/javascripts/codemirror/modes/php.js +20 -17
  17. data/vendor/assets/javascripts/codemirror/modes/python.js +1 -1
  18. data/vendor/assets/javascripts/codemirror/modes/swift.js +203 -0
  19. data/vendor/assets/javascripts/codemirror/modes/twig.js +132 -0
  20. data/vendor/assets/javascripts/codemirror/modes/vb.js +2 -1
  21. data/vendor/assets/stylesheets/codemirror.css +9 -9
  22. data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +3 -2
  23. data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +1 -1
  24. data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +2 -2
  25. data/vendor/assets/stylesheets/codemirror/themes/monokai.css +1 -0
  26. data/vendor/assets/stylesheets/codemirror/themes/solarized.css +2 -2
  27. data/vendor/assets/stylesheets/codemirror/themes/ttcn.css +9 -10
  28. metadata +6 -2
@@ -17,31 +17,31 @@
17
17
  return obj;
18
18
  }
19
19
 
20
- // Helper for stringWithEscapes
21
- function matchSequence(list, end) {
22
- if (list.length == 0) return stringWithEscapes(end);
20
+ // Helper for phpString
21
+ function matchSequence(list, end, escapes) {
22
+ if (list.length == 0) return phpString(end);
23
23
  return function (stream, state) {
24
24
  var patterns = list[0];
25
25
  for (var i = 0; i < patterns.length; i++) if (stream.match(patterns[i][0])) {
26
26
  state.tokenize = matchSequence(list.slice(1), end);
27
27
  return patterns[i][1];
28
28
  }
29
- state.tokenize = stringWithEscapes(end);
29
+ state.tokenize = phpString(end, escapes);
30
30
  return "string";
31
31
  };
32
32
  }
33
- function stringWithEscapes(closing) {
34
- return function(stream, state) { return stringWithEscapes_(stream, state, closing); };
33
+ function phpString(closing, escapes) {
34
+ return function(stream, state) { return phpString_(stream, state, closing, escapes); };
35
35
  }
36
- function stringWithEscapes_(stream, state, closing) {
36
+ function phpString_(stream, state, closing, escapes) {
37
37
  // "Complex" syntax
38
- if (stream.match("${", false) || stream.match("{$", false)) {
38
+ if (escapes !== false && stream.match("${", false) || stream.match("{$", false)) {
39
39
  state.tokenize = null;
40
40
  return "string";
41
41
  }
42
42
 
43
43
  // Simple syntax
44
- if (stream.match(/^\$[a-zA-Z_][a-zA-Z0-9_]*/)) {
44
+ if (escapes !== false && stream.match(/^\$[a-zA-Z_][a-zA-Z0-9_]*/)) {
45
45
  // After the variable name there may appear array or object operator.
46
46
  if (stream.match("[", false)) {
47
47
  // Match array operator
@@ -51,14 +51,14 @@
51
51
  [/\$[a-zA-Z_][a-zA-Z0-9_]*/, "variable-2"],
52
52
  [/[\w\$]+/, "variable"]],
53
53
  [["]", null]]
54
- ], closing);
54
+ ], closing, escapes);
55
55
  }
56
56
  if (stream.match(/\-\>\w/, false)) {
57
57
  // Match object operator
58
58
  state.tokenize = matchSequence([
59
59
  [["->", null]],
60
60
  [[/[\w]+/, "variable"]]
61
- ], closing);
61
+ ], closing, escapes);
62
62
  }
63
63
  return "variable-2";
64
64
  }
@@ -66,8 +66,9 @@
66
66
  var escaped = false;
67
67
  // Normal string
68
68
  while (!stream.eol() &&
69
- (escaped || (!stream.match("{$", false) &&
70
- !stream.match(/^(\$[a-zA-Z_][a-zA-Z0-9_]*|\$\{)/, false)))) {
69
+ (escaped || escapes === false ||
70
+ (!stream.match("{$", false) &&
71
+ !stream.match(/^(\$[a-zA-Z_][a-zA-Z0-9_]*|\$\{)/, false)))) {
71
72
  if (!escaped && stream.match(closing)) {
72
73
  state.tokenize = null;
73
74
  state.tokStack.pop(); state.tokStack.pop();
@@ -105,11 +106,13 @@
105
106
  },
106
107
  "<": function(stream, state) {
107
108
  if (stream.match(/<</)) {
109
+ var nowDoc = stream.eat("'");
108
110
  stream.eatWhile(/[\w\.]/);
109
- var delim = stream.current().slice(3);
111
+ var delim = stream.current().slice(3 + (nowDoc ? 1 : 0));
112
+ if (nowDoc) stream.eat("'");
110
113
  if (delim) {
111
114
  (state.tokStack || (state.tokStack = [])).push(delim, 0);
112
- state.tokenize = stringWithEscapes(delim);
115
+ state.tokenize = phpString(delim, nowDoc ? false : true);
113
116
  return "string";
114
117
  }
115
118
  }
@@ -128,7 +131,7 @@
128
131
  },
129
132
  '"': function(_stream, state) {
130
133
  (state.tokStack || (state.tokStack = [])).push('"', 0);
131
- state.tokenize = stringWithEscapes('"');
134
+ state.tokenize = phpString('"');
132
135
  return "string";
133
136
  },
134
137
  "{": function(_stream, state) {
@@ -139,7 +142,7 @@
139
142
  "}": function(_stream, state) {
140
143
  if (state.tokStack && state.tokStack.length > 0 &&
141
144
  !--state.tokStack[state.tokStack.length - 1]) {
142
- state.tokenize = stringWithEscapes(state.tokStack[state.tokStack.length - 2]);
145
+ state.tokenize = phpString(state.tokStack[state.tokStack.length - 2]);
143
146
  }
144
147
  return false;
145
148
  }
@@ -37,7 +37,7 @@
37
37
  "unichr", "unicode", "xrange", "False", "True", "None"],
38
38
  keywords: ["exec", "print"]};
39
39
  var py3 = {builtins: ["ascii", "bytes", "exec", "print"],
40
- keywords: ["nonlocal", "False", "True", "None"]};
40
+ keywords: ["nonlocal", "False", "True", "None", "async", "await"]};
41
41
 
42
42
  CodeMirror.registerHelper("hintWords", "python", commonKeywords.concat(commonBuiltins));
43
43
 
@@ -0,0 +1,203 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ // Swift mode created by Michael Kaminsky https://github.com/mkaminsky11
5
+
6
+ (function(mod) {
7
+ if (typeof exports == "object" && typeof module == "object")
8
+ mod(require("../../lib/codemirror"))
9
+ else if (typeof define == "function" && define.amd)
10
+ define(["../../lib/codemirror"], mod)
11
+ else
12
+ mod(CodeMirror)
13
+ })(function(CodeMirror) {
14
+ "use strict"
15
+
16
+ function trim(str) { return /^\s*(.*?)\s*$/.exec(str)[1] }
17
+
18
+ var separators = [" ","\\\+","\\\-","\\\(","\\\)","\\\*","/",":","\\\?","\\\<","\\\>"," ","\\\."]
19
+ var tokens = new RegExp(separators.join("|"),"g")
20
+
21
+ function getWord(string, pos) {
22
+ var index = -1, count = 1
23
+ var words = string.split(tokens)
24
+ for (var i = 0; i < words.length; i++) {
25
+ for(var j = 1; j <= words[i].length; j++) {
26
+ if (count==pos) index = i
27
+ count++
28
+ }
29
+ count++
30
+ }
31
+ var ret = ["", ""]
32
+ if (pos == 0) {
33
+ ret[1] = words[0]
34
+ ret[0] = null
35
+ } else {
36
+ ret[1] = words[index]
37
+ ret[0] = words[index-1]
38
+ }
39
+ return ret
40
+ }
41
+
42
+ CodeMirror.defineMode("swift", function() {
43
+ var keywords=["var","let","class","deinit","enum","extension","func","import","init","let","protocol","static","struct","subscript","typealias","var","as","dynamicType","is","new","super","self","Self","Type","__COLUMN__","__FILE__","__FUNCTION__","__LINE__","break","case","continue","default","do","else","fallthrough","if","in","for","return","switch","where","while","associativity","didSet","get","infix","inout","left","mutating","none","nonmutating","operator","override","postfix","precedence","prefix","right","set","unowned","unowned(safe)","unowned(unsafe)","weak","willSet"]
44
+ var commonConstants=["Infinity","NaN","undefined","null","true","false","on","off","yes","no","nil","null","this","super"]
45
+ var types=["String","bool","int","string","double","Double","Int","Float","float","public","private","extension"]
46
+ var numbers=["0","1","2","3","4","5","6","7","8","9"]
47
+ var operators=["+","-","/","*","%","=","|","&","<",">"]
48
+ var punc=[";",",",".","(",")","{","}","[","]"]
49
+ var delimiters=/^(?:[()\[\]{},:`=;]|\.\.?\.?)/
50
+ var identifiers=/^[_A-Za-z$][_A-Za-z$0-9]*/
51
+ var properties=/^(@|this\.)[_A-Za-z$][_A-Za-z$0-9]*/
52
+ var regexPrefixes=/^(\/{3}|\/)/
53
+
54
+ return {
55
+ startState: function() {
56
+ return {
57
+ prev: false,
58
+ string: false,
59
+ escape: false,
60
+ inner: false,
61
+ comment: false,
62
+ num_left: 0,
63
+ num_right: 0,
64
+ doubleString: false,
65
+ singleString: false
66
+ }
67
+ },
68
+ token: function(stream, state) {
69
+ if (stream.eatSpace()) return null
70
+
71
+ var ch = stream.next()
72
+ if (state.string) {
73
+ if (state.escape) {
74
+ state.escape = false
75
+ return "string"
76
+ } else {
77
+ if ((ch == "\"" && (state.doubleString && !state.singleString) ||
78
+ (ch == "'" && (!state.doubleString && state.singleString))) &&
79
+ !state.escape) {
80
+ state.string = false
81
+ state.doubleString = false
82
+ state.singleString = false
83
+ return "string"
84
+ } else if (ch == "\\" && stream.peek() == "(") {
85
+ state.inner = true
86
+ state.string = false
87
+ return "keyword"
88
+ } else if (ch == "\\" && stream.peek() != "(") {
89
+ state.escape = true
90
+ state.string = true
91
+ return "string"
92
+ } else {
93
+ return "string"
94
+ }
95
+ }
96
+ } else if (state.comment) {
97
+ if (ch == "*" && stream.peek() == "/") {
98
+ state.prev = "*"
99
+ return "comment"
100
+ } else if (ch == "/" && state.prev == "*") {
101
+ state.prev = false
102
+ state.comment = false
103
+ return "comment"
104
+ }
105
+ return "comment"
106
+ } else {
107
+ if (ch == "/") {
108
+ if (stream.peek() == "/") {
109
+ stream.skipToEnd()
110
+ return "comment"
111
+ }
112
+ if (stream.peek() == "*") {
113
+ state.comment = true
114
+ return "comment"
115
+ }
116
+ }
117
+ if (ch == "(" && state.inner) {
118
+ state.num_left++
119
+ return null
120
+ }
121
+ if (ch == ")" && state.inner) {
122
+ state.num_right++
123
+ if (state.num_left == state.num_right) {
124
+ state.inner=false
125
+ state.string=true
126
+ }
127
+ return null
128
+ }
129
+
130
+ var ret = getWord(stream.string, stream.pos)
131
+ var the_word = ret[1]
132
+ var prev_word = ret[0]
133
+
134
+ if (operators.indexOf(ch + "") > -1) return "operator"
135
+ if (punc.indexOf(ch) > -1) return "punctuation"
136
+
137
+ if (typeof the_word != "undefined") {
138
+ the_word = trim(the_word)
139
+ if (typeof prev_word != "undefined") prev_word = trim(prev_word)
140
+ if (the_word.charAt(0) == "#") return null
141
+
142
+ if (types.indexOf(the_word) > -1) return "def"
143
+ if (commonConstants.indexOf(the_word) > -1) return "atom"
144
+ if (numbers.indexOf(the_word) > -1) return "number"
145
+
146
+ if ((numbers.indexOf(the_word.charAt(0) + "") > -1 ||
147
+ operators.indexOf(the_word.charAt(0) + "") > -1) &&
148
+ numbers.indexOf(ch) > -1) {
149
+ return "number"
150
+ }
151
+
152
+ if (keywords.indexOf(the_word) > -1 ||
153
+ keywords.indexOf(the_word.split(tokens)[0]) > -1)
154
+ return "keyword"
155
+ if (keywords.indexOf(prev_word) > -1) return "def"
156
+ }
157
+ if (ch == '"' && !state.doubleString) {
158
+ state.string = true
159
+ state.doubleString = true
160
+ return "string"
161
+ }
162
+ if (ch == "'" && !state.singleString) {
163
+ state.string = true
164
+ state.singleString = true
165
+ return "string"
166
+ }
167
+ if (ch == "(" && state.inner)
168
+ state.num_left++
169
+ if (ch == ")" && state.inner) {
170
+ state.num_right++
171
+ if (state.num_left == state.num_right) {
172
+ state.inner = false
173
+ state.string = true
174
+ }
175
+ return null
176
+ }
177
+ if (stream.match(/^-?[0-9\.]/, false)) {
178
+ if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i) ||
179
+ stream.match(/^-?\d+\.\d*/) ||
180
+ stream.match(/^-?\.\d+/)) {
181
+ if (stream.peek() == ".") stream.backUp(1)
182
+ return "number"
183
+ }
184
+ if (stream.match(/^-?0x[0-9a-f]+/i) ||
185
+ stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/) ||
186
+ stream.match(/^-?0(?![\dx])/i))
187
+ return "number"
188
+ }
189
+ if (stream.match(regexPrefixes)) {
190
+ if (stream.current()!="/" || stream.match(/^.*\//,false)) return "string"
191
+ else stream.backUp(1)
192
+ }
193
+ if (stream.match(delimiters)) return "punctuation"
194
+ if (stream.match(identifiers)) return "variable"
195
+ if (stream.match(properties)) return "property"
196
+ return "variable"
197
+ }
198
+ }
199
+ }
200
+ })
201
+
202
+ CodeMirror.defineMIME("text/x-swift","swift")
203
+ })
@@ -0,0 +1,132 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ (function(mod) {
5
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
6
+ mod(require("../../lib/codemirror"));
7
+ else if (typeof define == "function" && define.amd) // AMD
8
+ define(["../../lib/codemirror"], mod);
9
+ else // Plain browser env
10
+ mod(CodeMirror);
11
+ })(function(CodeMirror) {
12
+ "use strict";
13
+
14
+ CodeMirror.defineMode("twig", function() {
15
+ var keywords = ["and", "as", "autoescape", "endautoescape", "block", "do", "endblock", "else", "elseif", "extends", "for", "endfor", "embed", "endembed", "filter", "endfilter", "flush", "from", "if", "endif", "in", "is", "include", "import", "not", "or", "set", "spaceless", "endspaceless", "with", "endwith", "trans", "endtrans", "blocktrans", "endblocktrans", "macro", "endmacro", "use", "verbatim", "endverbatim"],
16
+ operator = /^[+\-*&%=<>!?|~^]/,
17
+ sign = /^[:\[\(\{]/,
18
+ atom = ["true", "false", "null", "empty", "defined", "divisibleby", "divisible by", "even", "odd", "iterable", "sameas", "same as"],
19
+ number = /^(\d[+\-\*\/])?\d+(\.\d+)?/;
20
+
21
+ keywords = new RegExp("((" + keywords.join(")|(") + "))\\b");
22
+ atom = new RegExp("((" + atom.join(")|(") + "))\\b");
23
+
24
+ function tokenBase (stream, state) {
25
+ var ch = stream.peek();
26
+
27
+ //Comment
28
+ if (state.incomment) {
29
+ if (!stream.skipTo("#}")) {
30
+ stream.skipToEnd();
31
+ } else {
32
+ stream.eatWhile(/\#|}/);
33
+ state.incomment = false;
34
+ }
35
+ return "comment";
36
+ //Tag
37
+ } else if (state.intag) {
38
+ //After operator
39
+ if (state.operator) {
40
+ state.operator = false;
41
+ if (stream.match(atom)) {
42
+ return "atom";
43
+ }
44
+ if (stream.match(number)) {
45
+ return "number";
46
+ }
47
+ }
48
+ //After sign
49
+ if (state.sign) {
50
+ state.sign = false;
51
+ if (stream.match(atom)) {
52
+ return "atom";
53
+ }
54
+ if (stream.match(number)) {
55
+ return "number";
56
+ }
57
+ }
58
+
59
+ if (state.instring) {
60
+ if (ch == state.instring) {
61
+ state.instring = false;
62
+ }
63
+ stream.next();
64
+ return "string";
65
+ } else if (ch == "'" || ch == '"') {
66
+ state.instring = ch;
67
+ stream.next();
68
+ return "string";
69
+ } else if (stream.match(state.intag + "}") || stream.eat("-") && stream.match(state.intag + "}")) {
70
+ state.intag = false;
71
+ return "tag";
72
+ } else if (stream.match(operator)) {
73
+ state.operator = true;
74
+ return "operator";
75
+ } else if (stream.match(sign)) {
76
+ state.sign = true;
77
+ } else {
78
+ if (stream.eat(" ") || stream.sol()) {
79
+ if (stream.match(keywords)) {
80
+ return "keyword";
81
+ }
82
+ if (stream.match(atom)) {
83
+ return "atom";
84
+ }
85
+ if (stream.match(number)) {
86
+ return "number";
87
+ }
88
+ if (stream.sol()) {
89
+ stream.next();
90
+ }
91
+ } else {
92
+ stream.next();
93
+ }
94
+
95
+ }
96
+ return "variable";
97
+ } else if (stream.eat("{")) {
98
+ if (ch = stream.eat("#")) {
99
+ state.incomment = true;
100
+ if (!stream.skipTo("#}")) {
101
+ stream.skipToEnd();
102
+ } else {
103
+ stream.eatWhile(/\#|}/);
104
+ state.incomment = false;
105
+ }
106
+ return "comment";
107
+ //Open tag
108
+ } else if (ch = stream.eat(/\{|%/)) {
109
+ //Cache close tag
110
+ state.intag = ch;
111
+ if (ch == "{") {
112
+ state.intag = "}";
113
+ }
114
+ stream.eat("-");
115
+ return "tag";
116
+ }
117
+ }
118
+ stream.next();
119
+ };
120
+
121
+ return {
122
+ startState: function () {
123
+ return {};
124
+ },
125
+ token: function (stream, state) {
126
+ return tokenBase(stream, state);
127
+ }
128
+ };
129
+ });
130
+
131
+ CodeMirror.defineMIME("text/x-twig", "twig");
132
+ });
@@ -264,8 +264,9 @@ CodeMirror.defineMode("vb", function(conf, parserConf) {
264
264
  if (trueText.match(closing) || trueText.match(doubleClosing) || trueText.match(middle)) return conf.indentUnit*(state.currentIndent-1);
265
265
  if(state.currentIndent < 0) return 0;
266
266
  return state.currentIndent * conf.indentUnit;
267
- }
267
+ },
268
268
 
269
+ lineComment: "'"
269
270
  };
270
271
  return external;
271
272
  });