codemirror-rails 4.1 → 4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/lib/codemirror/rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/codemirror.js +133 -58
  4. data/vendor/assets/javascripts/codemirror/addons/comment/comment.js +3 -0
  5. data/vendor/assets/javascripts/codemirror/addons/comment/continuecomment.js +3 -0
  6. data/vendor/assets/javascripts/codemirror/addons/dialog/dialog.js +3 -0
  7. data/vendor/assets/javascripts/codemirror/addons/display/fullscreen.js +3 -0
  8. data/vendor/assets/javascripts/codemirror/addons/display/placeholder.js +3 -0
  9. data/vendor/assets/javascripts/codemirror/addons/display/rulers.js +16 -6
  10. data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +3 -0
  11. data/vendor/assets/javascripts/codemirror/addons/edit/closetag.js +28 -3
  12. data/vendor/assets/javascripts/codemirror/addons/edit/continuelist.js +3 -0
  13. data/vendor/assets/javascripts/codemirror/addons/edit/matchbrackets.js +3 -0
  14. data/vendor/assets/javascripts/codemirror/addons/edit/matchtags.js +3 -0
  15. data/vendor/assets/javascripts/codemirror/addons/edit/trailingspace.js +3 -0
  16. data/vendor/assets/javascripts/codemirror/addons/fold/brace-fold.js +3 -0
  17. data/vendor/assets/javascripts/codemirror/addons/fold/comment-fold.js +3 -0
  18. data/vendor/assets/javascripts/codemirror/addons/fold/foldcode.js +36 -8
  19. data/vendor/assets/javascripts/codemirror/addons/fold/foldgutter.js +3 -0
  20. data/vendor/assets/javascripts/codemirror/addons/fold/indent-fold.js +3 -0
  21. data/vendor/assets/javascripts/codemirror/addons/fold/markdown-fold.js +3 -0
  22. data/vendor/assets/javascripts/codemirror/addons/fold/xml-fold.js +4 -1
  23. data/vendor/assets/javascripts/codemirror/addons/hint/anyword-hint.js +3 -0
  24. data/vendor/assets/javascripts/codemirror/addons/hint/css-hint.js +3 -0
  25. data/vendor/assets/javascripts/codemirror/addons/hint/html-hint.js +3 -0
  26. data/vendor/assets/javascripts/codemirror/addons/hint/javascript-hint.js +7 -2
  27. data/vendor/assets/javascripts/codemirror/addons/hint/python-hint.js +3 -0
  28. data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +74 -36
  29. data/vendor/assets/javascripts/codemirror/addons/hint/sql-hint.js +3 -0
  30. data/vendor/assets/javascripts/codemirror/addons/hint/xml-hint.js +3 -0
  31. data/vendor/assets/javascripts/codemirror/addons/lint/coffeescript-lint.js +3 -0
  32. data/vendor/assets/javascripts/codemirror/addons/lint/css-lint.js +3 -0
  33. data/vendor/assets/javascripts/codemirror/addons/lint/javascript-lint.js +3 -0
  34. data/vendor/assets/javascripts/codemirror/addons/lint/json-lint.js +3 -0
  35. data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +3 -0
  36. data/vendor/assets/javascripts/codemirror/addons/lint/yaml-lint.js +3 -0
  37. data/vendor/assets/javascripts/codemirror/addons/merge/merge.js +3 -0
  38. data/vendor/assets/javascripts/codemirror/addons/mode/loadmode.js +3 -0
  39. data/vendor/assets/javascripts/codemirror/addons/mode/multiplex.js +3 -0
  40. data/vendor/assets/javascripts/codemirror/addons/mode/overlay.js +12 -3
  41. data/vendor/assets/javascripts/codemirror/addons/runmode/colorize.js +3 -0
  42. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode-standalone.js +4 -1
  43. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.js +4 -1
  44. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +4 -1
  45. data/vendor/assets/javascripts/codemirror/addons/scroll/scrollpastend.js +3 -0
  46. data/vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js +6 -2
  47. data/vendor/assets/javascripts/codemirror/addons/search/search.js +3 -0
  48. data/vendor/assets/javascripts/codemirror/addons/search/searchcursor.js +3 -0
  49. data/vendor/assets/javascripts/codemirror/addons/selection/active-line.js +3 -0
  50. data/vendor/assets/javascripts/codemirror/addons/selection/mark-selection.js +3 -0
  51. data/vendor/assets/javascripts/codemirror/addons/tern/tern.js +23 -16
  52. data/vendor/assets/javascripts/codemirror/addons/tern/worker.js +3 -0
  53. data/vendor/assets/javascripts/codemirror/addons/wrap/hardwrap.js +3 -0
  54. data/vendor/assets/javascripts/codemirror/keymaps/emacs.js +4 -7
  55. data/vendor/assets/javascripts/codemirror/keymaps/sublime.js +11 -8
  56. data/vendor/assets/javascripts/codemirror/keymaps/vim.js +92 -33
  57. data/vendor/assets/javascripts/codemirror/modes/apl.js +3 -0
  58. data/vendor/assets/javascripts/codemirror/modes/asterisk.js +3 -0
  59. data/vendor/assets/javascripts/codemirror/modes/clike.js +3 -0
  60. data/vendor/assets/javascripts/codemirror/modes/clojure.js +3 -0
  61. data/vendor/assets/javascripts/codemirror/modes/cobol.js +3 -0
  62. data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +3 -0
  63. data/vendor/assets/javascripts/codemirror/modes/commonlisp.js +3 -0
  64. data/vendor/assets/javascripts/codemirror/modes/css.js +13 -14
  65. data/vendor/assets/javascripts/codemirror/modes/cypher.js +146 -0
  66. data/vendor/assets/javascripts/codemirror/modes/d.js +3 -0
  67. data/vendor/assets/javascripts/codemirror/modes/diff.js +3 -0
  68. data/vendor/assets/javascripts/codemirror/modes/django.js +3 -0
  69. data/vendor/assets/javascripts/codemirror/modes/dtd.js +3 -0
  70. data/vendor/assets/javascripts/codemirror/modes/dylan.js +15 -0
  71. data/vendor/assets/javascripts/codemirror/modes/ecl.js +3 -0
  72. data/vendor/assets/javascripts/codemirror/modes/eiffel.js +3 -0
  73. data/vendor/assets/javascripts/codemirror/modes/erlang.js +3 -0
  74. data/vendor/assets/javascripts/codemirror/modes/fortran.js +3 -0
  75. data/vendor/assets/javascripts/codemirror/modes/gas.js +3 -0
  76. data/vendor/assets/javascripts/codemirror/modes/gfm.js +9 -1
  77. data/vendor/assets/javascripts/codemirror/modes/gherkin.js +3 -0
  78. data/vendor/assets/javascripts/codemirror/modes/go.js +3 -0
  79. data/vendor/assets/javascripts/codemirror/modes/groovy.js +3 -0
  80. data/vendor/assets/javascripts/codemirror/modes/haml.js +3 -0
  81. data/vendor/assets/javascripts/codemirror/modes/haskell.js +3 -0
  82. data/vendor/assets/javascripts/codemirror/modes/haxe.js +5 -1
  83. data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +3 -0
  84. data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +3 -0
  85. data/vendor/assets/javascripts/codemirror/modes/http.js +3 -0
  86. data/vendor/assets/javascripts/codemirror/modes/jade.js +569 -81
  87. data/vendor/assets/javascripts/codemirror/modes/javascript.js +5 -0
  88. data/vendor/assets/javascripts/codemirror/modes/jinja2.js +3 -0
  89. data/vendor/assets/javascripts/codemirror/modes/julia.js +3 -0
  90. data/vendor/assets/javascripts/codemirror/modes/livescript.js +17 -17
  91. data/vendor/assets/javascripts/codemirror/modes/lua.js +3 -0
  92. data/vendor/assets/javascripts/codemirror/modes/markdown.js +5 -3
  93. data/vendor/assets/javascripts/codemirror/modes/mirc.js +3 -0
  94. data/vendor/assets/javascripts/codemirror/modes/mllike.js +3 -0
  95. data/vendor/assets/javascripts/codemirror/modes/nginx.js +3 -0
  96. data/vendor/assets/javascripts/codemirror/modes/ntriples.js +3 -0
  97. data/vendor/assets/javascripts/codemirror/modes/octave.js +3 -0
  98. data/vendor/assets/javascripts/codemirror/modes/pascal.js +3 -0
  99. data/vendor/assets/javascripts/codemirror/modes/pegjs.js +3 -0
  100. data/vendor/assets/javascripts/codemirror/modes/perl.js +5 -0
  101. data/vendor/assets/javascripts/codemirror/modes/php.js +5 -2
  102. data/vendor/assets/javascripts/codemirror/modes/pig.js +3 -0
  103. data/vendor/assets/javascripts/codemirror/modes/properties.js +3 -0
  104. data/vendor/assets/javascripts/codemirror/modes/puppet.js +3 -0
  105. data/vendor/assets/javascripts/codemirror/modes/python.js +284 -328
  106. data/vendor/assets/javascripts/codemirror/modes/q.js +3 -0
  107. data/vendor/assets/javascripts/codemirror/modes/r.js +3 -0
  108. data/vendor/assets/javascripts/codemirror/modes/rpm.js +3 -0
  109. data/vendor/assets/javascripts/codemirror/modes/rst.js +3 -0
  110. data/vendor/assets/javascripts/codemirror/modes/ruby.js +3 -0
  111. data/vendor/assets/javascripts/codemirror/modes/rust.js +3 -0
  112. data/vendor/assets/javascripts/codemirror/modes/sass.js +3 -0
  113. data/vendor/assets/javascripts/codemirror/modes/scheme.js +3 -0
  114. data/vendor/assets/javascripts/codemirror/modes/shell.js +9 -2
  115. data/vendor/assets/javascripts/codemirror/modes/sieve.js +3 -0
  116. data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +3 -0
  117. data/vendor/assets/javascripts/codemirror/modes/smarty.js +3 -0
  118. data/vendor/assets/javascripts/codemirror/modes/smartymixed.js +3 -0
  119. data/vendor/assets/javascripts/codemirror/modes/solr.js +3 -0
  120. data/vendor/assets/javascripts/codemirror/modes/sparql.js +3 -0
  121. data/vendor/assets/javascripts/codemirror/modes/sql.js +3 -0
  122. data/vendor/assets/javascripts/codemirror/modes/stex.js +3 -0
  123. data/vendor/assets/javascripts/codemirror/modes/tcl.js +3 -0
  124. data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +3 -0
  125. data/vendor/assets/javascripts/codemirror/modes/tiki.js +3 -0
  126. data/vendor/assets/javascripts/codemirror/modes/toml.js +3 -0
  127. data/vendor/assets/javascripts/codemirror/modes/turtle.js +3 -0
  128. data/vendor/assets/javascripts/codemirror/modes/vb.js +3 -0
  129. data/vendor/assets/javascripts/codemirror/modes/vbscript.js +3 -0
  130. data/vendor/assets/javascripts/codemirror/modes/velocity.js +3 -0
  131. data/vendor/assets/javascripts/codemirror/modes/verilog.js +3 -0
  132. data/vendor/assets/javascripts/codemirror/modes/xml.js +4 -1
  133. data/vendor/assets/javascripts/codemirror/modes/xquery.js +3 -0
  134. data/vendor/assets/javascripts/codemirror/modes/yaml.js +3 -0
  135. data/vendor/assets/javascripts/codemirror/modes/z80.js +3 -0
  136. data/vendor/assets/stylesheets/codemirror/addons/tern/tern.css +1 -0
  137. data/vendor/assets/stylesheets/codemirror/themes/neo.css +40 -0
  138. metadata +4 -2
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  // TODO actually recognize syntax of TypeScript constructs
2
5
 
