codemirror-rails 5.11.1 → 5.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86b90957b2f67d6ec71cf4dd32a7fb5a9f9dd60a
4
- data.tar.gz: 77cac22b1af3f1c19bb61fc392b0292a653a48d6
3
+ metadata.gz: 2d50c6ae9f3c145c8a536553f00140d330628efd
4
+ data.tar.gz: 476404365d720f4980f576d5c838b9aeb3caaf14
5
5
  SHA512:
6
- metadata.gz: f2bf076d9971c26b1d72bc0f23aed28f7bbec97d9541fc0cb3c107c6e12835cc7fd3f74dea624719be9c5ab08360ae46669215bd8bba333ae0f0b1ad546fc2bd
7
- data.tar.gz: e8507ab58b6d2e26dae6df6fcea6740dde2e4e960a151b09b01c92c85d10f4587397f40bc7c1009a46062c00aea476b5c1803ecd6af425665ac942c9a32856e1
6
+ metadata.gz: 1d31e447de612a679ee1313a03d87d0cfed89b43c4ad16287fdd30099835df73969c2688ba31070c0d9c579e6745d415a7737aa796cf8e5e07ca581412a7f554
7
+ data.tar.gz: 0d276f0875057e15eb8e429bad6e2e3e5743cb6f243f2f495473f87b30de14b7356dd1141ad724d06a92a1e99403d09dce2c0b2f8885147c096d143cd4714401
@@ -1,6 +1,6 @@
1
1
  module Codemirror
2
2
  module Rails
3
- VERSION = '5.11.1'
4
- CODEMIRROR_VERSION = '5.11'
3
+ VERSION = '5.12'
4
+ CODEMIRROR_VERSION = '5.12'
5
5
  end
6
6
  end
@@ -543,6 +543,7 @@
543
543
 
544
544
  d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
545
545
  d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
546
+ d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent"
546
547
 
547
548
  if (sizes.right && sizes.bottom) {
548
549
  d.scrollbarFiller.style.display = "block";
@@ -787,9 +788,9 @@
787
788
 
788
789
  function setDocumentHeight(cm, measure) {
789
790
  cm.display.sizer.style.minHeight = measure.docHeight + "px";
790
- var total = measure.docHeight + cm.display.barHeight;
791
- cm.display.heightForcer.style.top = total + "px";
792
- cm.display.gutters.style.height = Math.max(total + scrollGap(cm), measure.clientHeight) + "px";
791
+ cm.display.heightForcer.style.top = measure.docHeight + "px";
792
+ cm.display.gutters.style.height = Math.max(measure.docHeight + cm.display.barHeight + scrollGap(cm),
793
+ measure.clientHeight) + "px";
793
794
  }
794
795
 
795
796
  // Read the actual heights of the rendered lines, and update their
@@ -1482,10 +1483,11 @@
1482
1483
  if (reset && cm.doc.sel.contains(pos) == -1)
1483
1484
  operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
1484
1485
 
1485
- var oldCSS = te.style.cssText;
1486
- input.wrapper.style.position = "absolute";
1487
- te.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
1488
- "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " +
1486
+ var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText;
1487
+ input.wrapper.style.cssText = "position: absolute"
1488
+ var wrapperBox = input.wrapper.getBoundingClientRect()
1489
+ te.style.cssText = "position: absolute; width: 30px; height: 30px; top: " + (e.clientY - wrapperBox.top - 5) +
1490
+ "px; left: " + (e.clientX - wrapperBox.left - 5) + "px; z-index: 1000; background: " +
1489
1491
  (ie ? "rgba(255, 255, 255, .05)" : "transparent") +
1490
1492
  "; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
1491
1493
  if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712)
@@ -1516,7 +1518,7 @@
1516
1518
  }
1517
1519
  function rehide() {
1518
1520
  input.contextMenuPending = false;
1519
- input.wrapper.style.position = "relative";
1521
+ input.wrapper.style.cssText = oldWrapperCSS
1520
1522
  te.style.cssText = oldCSS;
1521
1523
  if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos);
1522
1524
 
@@ -3139,7 +3141,7 @@
3139
3141
  display.scroller.scrollTop = doc.scrollTop;
3140
3142
  }
3141
3143
  if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) {
3142
- doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - displayWidth(cm), op.scrollLeft));
3144
+ doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - display.scroller.clientWidth, op.scrollLeft));
3143
3145
  display.scrollbars.setScrollLeft(doc.scrollLeft);
3144
3146
  display.scroller.scrollLeft = doc.scrollLeft;
3145
3147
  alignHorizontally(cm);
@@ -8884,7 +8886,7 @@
8884
8886
 
8885
8887
  // THE END
8886
8888
 
8887
- CodeMirror.version = "5.11.0";
8889
+ CodeMirror.version = "5.12.0";
8888
8890
 
8889
8891
  return CodeMirror;
8890
8892
  });
@@ -56,6 +56,8 @@
56
56
 
57
57
  var inp = dialog.getElementsByTagName("input")[0], button;
58
58
  if (inp) {
59
+ inp.focus();
60
+
59
61
  if (options.value) {
60
62
  inp.value = options.value;
61
63
  if (options.selectValueOnOpen !== false) {
@@ -79,8 +81,6 @@
79
81
  });
80
82
 
81
83
  if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close);
82
-
83
- inp.focus();
84
84
  } else if (button = dialog.getElementsByTagName("button")[0]) {
85
85
  CodeMirror.on(button, "click", function() {
86
86
  close();
@@ -427,8 +427,9 @@
427
427
 
428
428
  function copyChunk(dv, to, from, chunk) {
429
429
  if (dv.diffOutOfDate) return;
430
+ var start = chunk.editTo > to.lastLine() ? Pos(chunk.editFrom - 1) : Pos(chunk.editFrom, 0)
430
431
  to.replaceRange(from.getRange(Pos(chunk.origFrom, 0), Pos(chunk.origTo, 0)),
431
- Pos(chunk.editFrom, 0), Pos(chunk.editTo, 0));
432
+ start, Pos(chunk.editTo, 0));
432
433
  }
433
434
 
434
435
  // Merge view, containing 0, 1, or 2 diff views.
@@ -18,6 +18,7 @@
18
18
  "use strict";
19
19
  var WRAP_CLASS = "CodeMirror-activeline";
20
20
  var BACK_CLASS = "CodeMirror-activeline-background";
21
+ var GUTT_CLASS = "CodeMirror-activeline-gutter";
21
22
 
22
23
  CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
23
24
  var prev = old && old != CodeMirror.Init;
@@ -36,6 +37,7 @@
36
37
  for (var i = 0; i < cm.state.activeLines.length; i++) {
37
38
  cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS);
38
39
  cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS);
40
+ cm.removeLineClass(cm.state.activeLines[i], "gutter", GUTT_CLASS);
39
41
  }
40
42
  }
41
43
 
