codemirror-rails 3.02 → 3.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/codemirror-rails.gemspec +1 -0
- data/doc/CodeMirror-LICENSE +5 -1
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror/{utils → addons/dialog}/dialog.js +4 -0
- data/vendor/assets/javascripts/codemirror/addons/display/placeholder.js +54 -0
- data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +54 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/edit}/closetag.js +9 -8
- data/vendor/assets/javascripts/codemirror/{utils → addons/edit}/continuecomment.js +12 -4
- data/vendor/assets/javascripts/codemirror/addons/edit/continuelist.js +25 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/edit}/matchbrackets.js +30 -11
- data/vendor/assets/javascripts/codemirror/addons/fold/brace-fold.js +31 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/foldcode.js +32 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/indent-fold.js +11 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/xml-fold.js +64 -0
- data/vendor/assets/javascripts/codemirror/addons/hint/html-hint.js +582 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/javascript-hint.js +15 -11
- data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/pig-hint.js +19 -19
- data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/python-hint.js +2 -2
- data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +180 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/xml-hint.js +5 -18
- data/vendor/assets/javascripts/codemirror/addons/lint/javascript-lint.js +127 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/json-lint.js +14 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +197 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/mode}/loadmode.js +0 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/mode}/multiplex.js +2 -2
- data/vendor/assets/javascripts/codemirror/{utils → addons/mode}/overlay.js +2 -2
- data/vendor/assets/javascripts/codemirror/{utils → addons/runmode}/colorize.js +0 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/runmode}/runmode-standalone.js +2 -3
- data/vendor/assets/javascripts/codemirror/{utils → addons/runmode}/runmode.js +0 -0
- data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +89 -0
- data/vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js +60 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/search}/search.js +5 -5
- data/vendor/assets/javascripts/codemirror/{utils → addons/search}/searchcursor.js +37 -30
- data/vendor/assets/javascripts/codemirror/addons/selection/active-line.js +39 -0
- data/vendor/assets/javascripts/codemirror/addons/selection/mark-selection.js +34 -0
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +721 -188
- data/vendor/assets/javascripts/codemirror/modes/asterisk.js +6 -6
- data/vendor/assets/javascripts/codemirror/modes/clike.js +14 -14
- data/vendor/assets/javascripts/codemirror/modes/clojure.js +23 -7
- data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/css.js +337 -235
- data/vendor/assets/javascripts/codemirror/modes/ecl.js +12 -12
- data/vendor/assets/javascripts/codemirror/modes/erlang.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/gas.js +326 -0
- data/vendor/assets/javascripts/codemirror/modes/gfm.js +1 -0
- data/vendor/assets/javascripts/codemirror/modes/haskell.js +26 -26
- data/vendor/assets/javascripts/codemirror/modes/haxe.js +17 -17
- data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +6 -6
- data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +43 -23
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +78 -33
- data/vendor/assets/javascripts/codemirror/modes/jinja2.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/less.js +38 -38
- data/vendor/assets/javascripts/codemirror/modes/livescript.js +267 -0
- data/vendor/assets/javascripts/codemirror/modes/lua.js +7 -7
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +108 -57
- data/vendor/assets/javascripts/codemirror/modes/mirc.js +177 -0
- data/vendor/assets/javascripts/codemirror/modes/ntriples.js +22 -22
- data/vendor/assets/javascripts/codemirror/modes/ocaml.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/perl.js +791 -791
- data/vendor/assets/javascripts/codemirror/modes/php.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/pig.js +163 -163
- data/vendor/assets/javascripts/codemirror/modes/python.js +31 -31
- data/vendor/assets/javascripts/codemirror/modes/q.js +124 -0
- data/vendor/assets/javascripts/codemirror/modes/rst.js +486 -250
- data/vendor/assets/javascripts/codemirror/modes/sass.js +3 -3
- data/vendor/assets/javascripts/codemirror/modes/scss_test.js +80 -0
- data/vendor/assets/javascripts/codemirror/modes/shell.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/sieve.js +10 -10
- data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +129 -129
- data/vendor/assets/javascripts/codemirror/modes/smarty.js +3 -3
- data/vendor/assets/javascripts/codemirror/modes/sparql.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/sql.js +23 -23
- data/vendor/assets/javascripts/codemirror/modes/stex.js +192 -121
- data/vendor/assets/javascripts/codemirror/modes/tcl.js +131 -0
- data/vendor/assets/javascripts/codemirror/modes/test.js +64 -0
- data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +345 -345
- data/vendor/assets/javascripts/codemirror/modes/tiki.js +297 -298
- data/vendor/assets/javascripts/codemirror/modes/turtle.js +145 -0
- data/vendor/assets/javascripts/codemirror/modes/vb.js +31 -32
- data/vendor/assets/javascripts/codemirror/modes/vbscript.js +4 -4
- data/vendor/assets/javascripts/codemirror/modes/xml.js +10 -6
- data/vendor/assets/javascripts/codemirror/modes/xquery.js +55 -55
- data/vendor/assets/javascripts/codemirror/modes/yaml.js +90 -90
- data/vendor/assets/javascripts/codemirror/modes/z80.js +82 -110
- data/vendor/assets/javascripts/codemirror.js +1914 -1115
- data/vendor/assets/stylesheets/codemirror/{utils → addons/dialog}/dialog.css +0 -0
- data/vendor/assets/stylesheets/codemirror/addons/hint/show-hint.css +38 -0
- data/vendor/assets/stylesheets/codemirror/addons/lint/lint.css +96 -0
- data/vendor/assets/stylesheets/codemirror/modes/tiki.css +2 -2
- data/vendor/assets/stylesheets/codemirror/themes/ambiance-mobile.css +0 -1
- data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +0 -1
- data/vendor/assets/stylesheets/codemirror/themes/eclipse.css +2 -2
- data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +5 -5
- data/vendor/assets/stylesheets/codemirror/themes/midnight.css +52 -0
- data/vendor/assets/stylesheets/codemirror/themes/xq-light.css +43 -0
- data/vendor/assets/stylesheets/codemirror.css +16 -10
- metadata +60 -52
- data/vendor/assets/javascripts/codemirror/modes/mysql.js +0 -203
- data/vendor/assets/javascripts/codemirror/modes/plsql.js +0 -216
- data/vendor/assets/javascripts/codemirror/utils/collapserange.js +0 -68
- data/vendor/assets/javascripts/codemirror/utils/continuelist.js +0 -28
- data/vendor/assets/javascripts/codemirror/utils/foldcode.js +0 -183
- data/vendor/assets/javascripts/codemirror/utils/formatting.js +0 -114
- data/vendor/assets/javascripts/codemirror/utils/match-highlighter.js +0 -46
- data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +0 -102
- data/vendor/assets/stylesheets/codemirror/utils/simple-hint.css +0 -16
@@ -35,18 +35,18 @@ CodeMirror.defineMode("xquery", function() {
|
|
35
35
|
, atom = {type: "atom", style: "atom"}
|
36
36
|
, punctuation = {type: "punctuation", style: null}
|
37
37
|
, qualifier = {type: "axis_specifier", style: "qualifier"};
|
38
|
-
|
38
|
+
|
39
39
|
// kwObj is what is return from this function at the end
|
40
40
|
var kwObj = {
|
41
41
|
'if': A, 'switch': A, 'while': A, 'for': A,
|
42
42
|
'else': B, 'then': B, 'try': B, 'finally': B, 'catch': B,
|
43
|
-
'element': C, 'attribute': C, 'let': C, 'implements': C, 'import': C, 'module': C, 'namespace': C,
|
44
|
-
'return': C, 'super': C, 'this': C, 'throws': C, 'where': C, 'private': C,
|
43
|
+
'element': C, 'attribute': C, 'let': C, 'implements': C, 'import': C, 'module': C, 'namespace': C,
|
44
|
+
'return': C, 'super': C, 'this': C, 'throws': C, 'where': C, 'private': C,
|
45
45
|
',': punctuation,
|
46
46
|
'null': atom, 'fn:false()': atom, 'fn:true()': atom
|
47
47
|
};
|
48
|
-
|
49
|
-
// a list of 'basic' keywords. For each add a property to kwObj with the value of
|
48
|
+
|
49
|
+
// a list of 'basic' keywords. For each add a property to kwObj with the value of
|
50
50
|
// {type: basic[i], style: "keyword"} e.g. 'after' --> {type: "after", style: "keyword"}
|
51
51
|
var basic = ['after','ancestor','ancestor-or-self','and','as','ascending','assert','attribute','before',
|
52
52
|
'by','case','cast','child','comment','declare','default','define','descendant','descendant-or-self',
|
@@ -57,20 +57,20 @@ CodeMirror.defineMode("xquery", function() {
|
|
57
57
|
'self','some','sortby','stable','text','then','to','treat','typeswitch','union','variable','version','where',
|
58
58
|
'xquery', 'empty-sequence'];
|
59
59
|
for(var i=0, l=basic.length; i < l; i++) { kwObj[basic[i]] = kw(basic[i]);};
|
60
|
-
|
61
|
-
// a list of types. For each add a property to kwObj with the value of
|
60
|
+
|
61
|
+
// a list of types. For each add a property to kwObj with the value of
|
62
62
|
// {type: "atom", style: "atom"}
|
63
|
-
var types = ['xs:string', 'xs:float', 'xs:decimal', 'xs:double', 'xs:integer', 'xs:boolean', 'xs:date', 'xs:dateTime',
|
64
|
-
'xs:time', 'xs:duration', 'xs:dayTimeDuration', 'xs:time', 'xs:yearMonthDuration', 'numeric', 'xs:hexBinary',
|
63
|
+
var types = ['xs:string', 'xs:float', 'xs:decimal', 'xs:double', 'xs:integer', 'xs:boolean', 'xs:date', 'xs:dateTime',
|
64
|
+
'xs:time', 'xs:duration', 'xs:dayTimeDuration', 'xs:time', 'xs:yearMonthDuration', 'numeric', 'xs:hexBinary',
|
65
65
|
'xs:base64Binary', 'xs:anyURI', 'xs:QName', 'xs:byte','xs:boolean','xs:anyURI','xf:yearMonthDuration'];
|
66
66
|
for(var i=0, l=types.length; i < l; i++) { kwObj[types[i]] = atom;};
|
67
|
-
|
67
|
+
|
68
68
|
// each operator will add a property to kwObj with value of {type: "operator", style: "keyword"}
|
69
69
|
var operators = ['eq', 'ne', 'lt', 'le', 'gt', 'ge', ':=', '=', '>', '>=', '<', '<=', '.', '|', '?', 'and', 'or', 'div', 'idiv', 'mod', '*', '/', '+', '-'];
|
70
70
|
for(var i=0, l=operators.length; i < l; i++) { kwObj[operators[i]] = operator;};
|
71
|
-
|
71
|
+
|
72
72
|
// each axis_specifiers will add a property to kwObj with value of {type: "axis_specifier", style: "qualifier"}
|
73
|
-
var axis_specifiers = ["self::", "attribute::", "child::", "descendant::", "descendant-or-self::", "parent::",
|
73
|
+
var axis_specifiers = ["self::", "attribute::", "child::", "descendant::", "descendant-or-self::", "parent::",
|
74
74
|
"ancestor::", "ancestor-or-self::", "following::", "preceding::", "following-sibling::", "preceding-sibling::"];
|
75
75
|
for(var i=0, l=axis_specifiers.length; i < l; i++) { kwObj[axis_specifiers[i]] = qualifier; };
|
76
76
|
|
@@ -80,42 +80,42 @@ CodeMirror.defineMode("xquery", function() {
|
|
80
80
|
// Used as scratch variables to communicate multiple values without
|
81
81
|
// consing up tons of objects.
|
82
82
|
var type, content;
|
83
|
-
|
83
|
+
|
84
84
|
function ret(tp, style, cont) {
|
85
85
|
type = tp; content = cont;
|
86
86
|
return style;
|
87
87
|
}
|
88
|
-
|
88
|
+
|
89
89
|
function chain(stream, state, f) {
|
90
90
|
state.tokenize = f;
|
91
91
|
return f(stream, state);
|
92
92
|
}
|
93
|
-
|
93
|
+
|
94
94
|
// the primary mode tokenizer
|
95
95
|
function tokenBase(stream, state) {
|
96
|
-
var ch = stream.next(),
|
96
|
+
var ch = stream.next(),
|
97
97
|
mightBeFunction = false,
|
98
98
|
isEQName = isEQNameAhead(stream);
|
99
|
-
|
99
|
+
|
100
100
|
// an XML tag (if not in some sub, chained tokenizer)
|
101
101
|
if (ch == "<") {
|
102
102
|
if(stream.match("!--", true))
|
103
103
|
return chain(stream, state, tokenXMLComment);
|
104
|
-
|
104
|
+
|
105
105
|
if(stream.match("![CDATA", false)) {
|
106
106
|
state.tokenize = tokenCDATA;
|
107
107
|
return ret("tag", "tag");
|
108
108
|
}
|
109
|
-
|
109
|
+
|
110
110
|
if(stream.match("?", false)) {
|
111
111
|
return chain(stream, state, tokenPreProcessing);
|
112
112
|
}
|
113
|
-
|
113
|
+
|
114
114
|
var isclose = stream.eat("/");
|
115
115
|
stream.eatSpace();
|
116
116
|
var tagName = "", c;
|
117
117
|
while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
|
118
|
-
|
118
|
+
|
119
119
|
return chain(stream, state, tokenTag(tagName, isclose));
|
120
120
|
}
|
121
121
|
// start code block
|
@@ -136,7 +136,7 @@ CodeMirror.defineMode("xquery", function() {
|
|
136
136
|
popStateStack(state);
|
137
137
|
return ret("tag", "tag");
|
138
138
|
}
|
139
|
-
else
|
139
|
+
else
|
140
140
|
return ret("word", "variable");
|
141
141
|
}
|
142
142
|
// if a number
|
@@ -186,13 +186,13 @@ CodeMirror.defineMode("xquery", function() {
|
|
186
186
|
// if there's a EQName ahead, consume the rest of the string portion, it's likely a function
|
187
187
|
if(isEQName && ch === '\"') while(stream.next() !== '"'){}
|
188
188
|
if(isEQName && ch === '\'') while(stream.next() !== '\''){}
|
189
|
-
|
189
|
+
|
190
190
|
// gobble up a word if the character is not known
|
191
191
|
if(!known) stream.eatWhile(/[\w\$_-]/);
|
192
|
-
|
192
|
+
|
193
193
|
// gobble a colon in the case that is a lib func type call fn:doc
|
194
194
|
var foundColon = stream.eat(":");
|
195
|
-
|
195
|
+
|
196
196
|
// if there's not a second colon, gobble another word. Otherwise, it's probably an axis specifier
|
197
197
|
// which should get matched as a keyword
|
198
198
|
if(!stream.eat(":") && foundColon) {
|
@@ -205,27 +205,27 @@ CodeMirror.defineMode("xquery", function() {
|
|
205
205
|
// is the word a keyword?
|
206
206
|
var word = stream.current();
|
207
207
|
known = keywords.propertyIsEnumerable(word) && keywords[word];
|
208
|
-
|
209
|
-
// if we think it's a function call but not yet known,
|
208
|
+
|
209
|
+
// if we think it's a function call but not yet known,
|
210
210
|
// set style to variable for now for lack of something better
|
211
211
|
if(mightBeFunction && !known) known = {type: "function_call", style: "variable def"};
|
212
|
-
|
212
|
+
|
213
213
|
// if the previous word was element, attribute, axis specifier, this word should be the name of that
|
214
214
|
if(isInXmlConstructor(state)) {
|
215
215
|
popStateStack(state);
|
216
216
|
return ret("word", "variable", word);
|
217
217
|
}
|
218
|
-
// as previously checked, if the word is element,attribute, axis specifier, call it an "xmlconstructor" and
|
218
|
+
// as previously checked, if the word is element,attribute, axis specifier, call it an "xmlconstructor" and
|
219
219
|
// push the stack so we know to look for it on the next word
|
220
220
|
if(word == "element" || word == "attribute" || known.type == "axis_specifier") pushStateStack(state, {type: "xmlconstructor"});
|
221
|
-
|
221
|
+
|
222
222
|
// if the word is known, return the details of that else just call this a generic 'word'
|
223
223
|
return known ? ret(known.type, known.style, word) :
|
224
224
|
ret("word", "variable", word);
|
225
225
|
}
|
226
226
|
}
|
227
227
|
|
228
|
-
// handle comments, including nested
|
228
|
+
// handle comments, including nested
|
229
229
|
function tokenComment(stream, state) {
|
230
230
|
var maybeEnd = false, maybeNested = false, nestedCount = 0, ch;
|
231
231
|
while (ch = stream.next()) {
|
@@ -243,7 +243,7 @@ CodeMirror.defineMode("xquery", function() {
|
|
243
243
|
maybeEnd = (ch == ":");
|
244
244
|
maybeNested = (ch == "(");
|
245
245
|
}
|
246
|
-
|
246
|
+
|
247
247
|
return ret("comment", "comment");
|
248
248
|
}
|
249
249
|
|
@@ -264,10 +264,10 @@ CodeMirror.defineMode("xquery", function() {
|
|
264
264
|
// if we're in a string and in an XML block, allow an embedded code block
|
265
265
|
if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
|
266
266
|
state.tokenize = tokenBase;
|
267
|
-
return ret("string", "string");
|
267
|
+
return ret("string", "string");
|
268
268
|
}
|
269
269
|
|
270
|
-
|
270
|
+
|
271
271
|
while (ch = stream.next()) {
|
272
272
|
if (ch == quote) {
|
273
273
|
popStateStack(state);
|
@@ -278,16 +278,16 @@ CodeMirror.defineMode("xquery", function() {
|
|
278
278
|
// if we're in a string and in an XML block, allow an embedded code block in an attribute
|
279
279
|
if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
|
280
280
|
state.tokenize = tokenBase;
|
281
|
-
return ret("string", "string");
|
281
|
+
return ret("string", "string");
|
282
282
|
}
|
283
283
|
|
284
284
|
}
|
285
285
|
}
|
286
|
-
|
286
|
+
|
287
287
|
return ret("string", "string");
|
288
288
|
};
|
289
289
|
}
|
290
|
-
|
290
|
+
|
291
291
|
// tokenizer for variables
|
292
292
|
function tokenVariable(stream, state) {
|
293
293
|
var isVariableChar = /[\w\$_-]/;
|
@@ -304,7 +304,7 @@ CodeMirror.defineMode("xquery", function() {
|
|
304
304
|
state.tokenize = tokenBase;
|
305
305
|
return ret("variable", "variable");
|
306
306
|
}
|
307
|
-
|
307
|
+
|
308
308
|
// tokenizer for XML tags
|
309
309
|
function tokenTag(name, isclose) {
|
310
310
|
return function(stream, state) {
|
@@ -322,7 +322,7 @@ CodeMirror.defineMode("xquery", function() {
|
|
322
322
|
return ret("tag", "tag");
|
323
323
|
}
|
324
324
|
else {
|
325
|
-
state.tokenize = tokenBase;
|
325
|
+
state.tokenize = tokenBase;
|
326
326
|
}
|
327
327
|
return ret("tag", "tag");
|
328
328
|
};
|
@@ -331,7 +331,7 @@ CodeMirror.defineMode("xquery", function() {
|
|
331
331
|
// tokenizer for XML attributes
|
332
332
|
function tokenAttribute(stream, state) {
|
333
333
|
var ch = stream.next();
|
334
|
-
|
334
|
+
|
335
335
|
if(ch == "/" && stream.eat(">")) {
|
336
336
|
if(isInXmlAttributeBlock(state)) popStateStack(state);
|
337
337
|
if(isInXmlBlock(state)) popStateStack(state);
|
@@ -347,7 +347,7 @@ CodeMirror.defineMode("xquery", function() {
|
|
347
347
|
if (ch == '"' || ch == "'")
|
348
348
|
return chain(stream, state, tokenString(ch, tokenAttribute));
|
349
349
|
|
350
|
-
if(!isInXmlAttributeBlock(state))
|
350
|
+
if(!isInXmlAttributeBlock(state))
|
351
351
|
pushStateStack(state, { type: "attribute", name: name, tokenize: tokenAttribute});
|
352
352
|
|
353
353
|
stream.eat(/[a-zA-Z_:]/);
|
@@ -357,18 +357,18 @@ CodeMirror.defineMode("xquery", function() {
|
|
357
357
|
// the case where the attribute has not value and the tag was closed
|
358
358
|
if(stream.match(">", false) || stream.match("/", false)) {
|
359
359
|
popStateStack(state);
|
360
|
-
state.tokenize = tokenBase;
|
360
|
+
state.tokenize = tokenBase;
|
361
361
|
}
|
362
362
|
|
363
363
|
return ret("attribute", "attribute");
|
364
364
|
}
|
365
|
-
|
366
|
-
// handle comments, including nested
|
365
|
+
|
366
|
+
// handle comments, including nested
|
367
367
|
function tokenXMLComment(stream, state) {
|
368
368
|
var ch;
|
369
369
|
while (ch = stream.next()) {
|
370
370
|
if (ch == "-" && stream.match("->", true)) {
|
371
|
-
state.tokenize = tokenBase;
|
371
|
+
state.tokenize = tokenBase;
|
372
372
|
return ret("comment", "comment");
|
373
373
|
}
|
374
374
|
}
|
@@ -380,7 +380,7 @@ CodeMirror.defineMode("xquery", function() {
|
|
380
380
|
var ch;
|
381
381
|
while (ch = stream.next()) {
|
382
382
|
if (ch == "]" && stream.match("]", true)) {
|
383
|
-
state.tokenize = tokenBase;
|
383
|
+
state.tokenize = tokenBase;
|
384
384
|
return ret("comment", "comment");
|
385
385
|
}
|
386
386
|
}
|
@@ -391,20 +391,20 @@ CodeMirror.defineMode("xquery", function() {
|
|
391
391
|
var ch;
|
392
392
|
while (ch = stream.next()) {
|
393
393
|
if (ch == "?" && stream.match(">", true)) {
|
394
|
-
state.tokenize = tokenBase;
|
394
|
+
state.tokenize = tokenBase;
|
395
395
|
return ret("comment", "comment meta");
|
396
396
|
}
|
397
397
|
}
|
398
398
|
}
|
399
|
-
|
400
|
-
|
399
|
+
|
400
|
+
|
401
401
|
// functions to test the current context of the state
|
402
402
|
function isInXmlBlock(state) { return isIn(state, "tag"); }
|
403
403
|
function isInXmlAttributeBlock(state) { return isIn(state, "attribute"); }
|
404
404
|
function isInXmlConstructor(state) { return isIn(state, "xmlconstructor"); }
|
405
405
|
function isInString(state) { return isIn(state, "string"); }
|
406
406
|
|
407
|
-
function isEQNameAhead(stream) {
|
407
|
+
function isEQNameAhead(stream) {
|
408
408
|
// assume we've already eaten a quote (")
|
409
409
|
if(stream.current() === '"')
|
410
410
|
return stream.match(/^[^\"]+\"\:/, false);
|
@@ -413,21 +413,21 @@ CodeMirror.defineMode("xquery", function() {
|
|
413
413
|
else
|
414
414
|
return false;
|
415
415
|
}
|
416
|
-
|
416
|
+
|
417
417
|
function isIn(state, type) {
|
418
|
-
return (state.stack.length && state.stack[state.stack.length - 1].type == type);
|
418
|
+
return (state.stack.length && state.stack[state.stack.length - 1].type == type);
|
419
419
|
}
|
420
|
-
|
420
|
+
|
421
421
|
function pushStateStack(state, newState) {
|
422
422
|
state.stack.push(newState);
|
423
423
|
}
|
424
|
-
|
424
|
+
|
425
425
|
function popStateStack(state) {
|
426
426
|
state.stack.pop();
|
427
427
|
var reinstateTokenize = state.stack.length && state.stack[state.stack.length-1].tokenize;
|
428
428
|
state.tokenize = reinstateTokenize || tokenBase;
|
429
429
|
}
|
430
|
-
|
430
|
+
|
431
431
|
// the interface for the mode API
|
432
432
|
return {
|
433
433
|
startState: function() {
|
@@ -1,95 +1,95 @@
|
|
1
1
|
CodeMirror.defineMode("yaml", function() {
|
2
|
-
|
3
|
-
var cons = ['true', 'false', 'on', 'off', 'yes', 'no'];
|
4
|
-
var keywordRegex = new RegExp("\\b(("+cons.join(")|(")+"))$", 'i');
|
5
|
-
|
6
|
-
return {
|
7
|
-
token: function(stream, state) {
|
8
|
-
var ch = stream.peek();
|
9
|
-
var esc = state.escaped;
|
10
|
-
state.escaped = false;
|
11
|
-
/* comments */
|
12
|
-
if (ch == "#") { stream.skipToEnd(); return "comment"; }
|
13
|
-
if (state.literal && stream.indentation() > state.keyCol) {
|
14
|
-
stream.skipToEnd(); return "string";
|
15
|
-
} else if (state.literal) { state.literal = false; }
|
16
|
-
if (stream.sol()) {
|
17
|
-
state.keyCol = 0;
|
18
|
-
state.pair = false;
|
19
|
-
state.pairStart = false;
|
20
|
-
/* document start */
|
21
|
-
if(stream.match(/---/)) { return "def"; }
|
22
|
-
/* document end */
|
23
|
-
if (stream.match(/\.\.\./)) { return "def"; }
|
24
|
-
/* array list item */
|
25
|
-
if (stream.match(/\s*-\s+/)) { return 'meta'; }
|
26
|
-
}
|
27
|
-
/* pairs (associative arrays) -> key */
|
28
|
-
if (!state.pair && stream.match(/^\s*([a-z0-9\._-])+(?=\s*:)/i)) {
|
29
|
-
state.pair = true;
|
30
|
-
state.keyCol = stream.indentation();
|
31
|
-
return "atom";
|
32
|
-
}
|
33
|
-
if (state.pair && stream.match(/^:\s*/)) { state.pairStart = true; return 'meta'; }
|
34
|
-
|
35
|
-
/* inline pairs/lists */
|
36
|
-
if (stream.match(/^(\{|\}|\[|\])/)) {
|
37
|
-
if (ch == '{')
|
38
|
-
state.inlinePairs++;
|
39
|
-
else if (ch == '}')
|
40
|
-
state.inlinePairs--;
|
41
|
-
else if (ch == '[')
|
42
|
-
state.inlineList++;
|
43
|
-
else
|
44
|
-
state.inlineList--;
|
45
|
-
return 'meta';
|
46
|
-
}
|
47
|
-
|
48
|
-
/* list seperator */
|
49
|
-
if (state.inlineList > 0 && !esc && ch == ',') {
|
50
|
-
stream.next();
|
51
|
-
return 'meta';
|
52
|
-
}
|
53
|
-
/* pairs seperator */
|
54
|
-
if (state.inlinePairs > 0 && !esc && ch == ',') {
|
55
|
-
state.keyCol = 0;
|
56
|
-
state.pair = false;
|
57
|
-
state.pairStart = false;
|
58
|
-
stream.next();
|
59
|
-
return 'meta';
|
60
|
-
}
|
61
|
-
|
62
|
-
/* start of value of a pair */
|
63
|
-
if (state.pairStart) {
|
64
|
-
/* block literals */
|
65
|
-
if (stream.match(/^\s*(\||\>)\s*/)) { state.literal = true; return 'meta'; };
|
66
|
-
/* references */
|
67
|
-
if (stream.match(/^\s*(\&|\*)[a-z0-9\._-]+\b/i)) { return 'variable-2'; }
|
68
|
-
/* numbers */
|
69
|
-
if (state.inlinePairs == 0 && stream.match(/^\s*-?[0-9\.\,]+\s?$/)) { return 'number'; }
|
70
|
-
if (state.inlinePairs > 0 && stream.match(/^\s*-?[0-9\.\,]+\s?(?=(,|}))/)) { return 'number'; }
|
71
|
-
/* keywords */
|
72
|
-
if (stream.match(keywordRegex)) { return 'keyword'; }
|
73
|
-
}
|
74
2
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
3
|
+
var cons = ['true', 'false', 'on', 'off', 'yes', 'no'];
|
4
|
+
var keywordRegex = new RegExp("\\b(("+cons.join(")|(")+"))$", 'i');
|
5
|
+
|
6
|
+
return {
|
7
|
+
token: function(stream, state) {
|
8
|
+
var ch = stream.peek();
|
9
|
+
var esc = state.escaped;
|
10
|
+
state.escaped = false;
|
11
|
+
/* comments */
|
12
|
+
if (ch == "#") { stream.skipToEnd(); return "comment"; }
|
13
|
+
if (state.literal && stream.indentation() > state.keyCol) {
|
14
|
+
stream.skipToEnd(); return "string";
|
15
|
+
} else if (state.literal) { state.literal = false; }
|
16
|
+
if (stream.sol()) {
|
17
|
+
state.keyCol = 0;
|
18
|
+
state.pair = false;
|
19
|
+
state.pairStart = false;
|
20
|
+
/* document start */
|
21
|
+
if(stream.match(/---/)) { return "def"; }
|
22
|
+
/* document end */
|
23
|
+
if (stream.match(/\.\.\./)) { return "def"; }
|
24
|
+
/* array list item */
|
25
|
+
if (stream.match(/\s*-\s+/)) { return 'meta'; }
|
26
|
+
}
|
27
|
+
/* pairs (associative arrays) -> key */
|
28
|
+
if (!state.pair && stream.match(/^\s*([a-z0-9\._-])+(?=\s*:)/i)) {
|
29
|
+
state.pair = true;
|
30
|
+
state.keyCol = stream.indentation();
|
31
|
+
return "atom";
|
32
|
+
}
|
33
|
+
if (state.pair && stream.match(/^:\s*/)) { state.pairStart = true; return 'meta'; }
|
34
|
+
|
35
|
+
/* inline pairs/lists */
|
36
|
+
if (stream.match(/^(\{|\}|\[|\])/)) {
|
37
|
+
if (ch == '{')
|
38
|
+
state.inlinePairs++;
|
39
|
+
else if (ch == '}')
|
40
|
+
state.inlinePairs--;
|
41
|
+
else if (ch == '[')
|
42
|
+
state.inlineList++;
|
43
|
+
else
|
44
|
+
state.inlineList--;
|
45
|
+
return 'meta';
|
46
|
+
}
|
47
|
+
|
48
|
+
/* list seperator */
|
49
|
+
if (state.inlineList > 0 && !esc && ch == ',') {
|
50
|
+
stream.next();
|
51
|
+
return 'meta';
|
52
|
+
}
|
53
|
+
/* pairs seperator */
|
54
|
+
if (state.inlinePairs > 0 && !esc && ch == ',') {
|
55
|
+
state.keyCol = 0;
|
56
|
+
state.pair = false;
|
57
|
+
state.pairStart = false;
|
58
|
+
stream.next();
|
59
|
+
return 'meta';
|
60
|
+
}
|
61
|
+
|
62
|
+
/* start of value of a pair */
|
63
|
+
if (state.pairStart) {
|
64
|
+
/* block literals */
|
65
|
+
if (stream.match(/^\s*(\||\>)\s*/)) { state.literal = true; return 'meta'; };
|
66
|
+
/* references */
|
67
|
+
if (stream.match(/^\s*(\&|\*)[a-z0-9\._-]+\b/i)) { return 'variable-2'; }
|
68
|
+
/* numbers */
|
69
|
+
if (state.inlinePairs == 0 && stream.match(/^\s*-?[0-9\.\,]+\s?$/)) { return 'number'; }
|
70
|
+
if (state.inlinePairs > 0 && stream.match(/^\s*-?[0-9\.\,]+\s?(?=(,|}))/)) { return 'number'; }
|
71
|
+
/* keywords */
|
72
|
+
if (stream.match(keywordRegex)) { return 'keyword'; }
|
73
|
+
}
|
74
|
+
|
75
|
+
/* nothing found, continue */
|
76
|
+
state.pairStart = false;
|
77
|
+
state.escaped = (ch == '\\');
|
78
|
+
stream.next();
|
79
|
+
return null;
|
80
|
+
},
|
81
|
+
startState: function() {
|
82
|
+
return {
|
83
|
+
pair: false,
|
84
|
+
pairStart: false,
|
85
|
+
keyCol: 0,
|
86
|
+
inlinePairs: 0,
|
87
|
+
inlineList: 0,
|
88
|
+
literal: false,
|
89
|
+
escaped: false
|
90
|
+
};
|
91
|
+
}
|
92
|
+
};
|
93
93
|
});
|
94
94
|
|
95
95
|
CodeMirror.defineMIME("text/x-yaml", "yaml");
|