3
6
  (function(mod) {
@@ -645,6 +648,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
645
648
  };
646
649
  });
647
650
 
651
+ CodeMirror.registerHelper("wordChars", "javascript", /[\\w$]/);
652
+
648
653
  CodeMirror.defineMIME("text/javascript", "javascript");
649
654
  CodeMirror.defineMIME("text/ecmascript", "javascript");
650
655
  CodeMirror.defineMIME("application/javascript", "javascript");
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  (function(mod) {
2
5
  if (typeof exports == "object" && typeof module == "object") // CommonJS
3
6
  mod(require("../../lib/codemirror"));
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  (function(mod) {
2
5
  if (typeof exports == "object" && typeof module == "object") // CommonJS
3
6
  mod(require("../../lib/codemirror"));
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  /**
2
5
  * Link to the project's GitHub page:
3
6
  * https://github.com/duralog/CodeMirror
@@ -11,18 +14,17 @@
11
14
  else // Plain browser env
12
15
  mod(CodeMirror);
13
16
  })(function(CodeMirror) {
14
- "use strict";
17
+ "use strict";
15
18
 
16
- (function() {
17
19
  CodeMirror.defineMode('livescript', function(){
18
- var tokenBase, external;
19
- tokenBase = function(stream, state){
20
- var next_rule, nr, i$, len$, r, m;
21
- if (next_rule = state.next || 'start') {
20
+ var tokenBase = function(stream, state) {
21
+ var next_rule = state.next || "start";
22
+ if (next_rule) {
22
23
  state.next = state.next;
23
- if (Array.isArray(nr = Rules[next_rule])) {
24
- for (i$ = 0, len$ = nr.length; i$ < len$; ++i$) {
25
- r = nr[i$];
24
+ var nr = Rules[next_rule];
25
+ if (nr.splice) {
26
+ for (var i$ = 0; i$ < nr.length; ++i$) {
27
+ var r = nr[i$], m;
26
28
  if (r.regex && (m = stream.match(r.regex))) {
27
29
  state.next = r.next || state.next;
28
30
  return r.token;
@@ -44,7 +46,7 @@
44
46
  stream.next();
45
47
  return 'error';
46
48
  };
47
- external = {
49
+ var external = {
48
50
  startState: function(){
49
51
  return {
50
52
  next: 'start',
@@ -52,8 +54,8 @@
52
54
  };
53
55
  },
54
56
  token: function(stream, state){
55
- var style;
56
- style = tokenBase(stream, state);
57
+ while (stream.pos == stream.start)
58
+ var style = tokenBase(stream, state);
57
59
  state.lastToken = {
58
60
  style: style,
59
61
  indent: stream.indentation(),
@@ -62,8 +64,7 @@
62
64
  return style.replace(/\./g, ' ');
63
65
  },
64
66
  indent: function(state){
65
- var indentation;
66
- indentation = state.lastToken.indent;
67
+ var indentation = state.lastToken.indent;
67
68
  if (state.lastToken.content.match(indenter)) {
68
69
  indentation += 2;
69
70
  }
@@ -262,7 +263,7 @@
262
263
  };
263
264
  for (var idx in Rules) {
264
265
  var r = Rules[idx];
265
- if (Array.isArray(r)) {
266
+ if (r.splice) {
266
267
  for (var i = 0, len = r.length; i < len; ++i) {
267
268
  var rr = r[i];
268
269
  if (typeof rr.regex === 'string') {
@@ -273,8 +274,7 @@
273
274
  Rules[idx].regex = new RegExp('^' + r.regex);
274
275
  }
275
276
  }
276
- })();
277
277
 
278
- CodeMirror.defineMIME('text/x-livescript', 'livescript');
278
+ CodeMirror.defineMIME('text/x-livescript', 'livescript');
279
279
 
280
280
  });
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  // LUA mode. Ported to CodeMirror 2 from Franciszek Wawrzak's
2
5
  // CodeMirror 1 mode.
3
6
  // highlights keywords, strings, comments (no leveling supported! ("[==[")), tokens, basic indenting
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  (function(mod) {
2
5
  if (typeof exports == "object" && typeof module == "object") // CommonJS
3
6
  mod(require("../../lib/codemirror", require("../xml/xml")));
@@ -209,7 +212,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
209
212
 
210
213
  function htmlBlock(stream, state) {
211
214
  var style = htmlMode.token(stream, state.htmlState);
212
- if ((htmlFound && !state.htmlState.tagName && !state.htmlState.context) ||
215
+ if ((htmlFound && state.htmlState.tagStart === null && !state.htmlState.context) ||
213
216
  (state.md_inside && stream.current().indexOf(">") > -1)) {
214
217
  state.f = inlineNormal;
215
218
  state.block = blockNormal;
@@ -709,8 +712,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
709
712
 
710
713
  if (forceBlankLine) {
711
714
  state.prevLineHasContent = false;
712
- blankLine(state);
713
- return this.token(stream, state);
715
+ return blankLine(state);
714
716
  } else {
715
717
  state.prevLineHasContent = state.thisLineHasContent;
716
718
  state.thisLineHasContent = true;
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  //mIRC mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara
2
5
 
3
6
  (function(mod) {
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  (function(mod) {
2
5
  if (typeof exports == "object" && typeof module == "object") // CommonJS
3
6
  mod(require("../../lib/codemirror"));
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  (function(mod) {
2
5
  if (typeof exports == "object" && typeof module == "object") // CommonJS
3
6
  mod(require("../../lib/codemirror"));
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  /**********************************************************
2
5
  * This script provides syntax highlighting support for
3
6
  * the Ntriples format.
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  (function(mod) {
2
5
  if (typeof exports == "object" && typeof module == "object") // CommonJS
3
6
  mod(require("../../lib/codemirror"));
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  (function(mod) {
2
5
  if (typeof exports == "object" && typeof module == "object") // CommonJS
3
6
  mod(require("../../lib/codemirror"));
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  (function(mod) {
2
5
  if (typeof exports == "object" && typeof module == "object") // CommonJS
3
6
  mod(require("../../lib/codemirror"), require("../javascript/javascript"));
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  // CodeMirror2 mode/perl/perl.js (text/x-perl) beta 0.10 (2011-11-08)
2
5
  // This is a part of CodeMirror from https://github.com/sabaca/CodeMirror_mode_perl (mail@sabaca.com)
3
6
 
@@ -788,6 +791,8 @@ CodeMirror.defineMode("perl",function(){
788
791
  return (state.tokenize||tokenPerl)(stream,state);},
789
792
  electricChars:"{}"};});
790
793
 
794
+ CodeMirror.registerHelper("wordChars", "perl", /[\\w$]/);
795
+
791
796
  CodeMirror.defineMIME("text/x-perl", "perl");
792
797
 
793
798
  // it's like "peek", but need for look-ahead or look-behind if index < 0
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  (function(mod) {
2
5
  if (typeof exports == "object" && typeof module == "object") // CommonJS
3
6
  mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"), require("../clike/clike"));
@@ -94,6 +97,7 @@
94
97
  var phpAtoms = "true false null TRUE FALSE NULL __CLASS__ __DIR__ __FILE__ __LINE__ __METHOD__ __FUNCTION__ __NAMESPACE__ __TRAIT__";
95
98
  var phpBuiltin = "func_num_args func_get_arg func_get_args strlen strcmp strncmp strcasecmp strncasecmp each error_reporting define defined trigger_error user_error set_error_handler restore_error_handler get_declared_classes get_loaded_extensions extension_loaded get_extension_funcs debug_backtrace constant bin2hex hex2bin sleep usleep time mktime gmmktime strftime gmstrftime strtotime date gmdate getdate localtime checkdate flush wordwrap htmlspecialchars htmlentities html_entity_decode md5 md5_file crc32 getimagesize image_type_to_mime_type phpinfo phpversion phpcredits strnatcmp strnatcasecmp substr_count strspn strcspn strtok strtoupper strtolower strpos strrpos strrev hebrev hebrevc nl2br basename dirname pathinfo stripslashes stripcslashes strstr stristr strrchr str_shuffle str_word_count strcoll substr substr_replace quotemeta ucfirst ucwords strtr addslashes addcslashes rtrim str_replace str_repeat count_chars chunk_split trim ltrim strip_tags similar_text explode implode setlocale localeconv parse_str str_pad chop strchr sprintf printf vprintf vsprintf sscanf fscanf parse_url urlencode urldecode rawurlencode rawurldecode readlink linkinfo link unlink exec system escapeshellcmd escapeshellarg passthru shell_exec proc_open proc_close rand srand getrandmax mt_rand mt_srand mt_getrandmax base64_decode base64_encode abs ceil floor round is_finite is_nan is_infinite bindec hexdec octdec decbin decoct dechex base_convert number_format fmod ip2long long2ip getenv putenv getopt microtime gettimeofday getrusage uniqid quoted_printable_decode set_time_limit get_cfg_var magic_quotes_runtime set_magic_quotes_runtime get_magic_quotes_gpc get_magic_quotes_runtime import_request_variables error_log serialize unserialize memory_get_usage var_dump var_export debug_zval_dump print_r highlight_file show_source highlight_string ini_get ini_get_all ini_set ini_alter ini_restore get_include_path set_include_path restore_include_path setcookie header headers_sent connection_aborted connection_status ignore_user_abort parse_ini_file is_uploaded_file move_uploaded_file intval floatval doubleval strval gettype settype is_null is_resource is_bool is_long is_float is_int is_integer is_double is_real is_numeric is_string is_array is_object is_scalar ereg ereg_replace eregi eregi_replace split spliti join sql_regcase dl pclose popen readfile rewind rmdir umask fclose feof fgetc fgets fgetss fread fopen fpassthru ftruncate fstat fseek ftell fflush fwrite fputs mkdir rename copy tempnam tmpfile file file_get_contents stream_select stream_context_create stream_context_set_params stream_context_set_option stream_context_get_options stream_filter_prepend stream_filter_append fgetcsv flock get_meta_tags stream_set_write_buffer set_file_buffer set_socket_blocking stream_set_blocking socket_set_blocking stream_get_meta_data stream_register_wrapper stream_wrapper_register stream_set_timeout socket_set_timeout socket_get_status realpath fnmatch fsockopen pfsockopen pack unpack get_browser crypt opendir closedir chdir getcwd rewinddir readdir dir glob fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype file_exists is_writable is_writeable is_readable is_executable is_file is_dir is_link stat lstat chown touch clearstatcache mail ob_start ob_flush ob_clean ob_end_flush ob_end_clean ob_get_flush ob_get_clean ob_get_length ob_get_level ob_get_status ob_get_contents ob_implicit_flush ob_list_handlers ksort krsort natsort natcasesort asort arsort sort rsort usort uasort uksort shuffle array_walk count end prev next reset current key min max in_array array_search extract compact array_fill range array_multisort array_push array_pop array_shift array_unshift array_splice array_slice array_merge array_merge_recursive array_keys array_values array_count_values array_reverse array_reduce array_pad array_flip array_change_key_case array_rand array_unique array_intersect array_intersect_assoc array_diff array_diff_assoc array_sum array_filter array_map array_chunk array_key_exists pos sizeof key_exists assert assert_options version_compare ftok str_rot13 aggregate session_name session_module_name session_save_path session_id session_regenerate_id session_decode session_register session_unregister session_is_registered session_encode session_start session_destroy session_unset session_set_save_handler session_cache_limiter session_cache_expire session_set_cookie_params session_get_cookie_params session_write_close preg_match preg_match_all preg_replace preg_replace_callback preg_split preg_quote preg_grep overload ctype_alnum ctype_alpha ctype_cntrl ctype_digit ctype_lower ctype_graph ctype_print ctype_punct ctype_space ctype_upper ctype_xdigit virtual apache_request_headers apache_note apache_lookup_uri apache_child_terminate apache_setenv apache_response_headers apache_get_version getallheaders mysql_connect mysql_pconnect mysql_close mysql_select_db mysql_create_db mysql_drop_db mysql_query mysql_unbuffered_query mysql_db_query mysql_list_dbs mysql_list_tables mysql_list_fields mysql_list_processes mysql_error mysql_errno mysql_affected_rows mysql_insert_id mysql_result mysql_num_rows mysql_num_fields mysql_fetch_row mysql_fetch_array mysql_fetch_assoc mysql_fetch_object mysql_data_seek mysql_fetch_lengths mysql_fetch_field mysql_field_seek mysql_free_result mysql_field_name mysql_field_table mysql_field_len mysql_field_type mysql_field_flags mysql_escape_string mysql_real_escape_string mysql_stat mysql_thread_id mysql_client_encoding mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql mysql_fieldname mysql_fieldtable mysql_fieldlen mysql_fieldtype mysql_fieldflags mysql_selectdb mysql_createdb mysql_dropdb mysql_freeresult mysql_numfields mysql_numrows mysql_listdbs mysql_listtables mysql_listfields mysql_db_name mysql_dbname mysql_tablename mysql_table_name pg_connect pg_pconnect pg_close pg_connection_status pg_connection_busy pg_connection_reset pg_host pg_dbname pg_port pg_tty pg_options pg_ping pg_query pg_send_query pg_cancel_query pg_fetch_result pg_fetch_row pg_fetch_assoc pg_fetch_array pg_fetch_object pg_fetch_all pg_affected_rows pg_get_result pg_result_seek pg_result_status pg_free_result pg_last_oid pg_num_rows pg_num_fields pg_field_name pg_field_num pg_field_size pg_field_type pg_field_prtlen pg_field_is_null pg_get_notify pg_get_pid pg_result_error pg_last_error pg_last_notice pg_put_line pg_end_copy pg_copy_to pg_copy_from pg_trace pg_untrace pg_lo_create pg_lo_unlink pg_lo_open pg_lo_close pg_lo_read pg_lo_write pg_lo_read_all pg_lo_import pg_lo_export pg_lo_seek pg_lo_tell pg_escape_string pg_escape_bytea pg_unescape_bytea pg_client_encoding pg_set_client_encoding pg_meta_data pg_convert pg_insert pg_update pg_delete pg_select pg_exec pg_getlastoid pg_cmdtuples pg_errormessage pg_numrows pg_numfields pg_fieldname pg_fieldsize pg_fieldtype pg_fieldnum pg_fieldprtlen pg_fieldisnull pg_freeresult pg_result pg_loreadall pg_locreate pg_lounlink pg_loopen pg_loclose pg_loread pg_lowrite pg_loimport pg_loexport http_response_code get_declared_traits getimagesizefromstring socket_import_stream stream_set_chunk_size trait_exists header_register_callback class_uses session_status session_register_shutdown echo print global static exit array empty eval isset unset die include require include_once require_once";
96
99
  CodeMirror.registerHelper("hintWords", "php", [phpKeywords, phpAtoms, phpBuiltin].join(" ").split(" "));
100
+ CodeMirror.registerHelper("wordChars", "php", /[\\w$]/);
97
101
 
98
102
  var phpConfig = {
99
103
  name: "clike",
@@ -183,8 +187,7 @@
183
187
  state.curState = state.html;
184
188
  return "meta";
185
189
  } else {
186
- var result = phpMode.token(stream, state.curState);
187
- return (stream.pos <= stream.start) ? phpMode.token(stream, state.curState) : result;
190
+ return phpMode.token(stream, state.curState);
188
191
  }
189
192
  }
190
193
 
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  /*
2
5
  * Pig Latin Mode for CodeMirror 2
3
6
  * @author Prasanth Jayachandran
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  (function(mod) {
2
5
  if (typeof exports == "object" && typeof module == "object") // CommonJS
3
6
  mod(require("../../lib/codemirror"));
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  (function(mod) {
2
5
  if (typeof exports == "object" && typeof module == "object") // CommonJS
3
6
  mod(require("../../lib/codemirror"));
@@ -1,3 +1,6 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
1
4
  (function(mod) {
2
5
  if (typeof exports == "object" && typeof module == "object") // CommonJS
3
6
  mod(require("../../lib/codemirror"));
@@ -6,383 +9,336 @@
6
9
  else // Plain browser env
7
10
  mod(CodeMirror);
8
11
  })(function(CodeMirror) {
9
- "use strict";
10
-
11
-
12
- CodeMirror.defineMode("python", function(conf, parserConf) {
13
- var ERRORCLASS = 'error';
14
-
15
- function wordRegexp(words) {
16
- return new RegExp("^((" + words.join(")|(") + "))\\b");
17
- }
12
+ "use strict";
13
+
14
+ function wordRegexp(words) {
15
+ return new RegExp("^((" + words.join(")|(") + "))\\b");
16
+ }
17
+
18
+ var wordOperators = wordRegexp(["and", "or", "not", "is", "in"]);
19
+ var commonKeywords = ["as", "assert", "break", "class", "continue",
20
+ "def", "del", "elif", "else", "except", "finally",
21
+ "for", "from", "global", "if", "import",
22
+ "lambda", "pass", "raise", "return",
23
+ "try", "while", "with", "yield"];
24
+ var commonBuiltins = ["abs", "all", "any", "bin", "bool", "bytearray", "callable", "chr",
25
+ "classmethod", "compile", "complex", "delattr", "dict", "dir", "divmod",
26
+ "enumerate", "eval", "filter", "float", "format", "frozenset",
27
+ "getattr", "globals", "hasattr", "hash", "help", "hex", "id",
28
+ "input", "int", "isinstance", "issubclass", "iter", "len",
29
+ "list", "locals", "map", "max", "memoryview", "min", "next",
30
+ "object", "oct", "open", "ord", "pow", "property", "range",
31
+ "repr", "reversed", "round", "set", "setattr", "slice",
32
+ "sorted", "staticmethod", "str", "sum", "super", "tuple",
33
+ "type", "vars", "zip", "__import__", "NotImplemented",
34
+ "Ellipsis", "__debug__"];
35
+ var py2 = {builtins: ["apply", "basestring", "buffer", "cmp", "coerce", "execfile",
36
+ "file", "intern", "long", "raw_input", "reduce", "reload",
37
+ "unichr", "unicode", "xrange", "False", "True", "None"],
38
+ keywords: ["exec", "print"]};
39
+ var py3 = {builtins: ["ascii", "bytes", "exec", "print"],
40
+ keywords: ["nonlocal", "False", "True", "None"]};
41
+
42
+ CodeMirror.registerHelper("hintWords", "python", commonKeywords.concat(commonBuiltins));
43
+
44
+ function top(state) {
45
+ return state.scopes[state.scopes.length - 1];
46
+ }
47
+
48
+ CodeMirror.defineMode("python", function(conf, parserConf) {
49
+ var ERRORCLASS = "error";
18
50
 
19
51
  var singleOperators = parserConf.singleOperators || new RegExp("^[\\+\\-\\*/%&|\\^~<>!]");
20
- var singleDelimiters = parserConf.singleDelimiters || new RegExp('^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]');
52
+ var singleDelimiters = parserConf.singleDelimiters || new RegExp("^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]");
21
53
  var doubleOperators = parserConf.doubleOperators || new RegExp("^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))");
22
54
  var doubleDelimiters = parserConf.doubleDelimiters || new RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))");
23
55
  var tripleDelimiters = parserConf.tripleDelimiters || new RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))");