@@ -60,6 +62,7 @@
60
62
  for (var i = 0; i < active.length; i++) {
61
63
  cm.addLineClass(active[i], "wrap", WRAP_CLASS);
62
64
  cm.addLineClass(active[i], "background", BACK_CLASS);
65
+ cm.addLineClass(active[i], "gutter", GUTT_CLASS);
63
66
  }
64
67
  cm.state.activeLines = active;
65
68
  });
@@ -105,7 +105,7 @@
105
105
  cm.setSelections(extended);
106
106
  };
107
107
 
108
- map["Shift-" + ctrl + "K"] = "deleteLine";
108
+ map["Shift-Ctrl-K"] = "deleteLine";
109
109
 
110
110
  function insertLine(cm, above) {
111
111
  if (cm.isReadOnly()) return CodeMirror.Pass
@@ -164,6 +164,7 @@
164
164
  { keys: 'v', type: 'action', action: 'toggleVisualMode' },
165
165
  { keys: 'V', type: 'action', action: 'toggleVisualMode', actionArgs: { linewise: true }},
166
166
  { keys: '<C-v>', type: 'action', action: 'toggleVisualMode', actionArgs: { blockwise: true }},
167
+ { keys: '<C-q>', type: 'action', action: 'toggleVisualMode', actionArgs: { blockwise: true }},
167
168
  { keys: 'gv', type: 'action', action: 'reselectLastSelection' },
168
169
  { keys: 'J', type: 'action', action: 'joinLines', isEdit: true },
169
170
  { keys: 'p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: true, isEdit: true }},
@@ -681,6 +682,9 @@
681
682
  // Add user defined key bindings.
682
683
  exCommandDispatcher.map(lhs, rhs, ctx);
683
684
  },
685
+ unmap: function(lhs, ctx) {
686
+ exCommandDispatcher.unmap(lhs, ctx);
687
+ },
684
688
  // TODO: Expose setOption and getOption as instance methods. Need to decide how to namespace
685
689
  // them, or somehow make them work with the existing CodeMirror setOption/getOption API.
686
690
  setOption: setOption,
@@ -11,6 +11,42 @@
11
11
  })(function(CodeMirror) {
12
12
  "use strict";
13
13
 
14
+ function Context(indented, column, type, align, prev) {
15
+ this.indented = indented;
16
+ this.column = column;
17
+ this.type = type;
18
+ this.align = align;
19
+ this.prev = prev;
20
+ }
21
+ function isStatement(type) {
22
+ return type == "statement" || type == "switchstatement" || type == "namespace";
23
+ }
24
+ function pushContext(state, col, type) {
25
+ var indent = state.indented;
26
+ if (state.context && isStatement(state.context.type) && !isStatement(type))
27
+ indent = state.context.indented;
28
+ return state.context = new Context(indent, col, type, null, state.context);
29
+ }
30
+ function popContext(state) {
31
+ var t = state.context.type;
32
+ if (t == ")" || t == "]" || t == "}")
33
+ state.indented = state.context.indented;
34
+ return state.context = state.context.prev;
35
+ }
36
+
37
+ function typeBefore(stream, state) {
38
+ if (state.prevToken == "variable" || state.prevToken == "variable-3") return true;
39
+ if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, stream.start))) return true;
40
+ }
41
+
42
+ function isTopScope(context) {
43
+ for (;;) {
44
+ if (!context || context.type == "top") return true;
45
+ if (context.type == "}" && context.prev.type != "namespace") return false;
46
+ context = context.prev;
47
+ }
48
+ }
49
+
14
50
  CodeMirror.defineMode("clike", function(config, parserConfig) {
15
51
  var indentUnit = config.indentUnit,
16
52
  statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
@@ -111,42 +147,6 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
111
147
  return "comment";
112
148
  }
113
149
 
114
- function Context(indented, column, type, align, prev) {
115
- this.indented = indented;
116
- this.column = column;
117
- this.type = type;
118
- this.align = align;
119
- this.prev = prev;
120
- }
121
- function isStatement(type) {
122
- return type == "statement" || type == "switchstatement" || type == "namespace";
123
- }
124
- function pushContext(state, col, type) {
125
- var indent = state.indented;
126
- if (state.context && isStatement(state.context.type) && !isStatement(type))
127
- indent = state.context.indented;
128
- return state.context = new Context(indent, col, type, null, state.context);
129
- }
130
- function popContext(state) {
131
- var t = state.context.type;
132
- if (t == ")" || t == "]" || t == "}")
133
- state.indented = state.context.indented;
134
- return state.context = state.context.prev;
135
- }
136
-
137
- function typeBefore(stream, state) {
138
- if (state.prevToken == "variable" || state.prevToken == "variable-3") return true;
139
- if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, stream.start))) return true;
140
- }
141
-
142
- function isTopScope(context) {
143
- for (;;) {
144
- if (!context || context.type == "top") return true;
145
- if (context.type == "}" && context.prev.type != "namespace") return false;
146
- context = context.prev;
147
- }
148
- }
149
-
150
150
  // Interface
151
151
 
152
152
  return {
@@ -497,7 +497,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
497
497
  ),
498
498
  types: words(
499
499
  "AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
500
- "Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
500
+ "Enumeration Equiv Error Exception Fractional Function IndexedSeq Int Integral Iterable " +
501
501
  "Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
502
502
  "Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
503
503
  "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector " +
@@ -527,6 +527,15 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
527
527
  "'": function(stream) {
528
528
  stream.eatWhile(/[\w\$_\xa1-\uffff]/);
529
529
  return "atom";
530
+ },
531
+ "=": function(stream, state) {
532
+ var cx = state.context
533
+ if (cx.type == "}" && cx.align && stream.eat(">")) {
534
+ state.context = new Context(cx.indented, cx.column, cx.type, null, cx.prev)
535
+ return "operator"
536
+ } else {
537
+ return false
538
+ }
530
539
  }
531
540
  },
532
541
  modeProps: {closeBrackets: {triples: '"'}}
