codemirror-rails 2.3 → 2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. data/README.md +0 -16
  2. data/codemirror-rails.gemspec +1 -1
  3. data/lib/codemirror/rails/version.rb +2 -2
  4. data/vendor/assets/javascripts/codemirror.js +323 -687
  5. data/vendor/assets/javascripts/codemirror/modes/clike.js +3 -40
  6. data/vendor/assets/javascripts/codemirror/modes/clojure.js +14 -14
  7. data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +0 -6
  8. data/vendor/assets/javascripts/codemirror/modes/css.js +1 -1
  9. data/vendor/assets/javascripts/codemirror/modes/diff.js +5 -24
  10. data/vendor/assets/javascripts/codemirror/modes/gfm.js +4 -40
  11. data/vendor/assets/javascripts/codemirror/modes/go.js +22 -20
  12. data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +1 -1
  13. data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +2 -4
  14. data/vendor/assets/javascripts/codemirror/modes/javascript.js +7 -8
  15. data/vendor/assets/javascripts/codemirror/modes/less.js +54 -100
  16. data/vendor/assets/javascripts/codemirror/modes/markdown.js +49 -52
  17. data/vendor/assets/javascripts/codemirror/modes/pascal.js +46 -2
  18. data/vendor/assets/javascripts/codemirror/modes/perl.js +1 -1
  19. data/vendor/assets/javascripts/codemirror/modes/php.js +25 -54
  20. data/vendor/assets/javascripts/codemirror/modes/python.js +16 -14
  21. data/vendor/assets/javascripts/codemirror/modes/rpm-spec.js +1 -1
  22. data/vendor/assets/javascripts/codemirror/modes/rst.js +1 -1
  23. data/vendor/assets/javascripts/codemirror/modes/ruby.js +9 -4
  24. data/vendor/assets/javascripts/codemirror/modes/scheme.js +46 -74
  25. data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +16 -16
  26. data/vendor/assets/javascripts/codemirror/modes/stex.js +6 -21
  27. data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +45 -55
  28. data/vendor/assets/javascripts/codemirror/modes/xml.js +14 -79
  29. data/vendor/assets/javascripts/codemirror/{utils/overlay.js → overlay.js} +2 -3
  30. data/vendor/assets/javascripts/codemirror/runmode.js +27 -0
  31. data/vendor/assets/stylesheets/codemirror.css +2 -63
  32. data/vendor/assets/stylesheets/codemirror/modes/tiddlywiki.css +21 -14
  33. data/vendor/assets/stylesheets/codemirror/themes/eclipse.css +1 -1
  34. data/vendor/assets/stylesheets/codemirror/themes/elegant.css +2 -2
  35. data/vendor/assets/stylesheets/codemirror/themes/neat.css +3 -3
  36. data/vendor/assets/stylesheets/codemirror/themes/night.css +1 -1
  37. data/vendor/assets/stylesheets/codemirror/themes/rubyblue.css +2 -2
  38. metadata +6 -39
  39. data/vendor/assets/javascripts/codemirror/keymaps/emacs.js +0 -29
  40. data/vendor/assets/javascripts/codemirror/keymaps/vim.js +0 -766
  41. data/vendor/assets/javascripts/codemirror/modes/ecl.js +0 -203
  42. data/vendor/assets/javascripts/codemirror/modes/erlang.js +0 -251
  43. data/vendor/assets/javascripts/codemirror/modes/pig.js +0 -172
  44. data/vendor/assets/javascripts/codemirror/modes/properties.js +0 -63
  45. data/vendor/assets/javascripts/codemirror/modes/shell.js +0 -103
  46. data/vendor/assets/javascripts/codemirror/modes/smarty.js +0 -148
  47. data/vendor/assets/javascripts/codemirror/modes/tiki.js +0 -316
  48. data/vendor/assets/javascripts/codemirror/modes/vbscript.js +0 -26
  49. data/vendor/assets/javascripts/codemirror/modes/xquery.js +0 -448
  50. data/vendor/assets/javascripts/codemirror/utils/closetag.js +0 -146
  51. data/vendor/assets/javascripts/codemirror/utils/dialog.js +0 -63
  52. data/vendor/assets/javascripts/codemirror/utils/foldcode.js +0 -196
  53. data/vendor/assets/javascripts/codemirror/utils/formatting.js +0 -297
  54. data/vendor/assets/javascripts/codemirror/utils/javascript-hint.js +0 -134
  55. data/vendor/assets/javascripts/codemirror/utils/loadmode.js +0 -51
  56. data/vendor/assets/javascripts/codemirror/utils/match-highlighter.js +0 -44
  57. data/vendor/assets/javascripts/codemirror/utils/multiplex.js +0 -72
  58. data/vendor/assets/javascripts/codemirror/utils/pig-hint.js +0 -123
  59. data/vendor/assets/javascripts/codemirror/utils/runmode.js +0 -49
  60. data/vendor/assets/javascripts/codemirror/utils/search.js +0 -118
  61. data/vendor/assets/javascripts/codemirror/utils/searchcursor.js +0 -117
  62. data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +0 -72
  63. data/vendor/assets/stylesheets/codemirror/modes/tiki.css +0 -26
  64. data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +0 -81
  65. data/vendor/assets/stylesheets/codemirror/themes/blackboard.css +0 -25
  66. data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +0 -21
  67. data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +0 -44
  68. data/vendor/assets/stylesheets/codemirror/themes/vibrant-ink.css +0 -27
  69. data/vendor/assets/stylesheets/codemirror/themes/xq-dark.css +0 -46
  70. data/vendor/assets/stylesheets/codemirror/utils/dialog.css +0 -23
  71. data/vendor/assets/stylesheets/codemirror/utils/simple-hint.css +0 -16