24
56
  var identifiers = parserConf.identifiers|| new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
25
- var hangingIndent = parserConf.hangingIndent || parserConf.indentUnit;
26
-
27
- var wordOperators = wordRegexp(['and', 'or', 'not', 'is', 'in']);
28
- var commonkeywords = ['as', 'assert', 'break', 'class', 'continue',
29
- 'def', 'del', 'elif', 'else', 'except', 'finally',
30
- 'for', 'from', 'global', 'if', 'import',
31
- 'lambda', 'pass', 'raise', 'return',
32
- 'try', 'while', 'with', 'yield'];
33
- var commonBuiltins = ['abs', 'all', 'any', 'bin', 'bool', 'bytearray', 'callable', 'chr',
34
- 'classmethod', 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod',
35
- 'enumerate', 'eval', 'filter', 'float', 'format', 'frozenset',
36
- 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id',
37
- 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len',
38
- 'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next',
39
- 'object', 'oct', 'open', 'ord', 'pow', 'property', 'range',
40
- 'repr', 'reversed', 'round', 'set', 'setattr', 'slice',
41
- 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple',
42
- 'type', 'vars', 'zip', '__import__', 'NotImplemented',
43
- 'Ellipsis', '__debug__'];
44
- var py2 = {'builtins': ['apply', 'basestring', 'buffer', 'cmp', 'coerce', 'execfile',
45
- 'file', 'intern', 'long', 'raw_input', 'reduce', 'reload',
46
- 'unichr', 'unicode', 'xrange', 'False', 'True', 'None'],
47
- 'keywords': ['exec', 'print']};
48
- var py3 = {'builtins': ['ascii', 'bytes', 'exec', 'print'],
49
- 'keywords': ['nonlocal', 'False', 'True', 'None']};
57
+ var hangingIndent = parserConf.hangingIndent || conf.indentUnit;
50
58
 