@@ -0,0 +1,173 @@
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("fcl", function(config) {
15
+ var indentUnit = config.indentUnit;
16
+
17
+ var keywords = {
18
+ "term": true,
19
+ "method": true, "accu": true,
20
+ "rule": true, "then": true, "is": true, "and": true, "or": true,
21
+ "if": true, "default": true
22
+ };
23
+
24
+ var start_blocks = {
25
+ "var_input": true,
26
+ "var_output": true,
27
+ "fuzzify": true,
28
+ "defuzzify": true,
29
+ "function_block": true,
30
+ "ruleblock": true
31
+ };
32
+
33
+ var end_blocks = {
34
+ "end_ruleblock": true,
35
+ "end_defuzzify": true,
36
+ "end_function_block": true,
37
+ "end_fuzzify": true,
38
+ "end_var": true
39
+ };
40
+
41
+ var atoms = {
42
+ "true": true, "false": true, "nan": true,
43
+ "real": true, "min": true, "max": true, "cog": true, "cogs": true
44
+ };
45
+
46
+ var isOperatorChar = /[+\-*&^%:=<>!|\/]/;
47
+
48
+ function tokenBase(stream, state) {
49
+ var ch = stream.next();
50
+
51
+ if (/[\d\.]/.test(ch)) {
52
+ if (ch == ".") {
53
+ stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/);
54
+ } else if (ch == "0") {
55
+ stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/);
56
+ } else {
57
+ stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/);
58
+ }
59
+ return "number";
60
+ }
61
+
62
+ if (ch == "/" || ch == "(") {
63
+ if (stream.eat("*")) {
64
+ state.tokenize = tokenComment;
65
+ return tokenComment(stream, state);
66
+ }
67
+ if (stream.eat("/")) {
68
+ stream.skipToEnd();
69
+ return "comment";
70
+ }
71
+ }
72
+ if (isOperatorChar.test(ch)) {
73
+ stream.eatWhile(isOperatorChar);
74
+ return "operator";
75
+ }
76
+ stream.eatWhile(/[\w\$_\xa1-\uffff]/);
77
+
78
+ var cur = stream.current().toLowerCase();
79
+ if (keywords.propertyIsEnumerable(cur) ||
80
+ start_blocks.propertyIsEnumerable(cur) ||
81
+ end_blocks.propertyIsEnumerable(cur)) {
82
+ return "keyword";
83
+ }
84
+ if (atoms.propertyIsEnumerable(cur)) return "atom";
85
+ return "variable";
86
+ }
87
+
88
+
89
+ function tokenComment(stream, state) {
90
+ var maybeEnd = false, ch;
91
+ while (ch = stream.next()) {
92
+ if ((ch == "/" || ch == ")") && maybeEnd) {
93
+ state.tokenize = tokenBase;
94
+ break;
95
+ }
96
+ maybeEnd = (ch == "*");
97
+ }
98
+ return "comment";
99
+ }
100
+
101
+ function Context(indented, column, type, align, prev) {
102
+ this.indented = indented;
103
+ this.column = column;
104
+ this.type = type;
105
+ this.align = align;
106
+ this.prev = prev;
107
+ }
108
+
109
+ function pushContext(state, col, type) {
110
+ return state.context = new Context(state.indented, col, type, null, state.context);
111
+ }
112
+
113
+ function popContext(state) {
114
+ if (!state.context.prev) return;
115
+ var t = state.context.type;
116
+ if (t == "end_block")
117
+ state.indented = state.context.indented;
118
+ return state.context = state.context.prev;
119
+ }
120
+
121
+ // Interface
122
+
123
+ return {
124
+ startState: function(basecolumn) {
125
+ return {
126
+ tokenize: null,
127
+ context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
128
+ indented: 0,
129
+ startOfLine: true
130
+ };
131
+ },
132
+
133
+ token: function(stream, state) {
134
+ var ctx = state.context;
135
+ if (stream.sol()) {
136
+ if (ctx.align == null) ctx.align = false;
137
+ state.indented = stream.indentation();
138
+ state.startOfLine = true;
139
+ }
140
+ if (stream.eatSpace()) return null;
141
+
142
+ var style = (state.tokenize || tokenBase)(stream, state);
143
+ if (style == "comment") return style;
144
+ if (ctx.align == null) ctx.align = true;
145
+
146
+ var cur = stream.current().toLowerCase();
147
+
148
+ if (start_blocks.propertyIsEnumerable(cur)) pushContext(state, stream.column(), "end_block");
149
+ else if (end_blocks.propertyIsEnumerable(cur)) popContext(state);
150
+
151
+ state.startOfLine = false;
152
+ return style;
153
+ },
154
+
155
+ indent: function(state, textAfter) {
156
+ if (state.tokenize != tokenBase && state.tokenize != null) return 0;
157
+ var ctx = state.context;
158
+
159
+ var closing = end_blocks.propertyIsEnumerable(textAfter);
160
+ if (ctx.align) return ctx.column + (closing ? 0 : 1);
161
+ else return ctx.indented + (closing ? 0 : indentUnit);
162
+ },
163
+
164
+ electricChars: "ryk",
165
+ fold: "brace",
166
+ blockCommentStart: "(*",
167
+ blockCommentEnd: "*)",
168
+ lineComment: "//"
169
+ };
170
+ });
171
+
172
+ CodeMirror.defineMIME("text/x-fcl", "fcl");
173
+ });
@@ -44,13 +44,9 @@
44
44
  return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*");
45
45
  }
46
46
 
47
- function getAttrValue(stream, attr) {
48
- var pos = stream.pos, match;
49
- while (pos >= 0 && stream.string.charAt(pos) !== "<") pos--;
50
- if (pos < 0) return pos;
51
- if (match = stream.string.slice(pos, stream.pos).match(getAttrRegexp(attr)))
52
- return match[2];
53
- return "";
47
+ function getAttrValue(text, attr) {
48
+ var match = text.match(getAttrRegexp(attr))
49
+ return match ? match[2] : ""
54
50
  }
55
51
 
56
52
  function getTagRegexp(tagName, anchored) {
@@ -66,10 +62,10 @@
66
62
  }
67
63
  }
68
64
 