@@ -21,7 +21,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
21
21
  }
22
22
  if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
23
23
  curPunc = ch;
24
- return null;
24
+ return null
25
25
  }
26
26
  if (/\d/.test(ch)) {
27
27
  stream.eatWhile(/[\w\.]/);
@@ -59,7 +59,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
59
59
  escaped = !escaped && next == "\\";
60
60
  }
61
61
  if (end || !(escaped || multiLineStrings))
62
- state.tokenize = null;
62
+ state.tokenize = tokenBase;
63
63
  return "string";
64
64
  };
65
65
  }
@@ -68,7 +68,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
68
68
  var maybeEnd = false, ch;
69
69
  while (ch = stream.next()) {
70
70
  if (ch == "/" && maybeEnd) {
71
- state.tokenize = null;
71
+ state.tokenize = tokenBase;
72
72
  break;
73
73
  }
74
74
  maybeEnd = (ch == "*");
@@ -231,41 +231,4 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
231
231
  }
232
232
  }
233
233
  });
234
- CodeMirror.defineMIME("text/x-scala", {
235
- name: "clike",
236
- keywords: words(
237
-
238
- /* scala */
239
- "abstract case catch class def do else extends false final finally for forSome if " +
240
- "implicit import lazy match new null object override package private protected return " +
241
- "sealed super this throw trait try trye type val var while with yield _ : = => <- <: " +
242
- "<% >: # @ " +
243
-
244
- /* package scala */
245
- "assert assume require print println printf readLine readBoolean readByte readShort " +
246
- "readChar readInt readLong readFloat readDouble " +
247
-
248
- "AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
249
- "Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
250
- "Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
251
- "Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
252
- "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector :: #:: " +
253
-
254
- /* package java.lang */
255
- "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
256
- "Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
257
- "Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
258
- "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
259
-
260
-
261
- ),
262
- blockKeywords: words("catch class do else finally for forSome if match switch try while"),
263
- atoms: words("true false null"),
264
- hooks: {
265
- "@": function(stream, state) {
266
- stream.eatWhile(/[\w\$_]/);
267
- return "meta";
268
- }
269
- }
270
- });
271
234
  }());
@@ -4,7 +4,7 @@
4
4
  */