59
+ var myKeywords = commonKeywords, myBuiltins = commonBuiltins;
51
60
  if(parserConf.extra_keywords != undefined){
52
- commonkeywords = commonkeywords.concat(parserConf.extra_keywords);
61
+ myKeywords = myKeywords.concat(parserConf.extra_keywords);
53
62
  }
54
63
  if(parserConf.extra_builtins != undefined){
55
- commonBuiltins = commonBuiltins.concat(parserConf.extra_builtins);
64
+ myBuiltins = myBuiltins.concat(parserConf.extra_builtins);
56
65
  }
57
- if (!!parserConf.version && parseInt(parserConf.version, 10) === 3) {
58
- commonkeywords = commonkeywords.concat(py3.keywords);
59
- commonBuiltins = commonBuiltins.concat(py3.builtins);
60
- var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i");
66
+ if (parserConf.version && parseInt(parserConf.version, 10) == 3) {
67
+ myKeywords = myKeywords.concat(py3.keywords);
68
+ myBuiltins = myBuiltins.concat(py3.builtins);
69
+ var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i");
61
70
  } else {
62
- commonkeywords = commonkeywords.concat(py2.keywords);
63
- commonBuiltins = commonBuiltins.concat(py2.builtins);
64
- var stringPrefixes = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i");
71
+ myKeywords = myKeywords.concat(py2.keywords);
72
+ myBuiltins = myBuiltins.concat(py2.builtins);
73
+ var stringPrefixes = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i");
65
74
  }
66
- var keywords = wordRegexp(commonkeywords);
67
- var builtins = wordRegexp(commonBuiltins);
68
-
69
- var indentInfo = null;
75
+ var keywords = wordRegexp(myKeywords);
76
+ var builtins = wordRegexp(myBuiltins);
70
77
 
71
78
  // tokenizers
72
79
  function tokenBase(stream, state) {
73
- // Handle scope changes
74
- if (stream.sol()) {
75
- var scopeOffset = state.scopes[0].offset;
76
- if (stream.eatSpace()) {
77
- var lineOffset = stream.indentation();
78
- if (lineOffset > scopeOffset) {
79
- indentInfo = 'indent';
80
- } else if (lineOffset < scopeOffset) {
81
- indentInfo = 'dedent';
82
- }
83
- return null;
84
- } else {
85
- if (scopeOffset > 0) {
86
- dedent(stream, state);
87
- }
88
- }
89
- }
80
+ // Handle scope changes
81
+ if (stream.sol() && top(state).type == "py") {
82
+ var scopeOffset = top(state).offset;
90
83
  if (stream.eatSpace()) {
91
- return null;
84
+ var lineOffset = stream.indentation();
85
+ if (lineOffset > scopeOffset)
86
+ pushScope(stream, state, "py");
87
+ else if (lineOffset < scopeOffset && dedent(stream, state))
88
+ state.errorToken = true;
89
+ return null;
90
+ } else {
91
+ var style = tokenBaseInner(stream, state);
92
+ if (scopeOffset > 0 && dedent(stream, state))
93
+ style += " " + ERRORCLASS;
94
+ return style;
92
95
  }
96
+ }
97
+ return tokenBaseInner(stream, state);
98
+ }
93
99
 
94
- var ch = stream.peek();
95
-
96
- // Handle Comments
97
- if (ch === '#') {
98
- stream.skipToEnd();
99
- return 'comment';
100
+ function tokenBaseInner(stream, state) {
101
+ if (stream.eatSpace()) return null;
102
+
103
+ var ch = stream.peek();
104
+
105
+ // Handle Comments
106
+ if (ch == "#") {
107
+ stream.skipToEnd();
108
+ return "comment";
109
+ }
110
+
111
+ // Handle Number Literals
112
+ if (stream.match(/^[0-9\.]/, false)) {
113
+ var floatLiteral = false;
114
+ // Floats
115
+ if (stream.match(/^\d*\.\d+(e[\+\-]?\d+)?/i)) { floatLiteral = true; }
116
+ if (stream.match(/^\d+\.\d*/)) { floatLiteral = true; }
117
+ if (stream.match(/^\.\d+/)) { floatLiteral = true; }
118
+ if (floatLiteral) {
119
+ // Float literals may be "imaginary"
120
+ stream.eat(/J/i);
121
+ return "number";
100
122
  }
101
-
102
- // Handle Number Literals
103
- if (stream.match(/^[0-9\.]/, false)) {
104
- var floatLiteral = false;
105
- // Floats
106
- if (stream.match(/^\d*\.\d+(e[\+\-]?\d+)?/i)) { floatLiteral = true; }
107
- if (stream.match(/^\d+\.\d*/)) { floatLiteral = true; }
108
- if (stream.match(/^\.\d+/)) { floatLiteral = true; }
109
- if (floatLiteral) {
110
- // Float literals may be "imaginary"
111
- stream.eat(/J/i);
112
- return 'number';
113
- }
114
- // Integers
115
- var intLiteral = false;
116
- // Hex
117
- if (stream.match(/^0x[0-9a-f]+/i)) { intLiteral = true; }
118
- // Binary
119
- if (stream.match(/^0b[01]+/i)) { intLiteral = true; }
120
- // Octal
121
- if (stream.match(/^0o[0-7]+/i)) { intLiteral = true; }
122
- // Decimal
123
- if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) {
124
- // Decimal literals may be "imaginary"
125
- stream.eat(/J/i);
126
- // TODO - Can you have imaginary longs?
127
- intLiteral = true;
128
- }
129
- // Zero by itself with no other piece of number.
130
- if (stream.match(/^0(?![\dx])/i)) { intLiteral = true; }
131
- if (intLiteral) {
132
- // Integer literals may be "long"
133
- stream.eat(/L/i);
134
- return 'number';
135
- }
123
+ // Integers
124
+ var intLiteral = false;
125
+ // Hex
126
+ if (stream.match(/^0x[0-9a-f]+/i)) intLiteral = true;
127
+ // Binary
128
+ if (stream.match(/^0b[01]+/i)) intLiteral = true;
129
+ // Octal
130
+ if (stream.match(/^0o[0-7]+/i)) intLiteral = true;
131
+ // Decimal
132
+ if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) {
133
+ // Decimal literals may be "imaginary"
134
+ stream.eat(/J/i);
135
+ // TODO - Can you have imaginary longs?
136
+ intLiteral = true;
136
137
  }
137
-
138
- // Handle Strings
139
- if (stream.match(stringPrefixes)) {
140
- state.tokenize = tokenStringFactory(stream.current());
141
- return state.tokenize(stream, state);
138
+ // Zero by itself with no other piece of number.
139
+ if (stream.match(/^0(?![\dx])/i)) intLiteral = true;
140
+ if (intLiteral) {
141
+ // Integer literals may be "long"
142
+ stream.eat(/L/i);
143
+ return "number";
142
144
  }
145
+ }
143
146
 
144
- // Handle operators and Delimiters
145
- if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters)) {
146
- return null;
147
- }
148
- if (stream.match(doubleOperators)
149
- || stream.match(singleOperators)
150
- || stream.match(wordOperators)) {
151
- return 'operator';
152
- }
153
- if (stream.match(singleDelimiters)) {
154
- return null;
155
- }
147
+ // Handle Strings
148
+ if (stream.match(stringPrefixes)) {
149
+ state.tokenize = tokenStringFactory(stream.current());
150
+ return state.tokenize(stream, state);
151
+ }
156
152
 
157
- if (stream.match(keywords)) {
158
- return 'keyword';
159
- }
153
+ // Handle operators and Delimiters
154
+ if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters))
155
+ return null;
160
156
 