69
- function findMatchingMode(tagInfo, stream) {
65
+ function findMatchingMode(tagInfo, tagText) {
70
66
  for (var i = 0; i < tagInfo.length; i++) {
71
67
  var spec = tagInfo[i];
72
- if (!spec[0] || spec[1].test(getAttrValue(stream, spec[0]))) return spec[2];
68
+ if (!spec[0] || spec[1].test(getAttrValue(tagText, spec[0]))) return spec[2];
73
69
  }
74
70
  }
75
71
 
@@ -89,15 +85,17 @@
89
85
  tags.script.unshift(["type", configScript[i].matches, configScript[i].mode])
90
86
 
91
87
  function html(stream, state) {
92
- var tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase();
93
- var tagInfo = tagName && tags.hasOwnProperty(tagName) && tags[tagName];
94
-
95
- var style = htmlMode.token(stream, state.htmlState), modeSpec;
96
-
97
- if (tagInfo && /\btag\b/.test(style) && stream.current() === ">" &&
98
- (modeSpec = findMatchingMode(tagInfo, stream))) {
99
- var mode = CodeMirror.getMode(config, modeSpec);
100
- var endTagA = getTagRegexp(tagName, true), endTag = getTagRegexp(tagName, false);
88
+ var style = htmlMode.token(stream, state.htmlState), tag = /\btag\b/.test(style), tagName
89
+ if (tag && !/[<>\s\/]/.test(stream.current()) &&
90
+ (tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase()) &&
91
+ tags.hasOwnProperty(tagName)) {
92
+ state.inTag = tagName + " "
93
+ } else if (state.inTag && tag && />$/.test(stream.current())) {
94
+ var inTag = /^([\S]+) (.*)/.exec(state.inTag)
95
+ state.inTag = null
96
+ var modeSpec = stream.current() == ">" && findMatchingMode(tags[inTag[1]], inTag[2])
97
+ var mode = CodeMirror.getMode(config, modeSpec)
98
+ var endTagA = getTagRegexp(inTag[1], true), endTag = getTagRegexp(inTag[1], false);
101
99
  state.token = function (stream, state) {
102
100
  if (stream.match(endTagA, false)) {
103
101
  state.token = html;
@@ -108,6 +106,9 @@
108
106
  };
109
107
  state.localMode = mode;
110
108
  state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, ""));
109
+ } else if (state.inTag) {
110
+ state.inTag += stream.current()
111
+ if (stream.eol()) state.inTag += " "
111
112
  }
112
113
  return style;
113
114
  };
@@ -115,7 +116,7 @@
115
116
  return {
116
117
  startState: function () {
117
118
  var state = htmlMode.startState();
118
- return {token: html, localMode: null, localState: null, htmlState: state};
119
+ return {token: html, inTag: null, localMode: null, localState: null, htmlState: state};
119
120
  },
120
121
 
121
122
  copyState: function (state) {
@@ -123,7 +124,8 @@
123
124
  if (state.localState) {
124
125
  local = CodeMirror.copyState(state.localMode, state.localState);
125
126
  }
126
- return {token: state.token, localMode: state.localMode, localState: local,
127
+ return {token: state.token, inTag: state.inTag,
128
+ localMode: state.localMode, localState: local,
127
129
  htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
128
130
  },
129
131
 
@@ -14,27 +14,34 @@
14
14
  CodeMirror.defineMode("julia", function(_conf, parserConf) {
15
15
  var ERRORCLASS = 'error';
16
16
 
17
- function wordRegexp(words) {
18
- return new RegExp("^((" + words.join(")|(") + "))\\b");
17
+ function wordRegexp(words, end) {
18
+ if (typeof end === 'undefined') { end = "\\b"; }
19
+ return new RegExp("^((" + words.join(")|(") + "))" + end);
19
20
  }
20
21
 
22
+ var octChar = "\\\\[0-7]{1,3}";
23
+ var hexChar = "\\\\x[A-Fa-f0-9]{1,2}";
24
+ var specialChar = "\\\\[abfnrtv0%?'\"\\\\]";
25
+ var singleChar = "([^\\u0027\\u005C\\uD800-\\uDFFF]|[\\uD800-\\uDFFF][\\uDC00-\\uDFFF])";
21
26
  var operators = parserConf.operators || /^\.?[|&^\\%*+\-<>!=\/]=?|\?|~|:|\$|\.[<>]|<<=?|>>>?=?|\.[<>=]=|->?|\/\/|\bin\b(?!\()|[\u2208\u2209](?!\()/;
22
27
  var delimiters = parserConf.delimiters || /^[;,()[\]{}]/;
23
- var identifiers = parserConf.identifiers || /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*!*/;
28
+ var identifiers = parserConf.identifiers || /^[_A-Za-z\u00A1-\uFFFF][\w\u00A1-\uFFFF]*!*/;
29
+ var charsList = [octChar, hexChar, specialChar, singleChar];
24
30
  var blockOpeners = ["begin", "function", "type", "immutable", "let", "macro", "for", "while", "quote", "if", "else", "elseif", "try", "finally", "catch", "do"];
25
31
  var blockClosers = ["end", "else", "elseif", "catch", "finally"];
26
32
  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'];
27
33
  var builtinList = ['true', 'false', 'nothing', 'NaN', 'Inf'];
28
34
 
29
35
  //var stringPrefixes = new RegExp("^[br]?('|\")")
30
- var stringPrefixes = /^(`|'|"{3}|([brv]?"))/;
36
+ var stringPrefixes = /^(`|"{3}|([brv]?"))/;
37
+ var chars = wordRegexp(charsList, "'");
31
38
  var keywords = wordRegexp(keywordList);
32
39
  var builtins = wordRegexp(builtinList);
33
40
  var openers = wordRegexp(blockOpeners);
34
41
  var closers = wordRegexp(blockClosers);
35
- var macro = /^@[_A-Za-z][_A-Za-z0-9]*/;
36
- var symbol = /^:[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*!*/;
37
- var typeAnnotation = /^::[^.,;"{()=$\s]+({[^}]*}+)*/;
42
+ var macro = /^@[_A-Za-z][\w]*/;
43
+ var symbol = /^:[_A-Za-z\u00A1-\uFFFF][\w\u00A1-\uFFFF]*!*/;
44
+ var typeAnnotation = /^::[^,;"{()=$\s]+({[^}]*}+)*/;
38
45
 
39
46
  function inArray(state) {
40
47
  var ch = currentScope(state);
@@ -53,19 +60,10 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
53
60
 
54
61
  // tokenizers
55
62
  function tokenBase(stream, state) {
56
- //Handle multiline comments
57
- if (stream.match(/^#=\s*/)) {
58
- state.scopes.push('#=');
59
- }
60
- if (currentScope(state) == '#=' && stream.match(/^=#/)) {
61
- state.scopes.pop();
62
- return 'comment';
63
- }
64
- if (state.scopes.indexOf('#=') >= 0) {
65
- if (!stream.match(/.*?(?=(#=|=#))/)) {
66
- stream.skipToEnd();
67
- }
68
- return 'comment';
63
+ // Handle multiline comments
64
+ if (stream.match(/^#=/, false)) {
65
+ state.tokenize = tokenComment;
66
+ return state.tokenize(stream, state);
69
67
  }
70
68
 
71
69
  // Handle scope changes
@@ -100,6 +98,10 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
100
98
  state.scopes.push('[');
101
99
  }
102
100
 
101
+ if (ch === '(') {
102
+ state.scopes.push('(');
103
+ }
104
+
103
105
  var scope = currentScope(state);
104
106
 
105
107
  if (scope == '[' && ch === ']') {
@@ -137,33 +139,20 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
137
139
  // Handle Number Literals
138
140
  if (stream.match(/^[0-9\.]/, false)) {
139
141
  var imMatcher = RegExp(/^im\b/);
140
- var floatLiteral = false;
142
+ var numberLiteral = false;
141
143
  // Floats
142
- if (stream.match(/^\d*\.(?!\.)\d+([ef][\+\-]?\d+)?/i)) { floatLiteral = true; }
143
- if (stream.match(/^\d+\.(?!\.)\d*/)) { floatLiteral = true; }
144
- if (stream.match(/^\.\d+/)) { floatLiteral = true; }
145
- if (stream.match(/^0x\.[0-9a-f]+p[\+\-]?\d+/i)) { floatLiteral = true; }
146
- if (floatLiteral) {
147
- // Float literals may be "imaginary"
148
- stream.match(imMatcher);
149
- state.leavingExpr = true;
150
- return 'number';
151
- }
144
+ if (stream.match(/^\d*\.(?!\.)\d*([Eef][\+\-]?\d+)?/i)) { numberLiteral = true; }
145
+ if (stream.match(/^\d+\.(?!\.)\d*/)) { numberLiteral = true; }
146
+ if (stream.match(/^\.\d+/)) { numberLiteral = true; }
147
+ if (stream.match(/^0x\.[0-9a-f]+p[\+\-]?\d+/i)) { numberLiteral = true; }
152
148
  // Integers
153
- var intLiteral = false;
154
- // Hex
155
- if (stream.match(/^0x[0-9a-f]+/i)) { intLiteral = true; }
156
- // Binary
157
- if (stream.match(/^0b[01]+/i)) { intLiteral = true; }
158
- // Octal
159
- if (stream.match(/^0o[0-7]+/i)) { intLiteral = true; }
160
- // Decimal
161
- if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) {
162
- intLiteral = true;
163
- }
149
+ if (stream.match(/^0x[0-9a-f]+/i)) { numberLiteral = true; } // Hex
150
+ if (stream.match(/^0b[01]+/i)) { numberLiteral = true; } // Binary
151
+ if (stream.match(/^0o[0-7]+/i)) { numberLiteral = true; } // Octal
152
+ if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) { numberLiteral = true; } // Decimal
164
153
  // Zero by itself with no other piece of number.
165
- if (stream.match(/^0(?![\dx])/i)) { intLiteral = true; }
166
- if (intLiteral) {
154
+ if (stream.match(/^0(?![\dx])/i)) { numberLiteral = true; }
155
+ if (numberLiteral) {
167
156
  // Integer literals may be "long"
168
157
  stream.match(imMatcher);
169
158
  state.leavingExpr = true;
@@ -194,6 +183,12 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
194
183
  return 'operator';
195
184
  }
196
185
 
186
+ // Handle Chars
187
+ if (stream.match(/^'/)) {
188
+ state.tokenize = tokenChar;
189
+ return state.tokenize(stream, state);
190
+ }
191
+
197
192
  // Handle Strings
198
193
  if (stream.match(stringPrefixes)) {
199
194
  state.tokenize = tokenStringFactory(stream.current());
@@ -269,7 +264,7 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
269
264
  // over two or more lines.
270
265
  if (stream.match(/^$/g, false)) {
271
266
  stream.backUp(state.charsAdvanced);
272
- while (state.scopes.length > state.firstParenPos + 1)
267
+ while (state.scopes.length > state.firstParenPos)
273
268
  state.scopes.pop();
274
269
  state.firstParenPos = -1;
275
270
  state.charsAdvanced = 0;
@@ -279,33 +274,65 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
279
274
  return callOrDef(stream, state);
280
275
  }
281
276
 
277
+ function tokenComment(stream, state) {
278
+ if (stream.match(/^#=/)) {
279
+ state.weakScopes++;
280
+ }
281
+ if (!stream.match(/.*?(?=(#=|=#))/)) {
282
+ stream.skipToEnd();
283
+ }
284
+ if (stream.match(/^=#/)) {
285
+ state.weakScopes--;
286
+ if (state.weakScopes == 0)
287
+ state.tokenize = tokenBase;
288
+ }
289
+ return 'comment';
290
+ }
291
+
292
+ function tokenChar(stream, state) {
293
+ var isChar = false, match;
294
+ if (stream.match(chars)) {
295
+ isChar = true;
296
+ } else if (match = stream.match(/\\u([a-f0-9]{1,4})(?=')/i)) {
297
+ var value = parseInt(match[1], 16);
298
+ if (value <= 55295 || value >= 57344) { // (U+0,U+D7FF), (U+E000,U+FFFF)
299
+ isChar = true;
300
+ stream.next();
301
+ }
302
+ } else if (match = stream.match(/\\U([A-Fa-f0-9]{5,8})(?=')/)) {
303
+ var value = parseInt(match[1], 16);
304
+ if (value <= 1114111) { // U+10FFFF
305
+ isChar = true;
306
+ stream.next();
307
+ }
308
+ }
309
+ if (isChar) {
310
+ state.leavingExpr = true;
311
+ state.tokenize = tokenBase;
312
+ return 'string';
313
+ }
314
+ if (!stream.match(/^[^']+(?=')/)) { stream.skipToEnd(); }
315
+ if (stream.match(/^'/)) { state.tokenize = tokenBase; }
316
+ return ERRORCLASS;
317
+ }
318
+
282
319
  function tokenStringFactory(delimiter) {
283
320
  while ('bruv'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) {
284
321
  delimiter = delimiter.substr(1);
285
322
  }
286
- var singleline = delimiter == "'";
287
323
  var OUTCLASS = 'string';
288
324
 
289
325
  function tokenString(stream, state) {
290
326
  while (!stream.eol()) {
291
- stream.eatWhile(/[^'"\\]/);
327
+ stream.eatWhile(/[^"\\]/);
292
328
  if (stream.eat('\\')) {
293
329
  stream.next();
294
- if (singleline && stream.eol()) {
295
- return OUTCLASS;
296
- }
297
330
  } else if (stream.match(delimiter)) {
298
331
  state.tokenize = tokenBase;
332
+ state.leavingExpr = true;
299
333
  return OUTCLASS;
300
334
  } else {
301
- stream.eat(/['"]/);
302
- }
303
- }
304
- if (singleline) {
305
- if (parserConf.singleLineStringErrors) {
306
- return ERRORCLASS;
307
- } else {
308
- state.tokenize = tokenBase;
335
+ stream.eat(/["]/);
309
336
  }
310
337
  }
311
338
  return OUTCLASS;
@@ -319,6 +346,7 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
319
346
  return {
320
347
  tokenize: tokenBase,
321
348
  scopes: [],
349
+ weakScopes: 0,
322
350
  lastToken: null,
323
351
  leavingExpr: false,
324
352
  isDefinition: false,
@@ -345,15 +373,15 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
345
373
 
346
374
  indent: function(state, textAfter) {
347
375
  var delta = 0;
348
- if (textAfter == "end" || textAfter == "]" || textAfter == "}" || textAfter == "else" || textAfter == "elseif" || textAfter == "catch" || textAfter == "finally") {
376
+ if (textAfter == "]" || textAfter == ")" || textAfter == "end" || textAfter == "else" || textAfter == "elseif" || textAfter == "catch" || textAfter == "finally") {
349
377
  delta = -1;
350
378
  }
351
379
  return (state.scopes.length + delta) * _conf.indentUnit;
352
380
  },
353
381
 
382
+ electricInput: /(end|else(if)?|catch|finally)$/,
354
383
  lineComment: "#",
355
- fold: "indent",
356
- electricChars: "edlsifyh]}"
384
+ fold: "indent"
357
385
  };
358
386
  return external;
359
387
  });
@@ -13,8 +13,8 @@
13
13
 
14
14
  CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
15
15
 
16
- var htmlFound = CodeMirror.modes.hasOwnProperty("xml");
17
- var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? {name: "xml", htmlMode: true} : "text/plain");
16
+ var htmlMode = CodeMirror.getMode(cmCfg, "text/html");
17
+ var htmlModeMissing = htmlMode.name == "null"
18
18
 
19
19
  function getMode(name) {
20
20
  if (CodeMirror.findModeByName) {
@@ -55,8 +55,6 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
55
55
  if (modeCfg.tokenTypeOverrides === undefined)
56
56
  modeCfg.tokenTypeOverrides = {};
57
57
 
58
- var codeDepth = 0;
59
-
60
58
  var tokenTypes = {
61
59
  header: "header",
62
60
  code: "comment",
@@ -121,7 +119,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
121
119
  state.quote = 0;
122
120
  // Reset state.indentedCode
123
121
  state.indentedCode = false;
124
- if (!htmlFound && state.f == htmlBlock) {
122
+ if (htmlModeMissing && state.f == htmlBlock) {
125
123
  state.f = inlineNormal;
126
124
  state.block = blockNormal;
127
125
  }
@@ -215,7 +213,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
215
213
  if (state.localMode) state.localState = state.localMode.startState();
216
214
  state.f = state.block = local;
217
215
  if (modeCfg.highlightFormatting) state.formatting = "code-block";
218
- state.code = true;
216
+ state.code = -1
219
217
  return getType(state);
220
218
  }
221
219
 
@@ -224,12 +222,15 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
224
222
 
225
223
  function htmlBlock(stream, state) {
226
224
  var style = htmlMode.token(stream, state.htmlState);
227
- if ((htmlFound && state.htmlState.tagStart === null &&
228
- (!state.htmlState.context && state.htmlState.tokenize.isInText)) ||
229
- (state.md_inside && stream.current().indexOf(">") > -1)) {
230
- state.f = inlineNormal;
231
- state.block = blockNormal;
232
- state.htmlState = null;
225
+ if (!htmlModeMissing) {
226
+ var inner = CodeMirror.innerMode(htmlMode, state.htmlState)
227
+ if ((inner.mode.name == "xml" && inner.state.tagStart === null &&
228
+ (!inner.state.context && inner.state.tokenize.isInText)) ||
229
+ (state.md_inside && stream.current().indexOf(">") > -1)) {
230
+ state.f = inlineNormal;
231
+ state.block = blockNormal;
232
+ state.htmlState = null;
233
+ }
233
234
  }
234
235
  return style;
235
236
  }
@@ -253,9 +254,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
253
254
  state.f = inlineNormal;
254
255
  state.fencedChars = null;
255
256
  if (modeCfg.highlightFormatting) state.formatting = "code-block";
256
- state.code = true;
257
+ state.code = 1
257
258
  var returnType = getType(state);
258
- state.code = false;
259
+ state.code = 0
259
260
  return returnType;
260
261
  }
261
262
 
@@ -378,15 +379,6 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
378
379
 
379
380
  var ch = stream.next();
380
381
 
381
- if (ch === '\\') {
382
- stream.next();
383
- if (modeCfg.highlightFormatting) {
384
- var type = getType(state);
385
- var formattingEscape = tokenTypes.formatting + "-escape";
386
- return type ? type + " " + formattingEscape : formattingEscape;
387
- }
388
- }
389
-
390
382
  // Matches link titles present on next line
391
383
  if (state.linkTitle) {
392
384
  state.linkTitle = false;
@@ -405,26 +397,32 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
405
397
  if (ch === '`') {
406
398
  var previousFormatting = state.formatting;
407
399
  if (modeCfg.highlightFormatting) state.formatting = "code";
408
- var t = getType(state);
409
- var before = stream.pos;
410
400
  stream.eatWhile('`');
411
- var difference = 1 + stream.pos - before;
412
- if (!state.code) {
413
- codeDepth = difference;
414
- state.code = true;
415
- return getType(state);
401
+ var count = stream.current().length
402
+ if (state.code == 0) {
403
+ state.code = count
404
+ return getType(state)
405
+ } else if (count == state.code) { // Must be exact
406
+ var t = getType(state)
407
+ state.code = 0
408
+ return t
416
409
  } else {
417
- if (difference === codeDepth) { // Must be exact
418
- state.code = false;
419
- return t;
420
- }
421
- state.formatting = previousFormatting;
422
- return getType(state);
410
+ state.formatting = previousFormatting
411
+ return getType(state)
423
412
  }
424
413
  } else if (state.code) {
425
414
  return getType(state);
426
415
  }
427
416
 
417
+ if (ch === '\\') {
418
+ stream.next();
419
+ if (modeCfg.highlightFormatting) {
420
+ var type = getType(state);
421
+ var formattingEscape = tokenTypes.formatting + "-escape";
422
+ return type ? type + " " + formattingEscape : formattingEscape;
423
+ }
424
+ }
425
+
428
426
  if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
429
427
  stream.match(/\[[^\]]*\]/);
430
428
  state.inline = state.f = linkHref;
@@ -692,6 +690,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
692
690
  linkText: false,
693
691
  linkHref: false,
694
692
  linkTitle: false,
693
+ code: 0,
695
694
  em: false,
696
695
  strong: false,
697
696
  header: 0,
@@ -53,7 +53,7 @@
53
53
  var doubleDelimiters = parserConf.doubleDelimiters || /^(\+=|\-=|\*=|%=|\/=|&=|\|=|\^=)/;
54
54
  var tripleDelimiters = parserConf.tripleDelimiters || /^(\/\/=|>>=|<<=|\*\*=)/;
55
55
 
56
- if (parserConf.version && parseInt(parserConf.version, 10) == 3){
56
+ if (parserConf.version && parseInt(parserConf.version, 10) == 3) {
57
57
  // since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator
58
58
  var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!@]/;
59
59
  var identifiers = parserConf.identifiers|| /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/;
@@ -65,12 +65,12 @@
65
65
  var hangingIndent = parserConf.hangingIndent || conf.indentUnit;
66
66
 
67
67
  var myKeywords = commonKeywords, myBuiltins = commonBuiltins;
68
- if(parserConf.extra_keywords != undefined){
68
+ if (parserConf.extra_keywords != undefined)
69
69
  myKeywords = myKeywords.concat(parserConf.extra_keywords);
70
- }
71
- if(parserConf.extra_builtins != undefined){
70
+
71
+ if (parserConf.extra_builtins != undefined)
72
72
  myBuiltins = myBuiltins.concat(parserConf.extra_builtins);
73
- }
73
+
74
74
  if (parserConf.version && parseInt(parserConf.version, 10) == 3) {
75
75
  myKeywords = myKeywords.concat(py3.keywords);
76
76
  myBuiltins = myBuiltins.concat(py3.builtins);
@@ -85,13 +85,14 @@
85
85
 
86
86
  // tokenizers
87
87
  function tokenBase(stream, state) {
88
+ if (stream.sol()) state.indent = stream.indentation()
88
89
  // Handle scope changes
89
90
  if (stream.sol() && top(state).type == "py") {
90
91
  var scopeOffset = top(state).offset;
91
92
  if (stream.eatSpace()) {
92
93
  var lineOffset = stream.indentation();
93
94
  if (lineOffset > scopeOffset)
94
- pushScope(stream, state, "py");
95
+ pushPyScope(state);
95
96
  else if (lineOffset < scopeOffset && dedent(stream, state))
96
97
  state.errorToken = true;
97
98
  return null;
@@ -224,16 +225,18 @@
224
225
  return tokenString;
225
226
  }
226
227
 
227
- function pushScope(stream, state, type) {
228
- var offset = 0, align = null;
229
- if (type == "py") {
230
- while (top(state).type != "py")
231
- state.scopes.pop();
232
- }
233
- offset = top(state).offset + (type == "py" ? conf.indentUnit : hangingIndent);
234
- if (type != "py" && !stream.match(/^(\s|#.*)*$/, false))
235
- align = stream.column() + 1;
236
- state.scopes.push({offset: offset, type: type, align: align});
228
+ function pushPyScope(state) {
229
+ while (top(state).type != "py") state.scopes.pop()
230
+ state.scopes.push({offset: top(state).offset + conf.indentUnit,
231
+ type: "py",
232
+ align: null})
233
+ }
234
+
235
+ function pushBracketScope(stream, state, type) {
236
+ var align = stream.match(/^([\s\[\{\(]|#.*)*$/, false) ? null : stream.column() + 1
237
+ state.scopes.push({offset: state.indent + hangingIndent,
238
+ type: type,
239
+ align: align})
237
240
  }
238
241
 
239
242
  function dedent(stream, state) {
@@ -250,12 +253,11 @@
250
253
  var current = stream.current();
251
254
 
252
255
  // Handle decorators
253
- if (current == "@"){
254
- if(parserConf.version && parseInt(parserConf.version, 10) == 3){
255
- return stream.match(identifiers, false) ? "meta" : "operator";
256
- } else {
257
- return stream.match(identifiers, false) ? "meta" : ERRORCLASS;
258
- }
256
+ if (current == "@") {
257
+ if (parserConf.version && parseInt(parserConf.version, 10) == 3)
258
+ return stream.match(identifiers, false) ? "meta" : "operator";
259
+ else
260
+ return stream.match(identifiers, false) ? "meta" : ERRORCLASS;
259
261
  }
260
262
 
261
263
  if ((style == "variable" || style == "builtin")
@@ -268,15 +270,15 @@
268
270
 
269
271
  if (current == "lambda") state.lambda = true;
270
272
  if (current == ":" && !state.lambda && top(state).type == "py")
271
- pushScope(stream, state, "py");
273
+ pushPyScope(state);
272
274
 
273
275
  var delimiter_index = current.length == 1 ? "[({".indexOf(current) : -1;
274
276
  if (delimiter_index != -1)
275
- pushScope(stream, state, "])}".slice(delimiter_index, delimiter_index+1));
277
+ pushBracketScope(stream, state, "])}".slice(delimiter_index, delimiter_index+1));
276
278
 
277
279
  delimiter_index = "])}".indexOf(current);
278
280
  if (delimiter_index != -1) {
279
- if (top(state).type == current) state.scopes.pop();
281
+ if (top(state).type == current) state.indent = state.scopes.pop().offset - hangingIndent
280
282
  else return ERRORCLASS;
281
283
  }
282
284
  if (state.dedent > 0 && stream.eol() && top(state).type == "py") {
@@ -292,6 +294,7 @@
292
294
  return {
293
295
  tokenize: tokenBase,
294
296
  scopes: [{offset: basecolumn || 0, type: "py", align: null}],
297
+ indent: basecolumn || 0,
295
298
  lastToken: null,
296
299
  lambda: false,
297
300
  dedent: 0
@@ -316,16 +319,14 @@
316
319
  if (state.tokenize != tokenBase)
317
320
  return state.tokenize.isString ? CodeMirror.Pass : 0;
318
321
 
319
- var scope = top(state);
320
- var closing = textAfter && textAfter.charAt(0) == scope.type;
322
+ var scope = top(state), closing = scope.type == textAfter.charAt(0)
321
323
  if (scope.align != null)
322
- return scope.align - (closing ? 1 : 0);
323
- else if (closing && state.scopes.length > 1)
324
- return state.scopes[state.scopes.length - 2].offset;
324
+ return scope.align - (closing ? 1 : 0)
325
325
  else
326
- return scope.offset;
326
+ return scope.offset - (closing ? hangingIndent : 0)
327
327
  },
328
328
 
329
+ electricInput: /^\s*[\}\]\)]$/,
329
330
  closeBrackets: {triples: "'\""},
330
331
  lineComment: "#",
331
332
  fold: "indent"
@@ -135,7 +135,11 @@ CodeMirror.defineMode("sparql", function(config) {
135
135
  else if (curPunc == "{") pushContext(state, "}", stream.column());
136
136
  else if (/[\]\}\)]/.test(curPunc)) {
137
137
  while (state.context && state.context.type == "pattern") popContext(state);
138
- if (state.context && curPunc == state.context.type) popContext(state);
138
+ if (state.context && curPunc == state.context.type) {
139
+ popContext(state);
140
+ if (curPunc == "}" && state.context && state.context.type == "pattern")
141
+ popContext(state);
142
+ }
139
143
  }
140
144
  else if (curPunc == "." && state.context && state.context.type == "pattern") popContext(state);
141
145
  else if (/atom|string|variable/.test(style) && state.context) {
@@ -70,7 +70,10 @@
70
70
  return "operator";
71
71
  case "\\":
72
72
  if (stream.match(/\\[a-z]+/)) return "string-2";
73
- else return null;
73
+ else {
74
+ stream.next();
75
+ return "atom";
76
+ }
74
77
  case ".":
75
78
  case ",":
76
79
  case ";":
@@ -257,7 +257,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
257
257
  }
258
258
 
259
259
  // these keywords are used by all SQL dialects (however, a mode can still overwrite it)
260
- var sqlKeywords = "alter and as asc between by count create delete desc distinct drop from group having in insert into is join like not on or order select set table union update values where limit";
260
+ var sqlKeywords = "alter and as asc between by count create delete desc distinct drop from group having in insert into is join like not on or order select set table union update values where limit ";
261
261
 
262
262
  // turn a space-separated list into an array
263
263
  function set(str) {
@@ -357,6 +357,20 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
357
357
  dateSQL: set("date timestamp"),
358
358
  support: set("ODBCdotTable doubleQuote binaryNumber hexNumber")
359
359
  });
360
+
361
+ CodeMirror.defineMIME("text/x-pgsql", {
362
+ name: "sql",
363
+ client: set("source"),
364
+ // http://www.postgresql.org/docs/9.5/static/sql-keywords-appendix.html
365
+ keywords: set(sqlKeywords + "a abort abs absent absolute access according action ada add admin after aggregate all allocate also always analyse analyze any are array array_agg array_max_cardinality asensitive assertion assignment asymmetric at atomic attribute attributes authorization avg backward base64 before begin begin_frame begin_partition bernoulli binary bit_length blob blocked bom both breadth c cache call called cardinality cascade cascaded case cast catalog catalog_name ceil ceiling chain characteristics characters character_length character_set_catalog character_set_name character_set_schema char_length check checkpoint class class_origin clob close cluster coalesce cobol collate collation collation_catalog collation_name collation_schema collect column columns column_name command_function command_function_code comment comments commit committed concurrently condition condition_number configuration conflict connect connection connection_name constraint constraints constraint_catalog constraint_name constraint_schema constructor contains content continue control conversion convert copy corr corresponding cost covar_pop covar_samp cross csv cube cume_dist current current_catalog current_date current_default_transform_group current_path current_role current_row current_schema current_time current_timestamp current_transform_group_for_type current_user cursor cursor_name cycle data database datalink datetime_interval_code datetime_interval_precision day db deallocate dec declare default defaults deferrable deferred defined definer degree delimiter delimiters dense_rank depth deref derived describe descriptor deterministic diagnostics dictionary disable discard disconnect dispatch dlnewcopy dlpreviouscopy dlurlcomplete dlurlcompleteonly dlurlcompletewrite dlurlpath dlurlpathonly dlurlpathwrite dlurlscheme dlurlserver dlvalue do document domain dynamic dynamic_function dynamic_function_code each element else empty enable encoding encrypted end end-exec end_frame end_partition enforced enum equals escape event every except exception exclude excluding exclusive exec execute exists exp explain expression extension external extract false family fetch file filter final first first_value flag float floor following for force foreign fortran forward found frame_row free freeze fs full function functions fusion g general generated get global go goto grant granted greatest grouping groups handler header hex hierarchy hold hour id identity if ignore ilike immediate immediately immutable implementation implicit import including increment indent index indexes indicator inherit inherits initially inline inner inout input insensitive instance instantiable instead integrity intersect intersection invoker isnull isolation k key key_member key_type label lag language large last last_value lateral lead leading leakproof least left length level library like_regex link listen ln load local localtime localtimestamp location locator lock locked logged lower m map mapping match matched materialized max maxvalue max_cardinality member merge message_length message_octet_length message_text method min minute minvalue mod mode modifies module month more move multiset mumps name names namespace national natural nchar nclob nesting new next nfc nfd nfkc nfkd nil no none normalize normalized nothing notify notnull nowait nth_value ntile null nullable nullif nulls number object occurrences_regex octets octet_length of off offset oids old only open operator option options ordering ordinality others out outer output over overlaps overlay overriding owned owner p pad parameter parameter_mode parameter_name parameter_ordinal_position parameter_specific_catalog parameter_specific_name parameter_specific_schema parser partial partition pascal passing passthrough password percent percentile_cont percentile_disc percent_rank period permission placing plans pli policy portion position position_regex power precedes preceding prepare prepared preserve primary prior privileges procedural procedure program public quote range rank read reads reassign recheck recovery recursive ref references referencing refresh regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex relative release rename repeatable replace replica requiring reset respect restart restore restrict result return returned_cardinality returned_length returned_octet_length returned_sqlstate returning returns revoke right role rollback rollup routine routine_catalog routine_name routine_schema row rows row_count row_number rule savepoint scale schema schema_name scope scope_catalog scope_name scope_schema scroll search second section security selective self sensitive sequence sequences serializable server server_name session session_user setof sets share show similar simple size skip snapshot some source space specific specifictype specific_name sql sqlcode sqlerror sqlexception sqlstate sqlwarning sqrt stable standalone start state statement static statistics stddev_pop stddev_samp stdin stdout storage strict strip structure style subclass_origin submultiset substring substring_regex succeeds sum symmetric sysid system system_time system_user t tables tablesample tablespace table_name temp template temporary then ties timezone_hour timezone_minute to token top_level_count trailing transaction transactions_committed transactions_rolled_back transaction_active transform transforms translate translate_regex translation treat trigger trigger_catalog trigger_name trigger_schema trim trim_array true truncate trusted type types uescape unbounded uncommitted under unencrypted unique unknown unlink unlisten unlogged unnamed unnest until untyped upper uri usage user user_defined_type_catalog user_defined_type_code user_defined_type_name user_defined_type_schema using vacuum valid validate validator value value_of varbinary variadic var_pop var_samp verbose version versioning view views volatile when whenever whitespace width_bucket window within work wrapper write xmlagg xmlattributes xmlbinary xmlcast xmlcomment xmlconcat xmldeclaration xmldocument xmlelement xmlexists xmlforest xmliterate xmlnamespaces xmlparse xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltext xmlvalidate year yes loop repeat"),
366
+ // http://www.postgresql.org/docs/9.5/static/datatype.html
367
+ builtin: set("bigint int8 bigserial serial8 bit varying varbit boolean bool box bytea character char varchar cidr circle date double precision float8 inet integer int int4 interval json jsonb line lseg macaddr money numeric decimal path pg_lsn point polygon real float4 smallint int2 smallserial serial2 serial serial4 text time without zone with timetz timestamp timestamptz tsquery tsvector txid_snapshot uuid xml"),
368
+ atoms: set("false true null unknown"),
369
+ operatorChars: /^[*+\-%<>!=&|^]/,
370
+ dateSQL: set("date time timestamp"),
371
+ support: set("ODBCdotTable decimallessFloat zerolessFloat binaryNumber hexNumber nCharCast charsetCast commentHash commentSpaceRequired")
372
+ });
373
+
360
374
  }());
361
375
 
362
376
  });
@@ -237,7 +237,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
237
237
  if (state.context && state.context.tagName != tagName &&
238
238
  config.implicitlyClosed.hasOwnProperty(state.context.tagName))
239
239
  popContext(state);
240
- if (state.context && state.context.tagName == tagName) {
240
+ if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) {
241
241
  setStyle = "tag";
242
242
  return closeState;
243
243
  } else {
@@ -197,6 +197,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
197
197
  white-space: normal;
198
198
  height: 100%;
199
199
  display: inline-block;
200
+ vertical-align: top;
200
201
  margin-bottom: -30px;
201
202
  /* Hack to make IE7 behave */
202
203
  *zoom:1;
@@ -60,6 +60,7 @@
60
60
  position: absolute;
61
61
  cursor: pointer;
62
62
  color: #44c;
63
+ z-index: 3;
63
64
  }
64
65
 
65
66
  .CodeMirror-merge-copy-reverse {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codemirror-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.11.1
4
+ version: '5.12'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Fixler
@@ -176,6 +176,7 @@ files:
176
176
  - vendor/assets/javascripts/codemirror/modes/elm.js
177
177
  - vendor/assets/javascripts/codemirror/modes/erlang.js
178
178
  - vendor/assets/javascripts/codemirror/modes/factor.js
179
+ - vendor/assets/javascripts/codemirror/modes/fcl.js
179
180
  - vendor/assets/javascripts/codemirror/modes/forth.js
180
181
  - vendor/assets/javascripts/codemirror/modes/fortran.js
181
182
  - vendor/assets/javascripts/codemirror/modes/gas.js