5
5
  CodeMirror.defineMode("clojure", function (config, mode) {
6
6
  var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", TAG = "tag",
7
- ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword";
7
+ ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD="keyword";
8
8
  var INDENT_WORD_SKIP = 2, KEYWORDS_SKIP = 1;
9
9
 
10
10
  function makeKeywords(str) {
@@ -14,25 +14,26 @@ CodeMirror.defineMode("clojure", function (config, mode) {
14
14
  }
15
15
 
16
16
  var atoms = makeKeywords("true false nil");
17
-
17
+
18
18
  var keywords = makeKeywords(
19
- "defn defn- def def- defonce defmulti defmethod defmacro defstruct deftype defprotocol defrecord defproject deftest slice defalias defhinted defmacro- defn-memo defnk defnk defonce- defunbound defunbound- defvar defvar- let letfn do case cond condp for loop recur when when-not when-let when-first if if-let if-not . .. -> ->> doto and or dosync doseq dotimes dorun doall load import unimport ns in-ns refer try catch finally throw with-open with-local-vars binding gen-class gen-and-load-class gen-and-save-class handler-case handle");
19
+ // Control structures
20
+ "defn defn- def def- defonce defmulti defmethod defmacro defstruct deftype defprotocol defrecord deftest slice defalias defhinted defmacro- defn-memo defnk defnk defonce- defunbound defunbound- defvar defvar- let letfn do case cond condp for loop recur when when-not when-let when-first if if-let if-not . .. -> ->> doto and or dosync doseq dotimes dorun doall load import unimport ns in-ns refer try catch finally throw with-open with-local-vars binding gen-class gen-and-load-class gen-and-save-class handler-case handle" +
20
21
 
21
- var builtins = makeKeywords(
22
+ // Built-ins
22
23
  "* *1 *2 *3 *agent* *allow-unresolved-vars* *assert *clojure-version* *command-line-args* *compile-files* *compile-path* *e *err* *file* *flush-on-newline* *in* *macro-meta* *math-context* *ns* *out* *print-dup* *print-length* *print-level* *print-meta* *print-readably* *read-eval* *source-path* *use-context-classloader* *warn-on-reflection* + - / < <= = == > >= accessor aclone agent agent-errors aget alength alias all-ns alter alter-meta! alter-var-root amap ancestors and apply areduce array-map aset aset-boolean aset-byte aset-char aset-double aset-float aset-int aset-long aset-short assert assoc assoc! assoc-in associative? atom await await-for await1 bases bean bigdec bigint binding bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array booleans bound-fn bound-fn* butlast byte byte-array bytes case cast char char-array char-escape-string char-name-string char? chars chunk chunk-append chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? class class? clear-agent-errors clojure-version coll? comment commute comp comparator compare compare-and-set! compile complement concat cond condp conj conj! cons constantly construct-proxy contains? count counted? create-ns create-struct cycle dec decimal? declare definline defmacro defmethod defmulti defn defn- defonce defstruct delay delay? deliver deref derive descendants destructure disj disj! dissoc dissoc! distinct distinct? doall doc dorun doseq dosync dotimes doto double double-array doubles drop drop-last drop-while empty empty? ensure enumeration-seq eval even? every? extend extend-protocol extend-type extends? extenders false? ffirst file-seq filter find find-doc find-ns find-var first float float-array float? floats flush fn fn? fnext for force format future future-call future-cancel future-cancelled? future-done? future? gen-class gen-interface gensym get get-in get-method get-proxy-class get-thread-bindings get-validator hash hash-map hash-set identical? identity if-let if-not ifn? import in-ns inc init-proxy instance? int int-array integer? interleave intern interpose into into-array ints io! isa? iterate iterator-seq juxt key keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list list* list? load load-file load-reader load-string loaded-libs locking long long-array longs loop macroexpand macroexpand-1 make-array make-hierarchy map map? mapcat max max-key memfn memoize merge merge-with meta method-sig methods min min-key mod name namespace neg? newline next nfirst nil? nnext not not-any? not-empty not-every? not= ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ns-refers ns-resolve ns-unalias ns-unmap nth nthnext num number? odd? or parents partial partition pcalls peek persistent! pmap pop pop! pop-thread-bindings pos? pr pr-str prefer-method prefers primitives-classnames print print-ctor print-doc print-dup print-method print-namespace-doc print-simple print-special-doc print-str printf println println-str prn prn-str promise proxy proxy-call-with-super proxy-mappings proxy-name proxy-super push-thread-bindings pvalues quot rand rand-int range ratio? rational? rationalize re-find re-groups re-matcher re-matches re-pattern re-seq read read-line read-string reify reduce ref ref-history-count ref-max-history ref-min-history ref-set refer refer-clojure release-pending-sends rem remove remove-method remove-ns repeat repeatedly replace replicate require reset! reset-meta! resolve rest resultset-seq reverse reversible? rseq rsubseq satisfies? second select-keys send send-off seq seq? seque sequence sequential? set set-validator! set? short short-array shorts shutdown-agents slurp some sort sort-by sorted-map sorted-map-by sorted-set sorted-set-by sorted? special-form-anchor special-symbol? split-at split-with str stream? string? struct struct-map subs subseq subvec supers swap! symbol symbol? sync syntax-symbol-anchor take take-last take-nth take-while test the-ns time to-array to-array-2d trampoline transient tree-seq true? type unchecked-add unchecked-dec unchecked-divide unchecked-inc unchecked-multiply unchecked-negate unchecked-remainder unchecked-subtract underive unquote unquote-splicing update-in update-proxy use val vals var-get var-set var? vary-meta vec vector vector? when when-first when-let when-not while with-bindings with-bindings* with-in-str with-loading-context with-local-vars with-meta with-open with-out-str with-precision xml-seq");
23
24
 
24
25
  var indentKeys = makeKeywords(
25
26
  // Built-ins
26
- "ns fn def defn defmethod bound-fn if if-not case condp when while when-not when-first do future comment doto locking proxy with-open with-precision reify deftype defrecord defprotocol extend extend-protocol extend-type try catch " +
27
+ "ns fn def defn defmethod bound-fn if if-not case condp when while when-not when-first do future comment doto locking proxy with-open with-precision reify deftype defrecord defprotocol extend extend-protocol extend-type try catch" +
27
28
 
28
29
  // Binding forms
29
- "let letfn binding loop for doseq dotimes when-let if-let " +
30
+ "let letfn binding loop for doseq dotimes when-let if-let" +
30
31
 
31
32
  // Data structures
32
- "defstruct struct-map assoc " +
33
+ "defstruct struct-map assoc" +
33
34
 
34
35
  // clojure.test
35
- "testing deftest " +
36
+ "testing deftest" +
36
37
 
37
38
  // contrib
38
39
  "handler-case handle dotrace deftrace");
@@ -102,7 +103,7 @@ CodeMirror.defineMode("clojure", function (config, mode) {
102
103
  return {
103
104
  indentStack: null,
104
105
  indentation: 0,
105
- mode: false
106
+ mode: false,
106
107
  };
107
108
  },
108
109
 
@@ -153,11 +154,12 @@ CodeMirror.defineMode("clojure", function (config, mode) {
153
154
  (;something else, bracket, etc.
154
155
  */
155
156
 
156
- if (ch == "(") while ((letter = stream.eat(tests.keyword_char)) != null) {
157
+ while ((letter = stream.eat(tests.keyword_char)) != null) {
157
158
  keyWord += letter;
158
159
  }
159
160
 
160
161
  if (keyWord.length > 0 && indentKeys.propertyIsEnumerable(keyWord)) { // indent-word
162
+
161
163
  pushStack(state, indentTemp + INDENT_WORD_SKIP, ch);
162
164
  } else { // non-indent word
163
165
  // we continue eating the spaces
@@ -180,15 +182,13 @@ CodeMirror.defineMode("clojure", function (config, mode) {
180
182
  }
181
183
  } else if ( ch == ":" ) {
182
184
  stream.eatWhile(tests.lang_keyword);
183
- return ATOM;
185
+ return TAG;
184
186
  } else {
185
187
  stream.eatWhile(tests.basic);
186
188
 
187
189
  if (keywords && keywords.propertyIsEnumerable(stream.current())) {
188
- returnType = KEYWORD;
189
- } else if (builtins && builtins.propertyIsEnumerable(stream.current())) {
190
190
  returnType = BUILTIN;
191
- } else if (atoms && atoms.propertyIsEnumerable(stream.current())) {
191
+ } else if ( atoms && atoms.propertyIsEnumerable(stream.current()) ) {
192
192
  returnType = ATOM;
193
193
  } else returnType = null;
194
194
  }
@@ -60,12 +60,6 @@ CodeMirror.defineMode('coffeescript', function(conf) {
60
60
 
61
61
  var ch = stream.peek();
62
62
 
63
- // Handle docco title comment (single line)
64
- if (stream.match("####")) {
65
- stream.skipToEnd();
66
- return 'comment';
67
- }
68
-
69
63
  // Handle multi line comments
70
64
  if (stream.match("###")) {
71
65
  state.tokenize = longComment;
@@ -92,7 +92,7 @@ CodeMirror.defineMode("css", function(config) {
92
92
  var style = state.tokenize(stream, state);
93
93
 
94
94
  var context = state.stack[state.stack.length-1];
95
- if (type == "hash" && context != "rule") style = "string-2";
95
+ if (type == "hash" && context == "rule") style = "atom";
96
96
  else if (style == "variable") {
97
97
  if (context == "rule") style = "number";
98
98
  else if (!context || context == "@media{") style = "tag";
@@ -1,30 +1,11 @@
1
1
  CodeMirror.defineMode("diff", function() {
2
-
3
- var TOKEN_NAMES = {
4
- '+': 'tag',
5
- '-': 'string',
6
- '@': 'meta'
7
- };
8
-
9
2
  return {
10
3
  token: function(stream) {
11
- var tw_pos = stream.string.search(/[\t ]+?$/);
12
-
13
- if (!stream.sol() || tw_pos === 0) {
14
- stream.skipToEnd();
15
- return ("error " + (
16
- TOKEN_NAMES[stream.string.charAt(0)] || '')).replace(/ $/, '');
17
- }
18
-
19
- var token_name = TOKEN_NAMES[stream.peek()] || stream.skipToEnd();
20
-
21
- if (tw_pos === -1) {
22
- stream.skipToEnd();
23
- } else {
24
- stream.pos = tw_pos;
25
- }
26
-
27
- return token_name;
4
+ var ch = stream.next();
5
+ stream.skipToEnd();
6
+ if (ch == "+") return "plus";
7
+ if (ch == "-") return "minus";
8
+ if (ch == "@") return "rangeinfo";
28
9
  }
29
10
  };
30
11
  });
@@ -8,7 +8,7 @@ CodeMirror.defineMode("gfm", function(config, parserConfig) {
8
8
  "c++": "text/x-c++src",
9
9
  java: "text/x-java",
10
10
  csharp: "text/x-csharp",
11
- "c#": "text/x-csharp"
11
+ "c#": "text/x-csharp",
12
12
  };
13
13
 
14
14
  // make this lazy so that we don't need to load GFM last
@@ -69,7 +69,7 @@ CodeMirror.defineMode("gfm", function(config, parserConfig) {
69
69
  function handleText(stream, mdState) {
70
70
  var match;
71
71
  if (stream.match(/^\w+:\/\/\S+/)) {
72
- return 'link';
72
+ return 'linkhref';
73
73
  }
74
74
  if (stream.match(/^[^\[*\\<>` _][^\[*\\<>` ]*[^\[*\\<>` _]/)) {
75
75
  return mdMode.getType(mdState);
@@ -102,43 +102,7 @@ CodeMirror.defineMode("gfm", function(config, parserConfig) {
102
102
  },
103
103
 
104
104
  token: function(stream, state) {
105
- /* Parse GFM double bracket links */
106
- if ((ch = stream.peek()) != undefined && ch == '[') {
107
- stream.next(); // Advance the stream
108
-
109
- /* Only handle double bracket links */
110
- if ((ch = stream.peek()) == undefined || ch != '[') {
111
- stream.backUp(1);
112
- return state.token(stream, state);
113
- }
114
-
115
- while ((ch = stream.next()) != undefined && ch != ']') {}
116
-
117
- if (ch == ']' && (ch = stream.next()) != undefined && ch == ']')
118
- return 'link';
119
-
120
- /* If we did not find the second ']' */
121
- stream.backUp(1);
122
- }
123
-
124
- /* Match GFM latex formulas, as well as latex formulas within '$' */
125
- if (stream.match(/^\$[^\$]+\$/)) {
126
- return "string";
127
- }
128
-
129
- if (stream.match(/^\\\((.*?)\\\)/)) {
130
- return "string";
131
- }
132
-
133
- if (stream.match(/^\$\$[^\$]+\$\$/)) {
134
- return "string";
135
- }
136
-
137
- if (stream.match(/^\\\[(.*?)\\\]/)) {
138
- return "string";
139
- }
140
-
141
- return state.token(stream, state);
105
+ return state.token(stream, state);
142
106
  }
143
107
  }
144
- }, "markdown");
108
+ });
@@ -4,20 +4,20 @@ CodeMirror.defineMode("go", function(config, parserConfig) {
4
4
  var keywords = {
5
5
  "break":true, "case":true, "chan":true, "const":true, "continue":true,
6
6
  "default":true, "defer":true, "else":true, "fallthrough":true, "for":true,
7
- "func":true, "go":true, "goto":true, "if":true, "import":true,
8
- "interface":true, "map":true, "package":true, "range":true, "return":true,
9
- "select":true, "struct":true, "switch":true, "type":true, "var":true,
10
- "bool":true, "byte":true, "complex64":true, "complex128":true,
11
- "float32":true, "float64":true, "int8":true, "int16":true, "int32":true,
12
- "int64":true, "string":true, "uint8":true, "uint16":true, "uint32":true,
13
- "uint64":true, "int":true, "uint":true, "uintptr":true
7
+ "func":true, "go":true, "goto":true, "if":true, "import":true, "interface":true,
8
+ "map":true, "package":true, "range":true, "return":true, "select":true,
9
+ "struct":true, "switch":true, "type":true, "var":true, "bool":true, "byte":true,
10
+ "complex64":true, "complex128":true, "float32":true, "float64":true,
11
+ "int8":true, "int16":true, "int32":true, "int64":true, "string":true,
12
+ "uint8":true, "uint16":true, "uint32":true, "uint64":true, "int":true,
13
+ "uint":true, "uintptr":true
14
14
  };
15
15
 
16
16
  var atoms = {
17
17
  "true":true, "false":true, "iota":true, "nil":true, "append":true,
18
- "cap":true, "close":true, "complex":true, "copy":true, "imag":true,
19
- "len":true, "make":true, "new":true, "panic":true, "print":true,
20
- "println":true, "real":true, "recover":true
18
+ "cap":true, "close":true, "complex":true, "copy":true, "imag":true, "len":true,
19
+ "make":true, "new":true, "panic":true, "print":true, "println":true,
20
+ "real":true, "recover":true
21
21
  };
22
22
 
23
23
  var blockKeywords = {
@@ -66,7 +66,7 @@ CodeMirror.defineMode("go", function(config, parserConfig) {
66
66
  stream.eatWhile(/[\w\$_]/);
67
67
  var cur = stream.current();
68
68
  if (keywords.propertyIsEnumerable(cur)) {
69
- if (cur == "case" || cur == "default") curPunc = "case";
69
+ if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
70
70
  return "keyword";
71
71
  }
72
72
  if (atoms.propertyIsEnumerable(cur)) return "atom";
@@ -133,7 +133,6 @@ CodeMirror.defineMode("go", function(config, parserConfig) {
133
133
  if (ctx.align == null) ctx.align = false;
134
134
  state.indented = stream.indentation();
135
135
  state.startOfLine = true;
136
- if (ctx.type == "case") ctx.type = "}";
137
136
  }
138
137
  if (stream.eatSpace()) return null;
139
138
  curPunc = null;
@@ -144,9 +143,14 @@ CodeMirror.defineMode("go", function(config, parserConfig) {
144
143
  if (curPunc == "{") pushContext(state, stream.column(), "}");
145
144
  else if (curPunc == "[") pushContext(state, stream.column(), "]");
146
145
  else if (curPunc == "(") pushContext(state, stream.column(), ")");
147
- else if (curPunc == "case") ctx.type = "case"
148
- else if (curPunc == "}" && ctx.type == "}") ctx = popContext(state);
146
+ else if (curPunc == "}") {
147
+ while (ctx.type == "statement") ctx = popContext(state);
148
+ if (ctx.type == "}") ctx = popContext(state);
149
+ while (ctx.type == "statement") ctx = popContext(state);
150
+ }
149
151
  else if (curPunc == ctx.type) popContext(state);
152
+ else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
153
+ pushContext(state, stream.column(), "statement");
150
154
  state.startOfLine = false;
151
155
  return style;
152
156
  },
@@ -154,16 +158,14 @@ CodeMirror.defineMode("go", function(config, parserConfig) {
154
158
  indent: function(state, textAfter) {
155
159
  if (state.tokenize != tokenBase && state.tokenize != null) return 0;
156
160
  var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
157
- if (ctx.type == "case" && /^(?:case|default)\b/.test(textAfter)) {
158
- state.context.type = "}";
159
- return ctx.indented;
160
- }
161
+ if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
161
162
  var closing = firstChar == ctx.type;
162
- if (ctx.align) return ctx.column + (closing ? 0 : 1);
163
+ if (ctx.type == "statement") return ctx.indented;
164
+ else if (ctx.align) return ctx.column + (closing ? 0 : 1);
163
165
  else return ctx.indented + (closing ? 0 : indentUnit);
164
166
  },
165
167
 
166
- electricChars: "{}:"
168
+ electricChars: "{}"
167
169
  };
168
170
  });
169
171
 
@@ -61,7 +61,7 @@ CodeMirror.defineMode("htmlembedded", function(config, parserConfig) {
61
61
 
62
62
  electricChars: "/{}:"
63
63
  }
64
- }, "htmlmixed");
64
+ });
65
65
 
66
66
  CodeMirror.defineMIME("application/x-ejs", { name: "htmlembedded", scriptingModeSpec:"javascript"});
67
67
  CodeMirror.defineMIME("application/x-aspx", { name: "htmlembedded", scriptingModeSpec:"text/x-csharp"});
@@ -28,7 +28,7 @@ CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
28
28
  function javascript(stream, state) {
29
29
  if (stream.match(/^<\/\s*script\s*>/i, false)) {
30
30
  state.token = html;
31
- state.localState = null;
31
+ state.curState = null;
32
32
  state.mode = "html";
33
33
  return html(stream, state);
34
34
  }
@@ -73,13 +73,11 @@ CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
73
73
  },
74
74
 
75
75
  compareStates: function(a, b) {
76
- if (a.mode != b.mode) return false;
77
- if (a.localState) return CodeMirror.Pass;
78
76
  return htmlMode.compareStates(a.htmlState, b.htmlState);
79
77
  },
80
78
 
81
79
  electricChars: "/{}:"
82
80
  }
83
- }, "xml", "javascript", "css");
81
+ });
84
82
 
85
83
  CodeMirror.defineMIME("text/html", "htmlmixed");
@@ -54,7 +54,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
54
54
  stream.eatWhile(/[\da-f]/i);
55
55
  return ret("number", "number");
56
56
  }
57
- else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
57
+ else if (/\d/.test(ch)) {
58
58
  stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
59
59
  return ret("number", "number");
60
60
  }
@@ -243,7 +243,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
243
243
 
244
244
  function maybeoperator(type, value) {
245
245
  if (type == "operator" && /\+\+|--/.test(value)) return cont(maybeoperator);
246
- if (type == "operator" || type == ":") return cont(expression);
246
+ if (type == "operator") return cont(expression);
247
247
  if (type == ";") return;
248
248
  if (type == "(") return cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator);
249
249
  if (type == ".") return cont(property, maybeoperator);
@@ -319,8 +319,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
319
319
  kwAllowed: true,
320
320
  cc: [],
321
321
  lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
322
- localVars: parserConfig.localVars,
323
- context: parserConfig.localVars && {vars: parserConfig.localVars},
322
+ localVars: null,
323
+ context: null,
324
324
  indented: 0
325
325
  };
326
326
  },
@@ -334,16 +334,15 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
334
334
  if (stream.eatSpace()) return null;
335
335
  var style = state.tokenize(stream, state);
336
336
  if (type == "comment") return style;
337
- state.reAllowed = !!(type == "operator" || type == "keyword c" || type.match(/^[\[{}\(,;:]$/));
337
+ state.reAllowed = type == "operator" || type == "keyword c" || type.match(/^[\[{}\(,;:]$/);
338
338
  state.kwAllowed = type != '.';
339
339
  return parseJS(state, style, type, content, stream);
340
340
  },
341
341
 
342
342
  indent: function(state, textAfter) {
343
343
  if (state.tokenize != jsTokenBase) return 0;
344
- var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
345
- if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
346
- var type = lexical.type, closing = firstChar == type;
344
+ var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical,
345
+ type = lexical.type, closing = firstChar == type;
347
346
  if (type == "vardef") return lexical.indented + 4;
348
347
  else if (type == "form" && firstChar == "{") return lexical.indented;
349
348
  else if (type == "stat" || type == "form") return lexical.indented + indentUnit;
@@ -1,8 +1,3 @@
1
- /*
2
- LESS mode - http://www.lesscss.org/
3
- Ported to CodeMirror by Peter Kroon
4
- */
5
-
6
1
  CodeMirror.defineMode("less", function(config) {
7
2
  var indentUnit = config.indentUnit, type;
8
3
  function ret(style, tp) {type = tp; return style;}
@@ -10,17 +5,17 @@ CodeMirror.defineMode("less", function(config) {
10
5
  var tags = ["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","command","datalist","dd","del","details","dfn","dir","div","dl","dt","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","keygen","kbd","label","legend","li","link","map","mark","menu","meta","meter","nav","noframes","noscript","object","ol","optgroup","option","output","p","param","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strike","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr"];
11
6
 
12
7
  function inTagsArray(val){
13
- for(var i=0; i<tags.length; i++){
14
- if(val === tags[i]){
15
- return true;
16
- }
17
- }
8
+ for(var i=0; i<tags.length; i++){
9
+ if(val === tags[i]){
10
+ return true;
11
+ }
12
+ }
18
13
  }
19
14
 
20
15
  function tokenBase(stream, state) {
21
16
  var ch = stream.next();
22
17
 
23
- if (ch == "@") {stream.eatWhile(/[\w\-]/); return ret("meta", stream.current());}
18
+ if (ch == "@") {stream.eatWhile(/[\w\-]/); return ret("meta", stream.current());}
24
19
  else if (ch == "/" && stream.eat("*")) {
25
20
  state.tokenize = tokenCComment;
26
21
  return tokenCComment(stream, state);
@@ -35,15 +30,14 @@ CodeMirror.defineMode("less", function(config) {
35
30
  state.tokenize = tokenString(ch);
36
31
  return state.tokenize(stream, state);
37
32
  }
38
- else if (ch == "/") { // lesscss e.g.: .png will not be parsed as a class
39
- if(stream.eat("/")){
40
- state.tokenize = tokenSComment
33
+ else if (ch == "/") { // lesscss e.g.: .png will not be parsed as a class
34
+ if(stream.eat("/")){
35
+ state.tokenize = tokenSComment
41
36
  return tokenSComment(stream, state);
42
- }else{
43
- stream.eatWhile(/[\a-zA-Z0-9\-_.\s]/);
44
- if(/\/|\)|#/.test(stream.peek() || stream.eol() || (stream.eatSpace() && stream.peek() == ")")))return ret("string", "string");//let url(/images/logo.png) without quotes return as string
37
+ }else{
38
+ stream.eatWhile(/[\a-zA-Z0-9\-_.]/);
45
39
  return ret("number", "unit");
46
- }
40
+ }
47
41
  }
48
42
  else if (ch == "!") {
49
43
  stream.match(/^\s*\w*/);
@@ -53,98 +47,64 @@ CodeMirror.defineMode("less", function(config) {
53
47
  stream.eatWhile(/[\w.%]/);
54
48
  return ret("number", "unit");
55
49
  }
56
- else if (/[,+<>*\/]/.test(ch)) {//removed . dot character original was [,.+>*\/]
50
+ else if (/[,+>*\/]/.test(ch)) {//removed . dot character original was [,.+>*\/]
57
51
  return ret(null, "select-op");
58
52
  }
59
53
  else if (/[;{}:\[\]()]/.test(ch)) { //added () char for lesscss original was [;{}:\[\]]
60
54
  if(ch == ":"){
61
- stream.eatWhile(/[active|hover|link|visited]/);
62
- if( stream.current().match(/active|hover|link|visited/)){
63
- return ret("tag", "tag");
64
- }else{
65
- return ret(null, ch);
66
- }
67
- }else{
68
- return ret(null, ch);
69
- }
55
+ stream.eatWhile(/[active|hover|link|visited]/);
56
+ if( stream.current().match(/[active|hover|link|visited]/)){
57
+ return ret("tag", "tag");
58
+ }else{
59
+ return ret(null, ch);
60
+ }
61
+ }else{
62
+ return ret(null, ch);
63
+ }
70
64
  }
71
- else if (ch == ".") { // lesscss
72
- stream.eatWhile(/[\a-zA-Z0-9\-_]/);
65
+ else if (ch == ".") { // lesscss
66
+ stream.eatWhile(/[\a-zA-Z0-9\-_]/);
73
67
  return ret("tag", "tag");
74
68
  }
75
- else if (ch == "#") { // lesscss
76
- //we don't eat white-space, we want the hex color and or id only
77
- stream.eatWhile(/[A-Za-z0-9]/);
78
- //check if there is a proper hex color length e.g. #eee || #eeeEEE
79
- if(stream.current().length ===4 || stream.current().length ===7){
80
- if(stream.current().match(/[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/,false) != null){//is there a valid hex color value present in the current stream
81
- //when not a valid hex value, parse as id
82
- if(stream.current().substring(1) != stream.current().match(/[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/,false))return ret("atom", "tag");
83
- //eat white-space
84
- stream.eatSpace();
85
- //when hex value declaration doesn't end with [;,] but is does with a slash/cc comment treat it as an id, just like the other hex values that don't end with[;,]
86
- if( /[\/<>.(){!$%^&*_\-\\?=+\|#'~`]/.test(stream.peek()) )return ret("atom", "tag");
87
- //#time { color: #aaa }
88
- else if(stream.peek() == "}" )return ret("number", "unit");
89
- //we have a valid hex color value, parse as id whenever an element/class is defined after the hex(id) value e.g. #eee aaa || #eee .aaa
90
- else if( /[a-zA-Z\\]/.test(stream.peek()) )return ret("atom", "tag");
91
- //when a hex value is on the end of a line, parse as id
92
- else if(stream.eol())return ret("atom", "tag");
93
- //default
94
- else return ret("number", "unit");
95
- }else{//when not a valid hexvalue in the current stream e.g. #footer
96
- stream.eatWhile(/[\w\\\-]/);
97
- return ret("atom", "tag");
98
- }
99
- }else{
100
- stream.eatWhile(/[\w\\\-]/);
101
- return ret("atom", "tag");
102
- }
103
- }
104
- else if (ch == "&") {
69
+ else if (ch == "#") { // lesscss
70
+ stream.match(/([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/);
71
+ if(stream.current().length >1){
72
+ if(stream.current().match(/([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/) != null){
73
+ return ret("number", "unit");
74
+ }else{
105
75
  stream.eatWhile(/[\w\-]/);
106
- return ret(null, ch);
76
+ return ret("atom", "tag");
107
77
  }
78
+ }else{
79
+ stream.eatWhile(/[\w\-]/);
80
+ return ret("atom", "tag");
81
+ }
82
+ }
83
+ else if (ch == "&") {
84
+ stream.eatWhile(/[\w\-]/);
85
+ return ret(null, ch);
86
+ }
108
87
  else {
109
- stream.eatWhile(/[\w\\\-_%.{]/);
110
- if(stream.current().match(/http|https/) != null){
111
- stream.eatWhile(/[\w\\\-_%.{:\/]/);
112
- return ret("string", "string");
113
- }else if(stream.peek() == "<" || stream.peek() == ">"){
114
- return ret("tag", "tag");
115
- }else if( stream.peek().match(/\(/) != null ){// lessc
116
- return ret(null, ch);
117
- }else if (stream.peek() == "/" && state.stack[state.stack.length-1] != undefined){ // url(dir/center/image.png)
118
- return ret("string", "string");
119
- }else if( stream.current().match(/\-\d|\-.\d/) ){ // lesscss match e.g.: -5px -0.4 etc... only colorize the minus sign
120
- //stream.backUp(stream.current().length-1); //commment out these 2 comment if you want the minus sign to be parsed as null -500px
121
- //return ret(null, ch);
122
- return ret("number", "unit");
123
- }else if( inTagsArray(stream.current()) ){ // lesscss match html tags
124
- return ret("tag", "tag");
125
- }else if( /\/|[\s\)]/.test(stream.peek() || stream.eol() || (stream.eatSpace() && stream.peek() == "/")) && stream.current().indexOf(".") !== -1){
126
- if(stream.current().substring(stream.current().length-1,stream.current().length) == "{"){
127
- stream.backUp(1);
128
- return ret("tag", "tag");
129
- }//end if
130
- if( (stream.eatSpace() && stream.peek().match(/[{<>.a-zA-Z]/) != null) || stream.eol() )return ret("tag", "tag");//e.g. button.icon-plus
131
- return ret("string", "string");//let url(/images/logo.png) without quotes return as string
132
- }else if( stream.eol() ){
133
- if(stream.current().substring(stream.current().length-1,stream.current().length) == "{")stream.backUp(1);
134
- return ret("tag", "tag");
135
- }else{
88
+ stream.eatWhile(/[\w\\\-_.%{]/);
89
+ if( stream.eat("(") ){ // lesscss
90
+ return ret(null, ch);
91
+ }else if( stream.current().match(/\-\d|\-.\d/) ){ // lesscss match e.g.: -5px -0.4 etc...
92
+ return ret("number", "unit");
93
+ }else if( inTagsArray(stream.current()) ){ // lesscss match html tags
94
+ return ret("tag", "tag");
95
+ }else{
136
96
  return ret("variable", "variable");
137
- }
97
+ }
138
98
  }
139
99
 
140
100
  }
141
101
 
142
102
  function tokenSComment(stream, state) {// SComment = Slash comment
143
103
  stream.skipToEnd();
144
- state.tokenize = tokenBase;
104
+ state.tokenize = tokenBase;
145
105
  return ret("comment", "comment");
146
106
  }
147
-
107
+
148
108
  function tokenCComment(stream, state) {
149
109
  var maybeEnd = false, ch;
150
110
  while ((ch = stream.next()) != null) {
@@ -183,7 +143,7 @@ CodeMirror.defineMode("less", function(config) {
183
143
  }
184
144
 
185
145
  return {
186
- startState: function(base) {
146
+ startState: function(base) {
187
147
  return {tokenize: tokenBase,
188
148
  baseIndent: base || 0,
189
149
  stack: []};
@@ -197,11 +157,7 @@ CodeMirror.defineMode("less", function(config) {
197
157
  if (type == "hash" && context == "rule") style = "atom";
198
158
  else if (style == "variable") {
199
159
  if (context == "rule") style = null; //"tag"
200
- else if (!context || context == "@media{"){
201
- style = stream.current() == "when" ? "variable" :
202
- stream.string.match(/#/g) != undefined ? null :
203
- /[\s,|\s\)]/.test(stream.peek()) ? "tag" : null;
204
- }
160
+ else if (!context || context == "@media{") style = "tag";
205
161
  }
206
162
 
207
163
  if (context == "rule" && /^[\{\};]$/.test(type))
@@ -227,6 +183,4 @@ CodeMirror.defineMode("less", function(config) {
227
183
  };
228
184
  });
229
185
 
230
- CodeMirror.defineMIME("text/x-less", "less");
231
- if (!CodeMirror.mimeModes.hasOwnProperty("text/css"))
232
- CodeMirror.defineMIME("text/css", "less");
186
+ CodeMirror.defineMIME("text/less", "less");