161
- if (stream.match(builtins)) {
162
- return 'builtin';
163
- }
157
+ if (stream.match(doubleOperators)
158
+ || stream.match(singleOperators)
159
+ || stream.match(wordOperators))
160
+ return "operator";
164
161
 
165
- if (stream.match(/^(self|cls)\b/)) {
166
- return "variable-2";
167
- }
162
+ if (stream.match(singleDelimiters))
163
+ return null;
168
164
 
169
- if (stream.match(identifiers)) {
170
- if (state.lastToken == 'def' || state.lastToken == 'class') {
171
- return 'def';
172
- }
173
- return 'variable';
174
- }
165
+ if (stream.match(keywords))
166
+ return "keyword";
167
+
168
+ if (stream.match(builtins))
169
+ return "builtin";
170
+
171
+ if (stream.match(/^(self|cls)\b/))
172
+ return "variable-2";
175
173
 
176
- // Handle non-detected items
177
- stream.next();
178
- return ERRORCLASS;
174
+ if (stream.match(identifiers)) {
175
+ if (state.lastToken == "def" || state.lastToken == "class")
176
+ return "def";
177
+ return "variable";
178
+ }
179
+
180
+ // Handle non-detected items
181
+ stream.next();
182
+ return ERRORCLASS;
179
183
  }
