codemirror-rails 3.22 → 3.23

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.
@@ -191,6 +191,30 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
191
191
  return "meta";
192
192
  }
193
193
 
194
+ function cpp11StringHook(stream, state) {
195
+ stream.backUp(1);
196
+ // Raw strings.
197
+ if (stream.match(/(R|u8R|uR|UR|LR)/)) {
198
+ var match = stream.match(/"(.{0,16})\(/);
199
+ if (!match) {
200
+ return false;
201
+ }
202
+ state.cpp11RawStringDelim = match[1];
203
+ state.tokenize = tokenRawString;
204
+ return tokenRawString(stream, state);
205
+ }
206
+ // Unicode strings/chars.
207
+ if (stream.match(/(u8|u|U|L)/)) {
208
+ if (stream.match(/["']/, /* eat */ false)) {
209
+ return "string";
210
+ }
211
+ return false;
212
+ }
213
+ // Ignore this hook.
214
+ stream.next();
215
+ return false;
216
+ }
217
+
194
218
  // C#-style strings where "" escapes a quote.
195
219
  function tokenAtString(stream, state) {
196
220
  var next;
@@ -203,6 +227,19 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
203
227
  return "string";
204
228
  }
205
229
 
230
+ // C++11 raw string literal is <prefix>"<delim>( anything )<delim>", where
231
+ // <delim> can be a string up to 16 characters long.
232
+ function tokenRawString(stream, state) {
233
+ var closingSequence = new RegExp(".*?\\)" + state.cpp11RawStringDelim + '"');
234
+ var match = stream.match(closingSequence);
235
+ if (match) {
236
+ state.tokenize = null;
237
+ } else {
238
+ stream.skipToEnd();
239
+ }
240
+ return "string";
241
+ }
242
+
206
243
  function def(mimes, mode) {
207
244
  var words = [];
208
245
  function add(obj) {
@@ -235,10 +272,17 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
235
272
  keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
236
273
  "static_cast typeid catch operator template typename class friend private " +
237
274
  "this using const_cast inline public throw virtual delete mutable protected " +
238
- "wchar_t"),
275
+ "wchar_t alignas alignof constexpr decltype nullptr noexcept thread_local final " +
276
+ "static_assert override"),
239
277
  blockKeywords: words("catch class do else finally for if struct switch try while"),
240
278
  atoms: words("true false null"),
241
- hooks: {"#": cppHook},
279
+ hooks: {
280
+ "#": cppHook,
281
+ "u": cpp11StringHook,
282
+ "U": cpp11StringHook,
283
+ "L": cpp11StringHook,
284
+ "R": cpp11StringHook
285
+ },
242
286
  modeProps: {fold: ["brace", "include"]}
243
287
  });
244
288
  CodeMirror.defineMIME("text/x-java", {
@@ -8,6 +8,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
8
8
  mediaTypes = parserConfig.mediaTypes || {},
9
9
  mediaFeatures = parserConfig.mediaFeatures || {},
10
10
  propertyKeywords = parserConfig.propertyKeywords || {},
11
+ nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
11
12
  colorKeywords = parserConfig.colorKeywords || {},
12
13
  valueKeywords = parserConfig.valueKeywords || {},
13
14
  fontProperties = parserConfig.fontProperties || {},
@@ -162,9 +163,13 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
162
163
 
163
164
  states.block = function(type, stream, state) {
164
165
  if (type == "word") {
165
- if (propertyKeywords.hasOwnProperty(stream.current().toLowerCase())) {
166
+ var word = stream.current().toLowerCase();
167
+ if (propertyKeywords.hasOwnProperty(word)) {
166
168
  override = "property";
167
169
  return "maybeprop";
170
+ } else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
171
+ override = "string-2";
172
+ return "maybeprop";
168
173
  } else if (allowNested) {
169
174
  override = stream.match(/^\s*:/, false) ? "property" : "tag";
170
175
  return "block";
@@ -437,7 +442,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
437
442
  "vertical-align", "visibility", "voice-balance", "voice-duration",
438
443
  "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
439
444
  "voice-volume", "volume", "white-space", "widows", "width", "word-break",
440
- "word-spacing", "word-wrap", "z-index", "zoom",
445
+ "word-spacing", "word-wrap", "z-index",
441
446
  // SVG-specific
442
447
  "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
443
448
  "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
@@ -450,6 +455,14 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
450
455
  "glyph-orientation-vertical", "kerning", "text-anchor", "writing-mode"
451
456
  ], propertyKeywords = keySet(propertyKeywords_);
452
457
 
458
+ var nonStandardPropertyKeywords = [
459
+ "scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color",
460
+ "scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color",
461
+ "scrollbar-3d-light-color", "scrollbar-track-color", "shape-inside",
462
+ "searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button",
463
+ "searchfield-results-decoration", "zoom"
464
+ ], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords);
465
+
453
466
  var colorKeywords_ = [
454
467
  "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
455
468
  "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
@@ -569,7 +582,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
569
582
  "font-stretch", "font-weight", "font-style"
570
583
  ], fontProperties = keySet(fontProperties_);
571
584
 
572
- var allWords = mediaTypes_.concat(mediaFeatures_).concat(propertyKeywords_).concat(colorKeywords_).concat(valueKeywords_);
585
+ var allWords = mediaTypes_.concat(mediaFeatures_).concat(propertyKeywords_)
586
+ .concat(nonStandardPropertyKeywords).concat(colorKeywords_).concat(valueKeywords_);
573
587
  CodeMirror.registerHelper("hintWords", "css", allWords);
574
588
 
575
589
  function tokenCComment(stream, state) {
@@ -598,6 +612,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
598
612
  mediaTypes: mediaTypes,
599
613
  mediaFeatures: mediaFeatures,
600
614
  propertyKeywords: propertyKeywords,
615
+ nonStandardPropertyKeywords: nonStandardPropertyKeywords,
601
616
  colorKeywords: colorKeywords,
602
617
  valueKeywords: valueKeywords,
603
618
  fontProperties: fontProperties,
@@ -620,6 +635,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
620
635
  mediaTypes: mediaTypes,
621
636
  mediaFeatures: mediaFeatures,
622
637
  propertyKeywords: propertyKeywords,
638
+ nonStandardPropertyKeywords: nonStandardPropertyKeywords,
623
639
  colorKeywords: colorKeywords,
624
640
  valueKeywords: valueKeywords,
625
641
  fontProperties: fontProperties,
@@ -660,6 +676,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
660
676
  mediaTypes: mediaTypes,
661
677
  mediaFeatures: mediaFeatures,
662
678
  propertyKeywords: propertyKeywords,
679
+ nonStandardPropertyKeywords: nonStandardPropertyKeywords,
663
680
  colorKeywords: colorKeywords,
664
681
  valueKeywords: valueKeywords,
665
682
  fontProperties: fontProperties,
@@ -0,0 +1,284 @@
1
+ CodeMirror.defineMode("dylan", function(_config) {
2
+ // Words
3
+ var words = {
4
+ // Words that introduce unnamed definitions like "define interface"
5
+ unnamedDefinition: ["interface"],
6
+
7
+ // Words that introduce simple named definitions like "define library"
8
+ namedDefinition: ["module", "library", "macro",
9
+ "C-struct", "C-union",
10
+ "C-function", "C-callable-wrapper"
11
+ ],
12
+
13
+ // Words that introduce type definitions like "define class".
14
+ // These are also parameterized like "define method" and are
15
+ // appended to otherParameterizedDefinitionWords
16
+ typeParameterizedDefinition: ["class", "C-subtype", "C-mapped-subtype"],
17
+
18
+ // Words that introduce trickier definitions like "define method".
19
+ // These require special definitions to be added to startExpressions
20
+ otherParameterizedDefinition: ["method", "function",
21
+ "C-variable", "C-address"
22
+ ],
23
+
24
+ // Words that introduce module constant definitions.
25
+ // These must also be simple definitions and are
26
+ // appended to otherSimpleDefinitionWords
27
+ constantSimpleDefinition: ["constant"],
28
+
29
+ // Words that introduce module variable definitions.
30
+ // These must also be simple definitions and are
31
+ // appended to otherSimpleDefinitionWords
32
+ variableSimpleDefinition: ["variable"],
33
+
34
+ // Other words that introduce simple definitions
35
+ // (without implicit bodies).
36
+ otherSimpleDefinition: ["generic", "domain",
37
+ "C-pointer-type",
38
+ "table"
39
+ ],
40
+
41
+ // Words that begin statements with implicit bodies.
42
+ statement: ["if", "block", "begin", "method", "case",
43
+ "for", "select", "when", "unless", "until",
44
+ "while", "iterate", "profiling", "dynamic-bind"
45
+ ],
46
+
47
+ // Patterns that act as separators in compound statements.
48
+ // This may include any general pattern that must be indented
49
+ // specially.
50
+ separator: ["finally", "exception", "cleanup", "else",
51
+ "elseif", "afterwards"
52
+ ],
53
+
54
+ // Keywords that do not require special indentation handling,
55
+ // but which should be highlighted
56
+ other: ["above", "below", "by", "from", "handler", "in",
57
+ "instance", "let", "local", "otherwise", "slot",
58
+ "subclass", "then", "to", "keyed-by", "virtual"
59
+ ],
60
+
61
+ // Condition signaling function calls
62
+ signalingCalls: ["signal", "error", "cerror",
63
+ "break", "check-type", "abort"
64
+ ]
65
+ };
66
+
67
+ words["otherDefinition"] =
68
+ words["unnamedDefinition"]
69
+ .concat(words["namedDefinition"])
70
+ .concat(words["otherParameterizedDefinition"]);
71
+
72
+ words["definition"] =
73
+ words["typeParameterizedDefinition"]
74
+ .concat(words["otherDefinition"]);
75
+
76
+ words["parameterizedDefinition"] =
77
+ words["typeParameterizedDefinition"]
78
+ .concat(words["otherParameterizedDefinition"]);
79
+
80
+ words["simpleDefinition"] =
81
+ words["constantSimpleDefinition"]
82
+ .concat(words["variableSimpleDefinition"])
83
+ .concat(words["otherSimpleDefinition"]);
84
+
85
+ words["keyword"] =
86
+ words["statement"]
87
+ .concat(words["separator"])
88
+ .concat(words["other"]);
89
+
90
+ // Patterns
91
+ var symbolPattern = "[-_a-zA-Z?!*@<>$%]+";
92
+ var symbol = new RegExp("^" + symbolPattern);
93
+ var patterns = {
94
+ // Symbols with special syntax
95
+ symbolKeyword: symbolPattern + ":",
96
+ symbolClass: "<" + symbolPattern + ">",
97
+ symbolGlobal: "\\*" + symbolPattern + "\\*",
98
+ symbolConstant: "\\$" + symbolPattern
99
+ };
100
+ var patternStyles = {
101
+ symbolKeyword: "atom",
102
+ symbolClass: "tag",
103
+ symbolGlobal: "variable-2",
104
+ symbolConstant: "variable-3"
105
+ };
106
+
107
+ // Compile all patterns to regular expressions
108
+ for (var patternName in patterns)
109
+ if (patterns.hasOwnProperty(patternName))
110
+ patterns[patternName] = new RegExp("^" + patterns[patternName]);
111
+
112
+ // Names beginning "with-" and "without-" are commonly
113
+ // used as statement macro
114
+ patterns["keyword"] = [/^with(?:out)?-[-_a-zA-Z?!*@<>$%]+/];
115
+
116
+ var styles = {};
117
+ styles["keyword"] = "keyword";
118
+ styles["definition"] = "def";
119
+ styles["simpleDefinition"] = "def";
120
+ styles["signalingCalls"] = "builtin";
121
+
122
+ // protected words lookup table
123
+ var wordLookup = {};
124
+ var styleLookup = {};
125
+
126
+ [
127
+ "keyword",
128
+ "definition",
129
+ "simpleDefinition",
130
+ "signalingCalls"
131
+ ].forEach(function(type) {
132
+ words[type].forEach(function(word) {
133
+ wordLookup[word] = type;
134
+ styleLookup[word] = styles[type];
135
+ });
136
+ });
137
+
138
+
139
+ function chain(stream, state, f) {
140
+ state.tokenize = f;
141
+ return f(stream, state);
142
+ }
143
+
144
+ var type, content;
145
+
146
+ function ret(_type, style, _content) {
147
+ type = _type;
148
+ content = _content;
149
+ return style;
150
+ }
151
+
152
+ function tokenBase(stream, state) {
153
+ // String
154
+ var ch = stream.peek();
155
+ if (ch == "'" || ch == '"') {
156
+ stream.next();
157
+ return chain(stream, state, tokenString(ch, "string", "string"));
158
+ }
159
+ // Comment
160
+ else if (ch == "/") {
161
+ stream.next();
162
+ if (stream.eat("*")) {
163
+ return chain(stream, state, tokenComment);
164
+ } else if (stream.eat("/")) {
165
+ stream.skipToEnd();
166
+ return ret("comment", "comment");
167
+ } else {
168
+ stream.skipTo(" ");
169
+ return ret("operator", "operator");
170
+ }
171
+ }
172
+ // Decimal
173
+ else if (/\d/.test(ch)) {
174
+ stream.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/);
175
+ return ret("number", "number");
176
+ }
177
+ // Hash
178
+ else if (ch == "#") {
179
+ stream.next();
180
+ // Symbol with string syntax
181
+ ch = stream.peek();
182
+ if (ch == '"') {
183
+ stream.next();
184
+ return chain(stream, state, tokenString('"', "symbol", "string-2"));
185
+ }
186
+ // Binary number
187
+ else if (ch == "b") {
188
+ stream.next();
189
+ stream.eatWhile(/[01]/);
190
+ return ret("number", "number");
191
+ }
192
+ // Hex number
193
+ else if (ch == "x") {
194
+ stream.next();
195
+ stream.eatWhile(/[\da-f]/i);
196
+ return ret("number", "number");
197
+ }
198
+ // Octal number
199
+ else if (ch == "o") {
200
+ stream.next();
201
+ stream.eatWhile(/[0-7]/);
202
+ return ret("number", "number");
203
+ }
204
+ // Hash symbol
205
+ else {
206
+ stream.eatWhile(/[-a-zA-Z]/);
207
+ return ret("hash", "keyword");
208
+ }
209
+ } else if (stream.match("end")) {
210
+ return ret("end", "keyword");
211
+ }
212
+ for (var name in patterns) {
213
+ if (patterns.hasOwnProperty(name)) {
214
+ var pattern = patterns[name];
215
+ if ((pattern instanceof Array && pattern.some(function(p) {
216
+ return stream.match(p);
217
+ })) || stream.match(pattern))
218
+ return ret(name, patternStyles[name], stream.current());
219
+ }
220
+ }
221
+ if (stream.match("define")) {
222
+ return ret("definition", "def");
223
+ } else {
224
+ stream.eatWhile(/[\w\-]/);
225
+ // Keyword
226
+ if (wordLookup[stream.current()]) {
227
+ return ret(wordLookup[stream.current()], styleLookup[stream.current()], stream.current());
228
+ } else if (stream.current().match(symbol)) {
229
+ return ret("variable", "variable");
230
+ } else {
231
+ stream.next();
232
+ return ret("other", "variable-2");
233
+ }
234
+ }
235
+ }
236
+
237
+ function tokenComment(stream, state) {
238
+ var maybeEnd = false,
239
+ ch;
240
+ while ((ch = stream.next())) {
241
+ if (ch == "/" && maybeEnd) {
242
+ state.tokenize = tokenBase;
243
+ break;
244
+ }
245
+ maybeEnd = (ch == "*");
246
+ }
247
+ return ret("comment", "comment");
248
+ }
249
+
250
+ function tokenString(quote, type, style) {
251
+ return function(stream, state) {
252
+ var next, end = false;
253
+ while ((next = stream.next()) != null) {
254
+ if (next == quote) {
255
+ end = true;
256
+ break;
257
+ }
258
+ }
259
+ if (end)
260
+ state.tokenize = tokenBase;
261
+ return ret(type, style);
262
+ };
263
+ }
264
+
265
+ // Interface
266
+ return {
267
+ startState: function() {
268
+ return {
269
+ tokenize: tokenBase,
270
+ currentIndent: 0
271
+ };
272
+ },
273
+ token: function(stream, state) {
274
+ if (stream.eatSpace())
275
+ return null;
276
+ var style = state.tokenize(stream, state);
277
+ return style;
278
+ },
279
+ blockCommentStart: "/*",
280
+ blockCommentEnd: "*/"
281
+ };
282
+ });
283
+
284
+ CodeMirror.defineMIME("text/x-dylan", "dylan");
@@ -345,7 +345,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
345
345
 
346
346
  var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
347
347
  if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
348
- if (type == "function") return cont(functiondef);
348
+ if (type == "function") return cont(functiondef, maybeop);
349
349
  if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
350
350
  if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop);
351
351
  if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
@@ -571,7 +571,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
571
571
  context: parserConfig.localVars && {vars: parserConfig.localVars},
572
572
  indented: 0
573
573
  };
574
- if (parserConfig.globalVars) state.globalVars = parserConfig.globalVars;
574
+ if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
575
+ state.globalVars = parserConfig.globalVars;
575
576
  return state;
576
577
  },
577
578