180
184
 
181
185
  function tokenStringFactory(delimiter) {
182
- while ('rub'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) {
183
- delimiter = delimiter.substr(1);
184
- }
185
- var singleline = delimiter.length == 1;
186
- var OUTCLASS = 'string';
187
-
188
- function tokenString(stream, state) {
189
- while (!stream.eol()) {
190
- stream.eatWhile(/[^'"\\]/);
191
- if (stream.eat('\\')) {
192
- stream.next();
193
- if (singleline && stream.eol()) {
194
- return OUTCLASS;
195
- }
196
- } else if (stream.match(delimiter)) {
197
- state.tokenize = tokenBase;
198
- return OUTCLASS;
199
- } else {
200
- stream.eat(/['"]/);
201
- }
202
- }
203
- if (singleline) {
204
- if (parserConf.singleLineStringErrors) {
205
- return ERRORCLASS;
206
- } else {
207
- state.tokenize = tokenBase;
208
- }
209
- }
186
+ while ("rub".indexOf(delimiter.charAt(0).toLowerCase()) >= 0)
187
+ delimiter = delimiter.substr(1);
188
+
189
+ var singleline = delimiter.length == 1;
190
+ var OUTCLASS = "string";
191
+
192
+ function tokenString(stream, state) {
193
+ while (!stream.eol()) {
194
+ stream.eatWhile(/[^'"\\]/);
195
+ if (stream.eat("\\")) {
196
+ stream.next();
197
+ if (singleline && stream.eol())
198
+ return OUTCLASS;
199
+ } else if (stream.match(delimiter)) {
200
+ state.tokenize = tokenBase;
210
201
  return OUTCLASS;
202
+ } else {
203
+ stream.eat(/['"]/);
204
+ }
211
205
  }
212
- tokenString.isString = true;
213
- return tokenString;
206
+ if (singleline) {
207
+ if (parserConf.singleLineStringErrors)
208
+ return ERRORCLASS;
209
+ else
210
+ state.tokenize = tokenBase;
211
+ }
212
+ return OUTCLASS;
213
+ }
214
+ tokenString.isString = true;
215
+ return tokenString;
214
216
  }
215
217
 
216
- function indent(stream, state, type) {
217
- type = type || 'py';
218
- var indentUnit = 0;
219
- if (type === 'py') {
220
- if (state.scopes[0].type !== 'py') {
221
- state.scopes[0].offset = stream.indentation();
222
- return;
223
- }
224
- for (var i = 0; i < state.scopes.length; ++i) {
225
- if (state.scopes[i].type === 'py') {
226
- indentUnit = state.scopes[i].offset + conf.indentUnit;
227
- break;
228
- }
229
- }
230
- } else if (stream.match(/\s*($|#)/, false)) {
231
- // An open paren/bracket/brace with only space or comments after it
232
- // on the line will indent the next line a fixed amount, to make it
233
- // easier to put arguments, list items, etc. on their own lines.
234
- indentUnit = stream.indentation() + hangingIndent;
235
- } else {
236
- indentUnit = stream.column() + stream.current().length;
237
- }
238
- state.scopes.unshift({
239
- offset: indentUnit,
240
- type: type
241
- });
218
+ function pushScope(stream, state, type) {
219
+ var offset = 0, align = null;
220
+ if (type == "py") {
221
+ while (top(state).type != "py")
222
+ state.scopes.pop();
223
+ }
224
+ offset = top(state).offset + (type == "py" ? conf.indentUnit : hangingIndent);
225
+ if (type != "py" && !stream.match(/^(\s|#.*)*$/, false))
226
+ align = stream.column() + 1;
227
+ state.scopes.push({offset: offset, type: type, align: align});
242
228
  }
243
229
 
244
- function dedent(stream, state, type) {
245
- type = type || 'py';
246
- if (state.scopes.length == 1) return;
247
- if (state.scopes[0].type === 'py') {
248
- var _indent = stream.indentation();
249
- var _indent_index = -1;
250
- for (var i = 0; i < state.scopes.length; ++i) {
251
- if (_indent === state.scopes[i].offset) {
252
- _indent_index = i;
253
- break;
254
- }
255
- }
256
- if (_indent_index === -1) {
257
- return true;
258
- }
259
- while (state.scopes[0].offset !== _indent) {
260
- state.scopes.shift();
261
- }
262
- return false;
263
- } else {
264
- if (type === 'py') {
265
- state.scopes[0].offset = stream.indentation();
266
- return false;
267
- } else {
268
- if (state.scopes[0].type != type) {
269
- return true;
270
- }
271
- state.scopes.shift();
272
- return false;
273
- }
274
- }
230
+ function dedent(stream, state) {
231
+ var indented = stream.indentation();
232
+ while (top(state).offset > indented) {
233
+ if (top(state).type != "py") return true;
234
+ state.scopes.pop();
235
+ }
236
+ return top(state).offset != indented;
275
237
  }
276
238
 
277
239
  function tokenLexer(stream, state) {
278
- indentInfo = null;
279
- var style = state.tokenize(stream, state);
280
- var current = stream.current();
281
-
282
- // Handle '.' connected identifiers
283
- if (current === '.') {
284
- style = stream.match(identifiers, false) ? null : ERRORCLASS;
285
- if (style === null && state.lastStyle === 'meta') {
286
- // Apply 'meta' style to '.' connected identifiers when
287
- // appropriate.
288
- style = 'meta';
289
- }
290
- return style;
291
- }
292
-
293
- // Handle decorators
294
- if (current === '@') {
295
- return stream.match(identifiers, false) ? 'meta' : ERRORCLASS;
240
+ var style = state.tokenize(stream, state);
241
+ var current = stream.current();
242
+
243
+ // Handle '.' connected identifiers
244
+ if (current == ".") {
245
+ style = stream.match(identifiers, false) ? null : ERRORCLASS;
246
+ if (style == null && state.lastStyle == "meta") {
247
+ // Apply 'meta' style to '.' connected identifiers when
248
+ // appropriate.
249
+ style = "meta";
296
250
  }
297
-
298
- if ((style === 'variable' || style === 'builtin')
299
- && state.lastStyle === 'meta') {
300
- style = 'meta';
301
- }
302
-
303
- // Handle scope changes.
304
- if (current === 'pass' || current === 'return') {
305
- state.dedent += 1;
306
- }
307
- if (current === 'lambda') state.lambda = true;
308
- if ((current === ':' && !state.lambda && state.scopes[0].type == 'py')
309
- || indentInfo === 'indent') {
310
- indent(stream, state);
311
- }
312
- var delimiter_index = '[({'.indexOf(current);
313
- if (delimiter_index !== -1) {
314
- indent(stream, state, '])}'.slice(delimiter_index, delimiter_index+1));
315
- }
316
- if (indentInfo === 'dedent') {
317
- if (dedent(stream, state)) {
318
- return ERRORCLASS;
319
- }
320
- }
321
- delimiter_index = '])}'.indexOf(current);
322
- if (delimiter_index !== -1) {
323
- if (dedent(stream, state, current)) {
324
- return ERRORCLASS;
325
- }
326
- }
327
- if (state.dedent > 0 && stream.eol() && state.scopes[0].type == 'py') {
328
- if (state.scopes.length > 1) state.scopes.shift();
329
- state.dedent -= 1;
330
- }
331
-
332
251
  return style;
252
+ }
253
+
254
+ // Handle decorators
255
+ if (current == "@")
256
+ return stream.match(identifiers, false) ? "meta" : ERRORCLASS;
257
+
258
+ if ((style == "variable" || style == "builtin")
259
+ && state.lastStyle == "meta")
260
+ style = "meta";
261
+
262
+ // Handle scope changes.
263
+ if (current == "pass" || current == "return")
264
+ state.dedent += 1;
265
+
266
+ if (current == "lambda") state.lambda = true;
267
+ if (current == ":" && !state.lambda && top(state).type == "py")
268
+ pushScope(stream, state, "py");
269
+
270
+ var delimiter_index = current.length == 1 ? "[({".indexOf(current) : -1;
271
+ if (delimiter_index != -1)
272
+ pushScope(stream, state, "])}".slice(delimiter_index, delimiter_index+1));
273
+
274
+ delimiter_index = "])}".indexOf(current);
275
+ if (delimiter_index != -1) {
276
+ if (top(state).type == current) state.scopes.pop();
277
+ else return ERRORCLASS;
278
+ }
279
+ if (state.dedent > 0 && stream.eol() && top(state).type == "py") {
280
+ if (state.scopes.length > 1) state.scopes.pop();
281
+ state.dedent -= 1;
282
+ }
283
+
284
+ return style;
333
285
  }
334
286
 
335
287
  var external = {
336
- startState: function(basecolumn) {
337
- return {
338
- tokenize: tokenBase,
339
- scopes: [{offset:basecolumn || 0, type:'py'}],
340
- lastStyle: null,
341
- lastToken: null,
342
- lambda: false,
343
- dedent: 0
344
- };
345
- },
346
-
347
- token: function(stream, state) {
348
- var style = tokenLexer(stream, state);
349
-
350
- state.lastStyle = style;
351
-
352
- var current = stream.current();
353
- if (current && style) {
354
- state.lastToken = current;
355
- }
356
-
357
- if (stream.eol() && state.lambda) {
358
- state.lambda = false;
359
- }
360
- return style;
361
- },
362
-
363
- indent: function(state) {
364
- if (state.tokenize != tokenBase) {
365
- return state.tokenize.isString ? CodeMirror.Pass : 0;
366
- }
367
-
368
- return state.scopes[0].offset;
369
- },
370
-
371
- lineComment: "#",
372
- fold: "indent"
288
+ startState: function(basecolumn) {
289
+ return {
290
+ tokenize: tokenBase,
291
+ scopes: [{offset: basecolumn || 0, type: "py", align: null}],
292
+ lastStyle: null,
293
+ lastToken: null,
294
+ lambda: false,
295
+ dedent: 0
296
+ };
297
+ },
298
+
299
+ token: function(stream, state) {
300
+ var addErr = state.errorToken;
301
+ if (addErr) state.errorToken = false;
302
+ var style = tokenLexer(stream, state);
303
+
304
+ state.lastStyle = style;
305
+
306
+ var current = stream.current();
307
+ if (current && style)
308
+ state.lastToken = current;
309
+
310
+ if (stream.eol() && state.lambda)
311
+ state.lambda = false;
312
+ return addErr ? style + " " + ERRORCLASS : style;
313
+ },
314
+
315
+ indent: function(state, textAfter) {
316
+ if (state.tokenize != tokenBase)
317
+ return state.tokenize.isString ? CodeMirror.Pass : 0;
318
+
319
+ var scope = top(state);
320
+ var closing = textAfter && textAfter.charAt(0) == scope.type;
321
+ if (scope.align != null)
322
+ return scope.align - (closing ? 1 : 0);
323
+ else
324
+ return scope.offset - (closing ? conf.indentUnit : 0);
325
+ },
326
+
327
+ lineComment: "#",
328
+ fold: "indent"
373
329
  };
374
330
  return external;
375
- });
331
+ });
376
332
 
377
- CodeMirror.defineMIME("text/x-python", "python");
333
+ CodeMirror.defineMIME("text/x-python", "python");
378
334
 
379
- var words = function(str){return str.split(' ');};
335
+ var words = function(str) { return str.split(" "); };
380
336
 
381
- CodeMirror.defineMIME("text/x-cython", {
382
- name: "python",
383
- extra_keywords: words("by cdef cimport cpdef ctypedef enum except"+
384
- "extern gil include nogil property public"+
385
- "readonly struct union DEF IF ELIF ELSE")
386
- });
337
+ CodeMirror.defineMIME("text/x-cython", {
338
+ name: "python",
339
+ extra_keywords: words("by cdef cimport cpdef ctypedef enum except"+
340
+ "extern gil include nogil property public"+
341
+ "readonly struct union DEF IF ELIF ELSE")
342
+ });
387
343
 
388
344
  });