codemirror-rails 2.24 → 2.32
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Rakefile +19 -0
- data/codemirror-rails.gemspec +6 -1
- data/lib/codemirror/rails/version.rb +2 -2
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +56 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/integration/codemirror_rails_integration_test.rb +13 -0
- data/test/test_helper.rb +13 -0
- data/vendor/assets/javascripts/codemirror.js +381 -197
- data/vendor/assets/javascripts/codemirror/keymaps/emacs.js +1 -1
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +649 -94
- data/vendor/assets/javascripts/codemirror/modes/clike.js +53 -7
- data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +12 -7
- data/vendor/assets/javascripts/codemirror/modes/diff.js +24 -5
- data/vendor/assets/javascripts/codemirror/modes/ecl.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/erlang.js +463 -0
- data/vendor/assets/javascripts/codemirror/modes/gfm.js +38 -2
- data/vendor/assets/javascripts/codemirror/modes/go.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/groovy.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/haxe.js +432 -0
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/less.js +93 -93
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +29 -6
- data/vendor/assets/javascripts/codemirror/modes/mysql.js +6 -8
- data/vendor/assets/javascripts/codemirror/modes/ocaml.js +114 -0
- data/vendor/assets/javascripts/codemirror/modes/pascal.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/pig.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/plsql.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/python.js +13 -16
- data/vendor/assets/javascripts/codemirror/modes/ruby.js +3 -8
- data/vendor/assets/javascripts/codemirror/modes/scheme.js +74 -46
- data/vendor/assets/javascripts/codemirror/modes/shell.js +22 -7
- data/vendor/assets/javascripts/codemirror/modes/stex.js +7 -5
- data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +14 -14
- data/vendor/assets/javascripts/codemirror/modes/vb.js +260 -0
- data/vendor/assets/javascripts/codemirror/modes/verilog.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/xml.js +2 -1
- data/vendor/assets/javascripts/codemirror/modes/xquery.js +3 -3
- data/vendor/assets/javascripts/codemirror/utils/closetag.js +24 -34
- data/vendor/assets/javascripts/codemirror/utils/dialog.js +5 -1
- data/vendor/assets/javascripts/codemirror/utils/foldcode.js +10 -5
- data/vendor/assets/javascripts/codemirror/utils/formatting.js +8 -3
- data/vendor/assets/javascripts/codemirror/utils/loadmode.js +2 -1
- data/vendor/assets/javascripts/codemirror/utils/match-highlighter.js +1 -1
- data/vendor/assets/javascripts/codemirror/utils/multiplex.js +81 -0
- data/vendor/assets/javascripts/codemirror/utils/overlay.js +2 -1
- data/vendor/assets/javascripts/codemirror/utils/pig-hint.js +123 -0
- data/vendor/assets/javascripts/codemirror/utils/search.js +16 -12
- data/vendor/assets/javascripts/codemirror/utils/searchcursor.js +1 -1
- data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +4 -0
- data/vendor/assets/javascripts/codemirror/utils/xml-hint.js +137 -0
- data/vendor/assets/stylesheets/codemirror.css +59 -4
- data/vendor/assets/stylesheets/codemirror/modes/tiddlywiki.css +14 -21
- data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +1 -2
- data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +21 -0
- data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +2 -3
- data/vendor/assets/stylesheets/codemirror/themes/night.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/vibrant-ink.css +27 -0
- data/vendor/assets/stylesheets/codemirror/utils/dialog.css +4 -0
- metadata +98 -5
- data/vendor/assets/javascripts/codemirror/modes/rpm-spec.css +0 -5
@@ -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)) {
|
57
|
+
else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
|
58
58
|
stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
|
59
59
|
return ret("number", "number");
|
60
60
|
}
|
@@ -1,26 +1,26 @@
|
|
1
1
|
/*
|
2
|
-
LESS mode - http://www.lesscss.org/
|
3
|
-
Ported to CodeMirror by Peter Kroon
|
2
|
+
LESS mode - http://www.lesscss.org/
|
3
|
+
Ported to CodeMirror by Peter Kroon
|
4
4
|
*/
|
5
5
|
|
6
|
-
CodeMirror.defineMode("
|
6
|
+
CodeMirror.defineMode("less", function(config) {
|
7
7
|
var indentUnit = config.indentUnit, type;
|
8
8
|
function ret(style, tp) {type = tp; return style;}
|
9
9
|
//html5 tags
|
10
10
|
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
11
|
|
12
12
|
function inTagsArray(val){
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
for(var i=0; i<tags.length; i++){
|
14
|
+
if(val === tags[i]){
|
15
|
+
return true;
|
16
|
+
}
|
17
|
+
}
|
18
18
|
}
|
19
19
|
|
20
20
|
function tokenBase(stream, state) {
|
21
21
|
var ch = stream.next();
|
22
22
|
|
23
|
-
|
23
|
+
if (ch == "@") {stream.eatWhile(/[\w\-]/); return ret("meta", stream.current());}
|
24
24
|
else if (ch == "/" && stream.eat("*")) {
|
25
25
|
state.tokenize = tokenCComment;
|
26
26
|
return tokenCComment(stream, state);
|
@@ -35,15 +35,15 @@ CodeMirror.defineMode("css", function(config) {
|
|
35
35
|
state.tokenize = tokenString(ch);
|
36
36
|
return state.tokenize(stream, state);
|
37
37
|
}
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
38
|
+
else if (ch == "/") { // lesscss e.g.: .png will not be parsed as a class
|
39
|
+
if(stream.eat("/")){
|
40
|
+
state.tokenize = tokenSComment;
|
41
|
+
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
|
45
45
|
return ret("number", "unit");
|
46
|
-
|
46
|
+
}
|
47
47
|
}
|
48
48
|
else if (ch == "!") {
|
49
49
|
stream.match(/^\s*\w*/);
|
@@ -58,93 +58,93 @@ CodeMirror.defineMode("css", function(config) {
|
|
58
58
|
}
|
59
59
|
else if (/[;{}:\[\]()]/.test(ch)) { //added () char for lesscss original was [;{}:\[\]]
|
60
60
|
if(ch == ":"){
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
+
}
|
70
70
|
}
|
71
|
-
|
72
|
-
|
71
|
+
else if (ch == ".") { // lesscss
|
72
|
+
stream.eatWhile(/[\a-zA-Z0-9\-_]/);
|
73
73
|
return ret("tag", "tag");
|
74
74
|
}
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
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 == "&") {
|
105
|
+
stream.eatWhile(/[\w\-]/);
|
106
|
+
return ret(null, ch);
|
103
107
|
}
|
104
|
-
else if (ch == "&") {
|
105
|
-
stream.eatWhile(/[\w\-]/);
|
106
|
-
return ret(null, ch);
|
107
|
-
}
|
108
108
|
else {
|
109
109
|
stream.eatWhile(/[\w\\\-_%.{]/);
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
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{
|
136
136
|
return ret("variable", "variable");
|
137
|
-
|
137
|
+
}
|
138
138
|
}
|
139
139
|
|
140
140
|
}
|
141
141
|
|
142
142
|
function tokenSComment(stream, state) {// SComment = Slash comment
|
143
143
|
stream.skipToEnd();
|
144
|
-
|
144
|
+
state.tokenize = tokenBase;
|
145
145
|
return ret("comment", "comment");
|
146
146
|
}
|
147
|
-
|
147
|
+
|
148
148
|
function tokenCComment(stream, state) {
|
149
149
|
var maybeEnd = false, ch;
|
150
150
|
while ((ch = stream.next()) != null) {
|
@@ -198,10 +198,10 @@ CodeMirror.defineMode("css", function(config) {
|
|
198
198
|
else if (style == "variable") {
|
199
199
|
if (context == "rule") style = null; //"tag"
|
200
200
|
else if (!context || context == "@media{"){
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
201
|
+
style = stream.current() == "when" ? "variable" :
|
202
|
+
stream.string.match(/#/g) != undefined ? null :
|
203
|
+
/[\s,|\s\)]/.test(stream.peek()) ? "tag" : null;
|
204
|
+
}
|
205
205
|
}
|
206
206
|
|
207
207
|
if (context == "rule" && /^[\{\};]$/.test(type))
|
@@ -1,6 +1,7 @@
|
|
1
1
|
CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
2
2
|
|
3
|
-
var
|
3
|
+
var htmlFound = CodeMirror.mimeModes.hasOwnProperty("text/html");
|
4
|
+
var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? "text/html" : "text/plain");
|
4
5
|
|
5
6
|
var header = 'header'
|
6
7
|
, code = 'comment'
|
@@ -37,6 +38,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
37
38
|
state.em = false;
|
38
39
|
// Reset STRONG state
|
39
40
|
state.strong = false;
|
41
|
+
if (!htmlFound && state.f == htmlBlock) {
|
42
|
+
state.f = inlineNormal;
|
43
|
+
state.block = blockNormal;
|
44
|
+
}
|
40
45
|
return null;
|
41
46
|
}
|
42
47
|
|
@@ -67,9 +72,14 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
67
72
|
|
68
73
|
function htmlBlock(stream, state) {
|
69
74
|
var style = htmlMode.token(stream, state.htmlState);
|
70
|
-
if (style === 'tag' && state.htmlState.type !== 'openTag' && !state.htmlState.context) {
|
75
|
+
if (htmlFound && style === 'tag' && state.htmlState.type !== 'openTag' && !state.htmlState.context) {
|
76
|
+
state.f = inlineNormal;
|
77
|
+
state.block = blockNormal;
|
78
|
+
}
|
79
|
+
if (state.md_inside && stream.current().indexOf(">")!=-1) {
|
71
80
|
state.f = inlineNormal;
|
72
81
|
state.block = blockNormal;
|
82
|
+
state.htmlState.context = undefined;
|
73
83
|
}
|
74
84
|
return style;
|
75
85
|
}
|
@@ -113,10 +123,22 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
113
123
|
return switchInline(stream, state, linkText);
|
114
124
|
}
|
115
125
|
if (ch === '<' && stream.match(/^\w/, false)) {
|
126
|
+
var md_inside = false;
|
127
|
+
if (stream.string.indexOf(">")!=-1) {
|
128
|
+
var atts = stream.string.substring(1,stream.string.indexOf(">"));
|
129
|
+
if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) {
|
130
|
+
state.md_inside = true;
|
131
|
+
}
|
132
|
+
}
|
116
133
|
stream.backUp(1);
|
117
134
|
return switchBlock(stream, state, htmlBlock);
|
118
135
|
}
|
119
|
-
|
136
|
+
|
137
|
+
if (ch === '<' && stream.match(/^\/\w*?>/)) {
|
138
|
+
state.md_inside = false;
|
139
|
+
return "tag";
|
140
|
+
}
|
141
|
+
|
120
142
|
var t = getType(state);
|
121
143
|
if (ch === '*' || ch === '_') {
|
122
144
|
if (stream.eat(ch)) {
|
@@ -188,7 +210,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
188
210
|
f: blockNormal,
|
189
211
|
|
190
212
|
block: blockNormal,
|
191
|
-
htmlState:
|
213
|
+
htmlState: CodeMirror.startState(htmlMode),
|
192
214
|
indentation: 0,
|
193
215
|
|
194
216
|
inline: inlineNormal,
|
@@ -207,13 +229,14 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
207
229
|
block: s.block,
|
208
230
|
htmlState: CodeMirror.copyState(htmlMode, s.htmlState),
|
209
231
|
indentation: s.indentation,
|
210
|
-
|
232
|
+
|
211
233
|
inline: s.inline,
|
212
234
|
text: s.text,
|
213
235
|
em: s.em,
|
214
236
|
strong: s.strong,
|
215
237
|
header: s.header,
|
216
|
-
quote: s.quote
|
238
|
+
quote: s.quote,
|
239
|
+
md_inside: s.md_inside
|
217
240
|
};
|
218
241
|
},
|
219
242
|
|
@@ -15,7 +15,7 @@ CodeMirror.defineMode("mysql", function(config) {
|
|
15
15
|
var ops = wordRegexp(["str", "lang", "langmatches", "datatype", "bound", "sameterm", "isiri", "isuri",
|
16
16
|
"isblank", "isliteral", "union", "a"]);
|
17
17
|
var keywords = wordRegexp([
|
18
|
-
|
18
|
+
('ACCESSIBLE'),('ALTER'),('AS'),('BEFORE'),('BINARY'),('BY'),('CASE'),('CHARACTER'),('COLUMN'),('CONTINUE'),('CROSS'),('CURRENT_TIMESTAMP'),('DATABASE'),('DAY_MICROSECOND'),('DEC'),('DEFAULT'),
|
19
19
|
('DESC'),('DISTINCT'),('DOUBLE'),('EACH'),('ENCLOSED'),('EXIT'),('FETCH'),('FLOAT8'),('FOREIGN'),('GRANT'),('HIGH_PRIORITY'),('HOUR_SECOND'),('IN'),('INNER'),('INSERT'),('INT2'),('INT8'),
|
20
20
|
('INTO'),('JOIN'),('KILL'),('LEFT'),('LINEAR'),('LOCALTIME'),('LONG'),('LOOP'),('MATCH'),('MEDIUMTEXT'),('MINUTE_SECOND'),('NATURAL'),('NULL'),('OPTIMIZE'),('OR'),('OUTER'),('PRIMARY'),
|
21
21
|
('RANGE'),('READ_WRITE'),('REGEXP'),('REPEAT'),('RESTRICT'),('RIGHT'),('SCHEMAS'),('SENSITIVE'),('SHOW'),('SPECIFIC'),('SQLSTATE'),('SQL_CALC_FOUND_ROWS'),('STARTING'),('TERMINATED'),
|
@@ -57,13 +57,11 @@ CodeMirror.defineMode("mysql", function(config) {
|
|
57
57
|
return null;
|
58
58
|
}
|
59
59
|
else if (ch == "-") {
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
}
|
66
|
-
|
60
|
+
var ch2 = stream.next();
|
61
|
+
if (ch2=="-") {
|
62
|
+
stream.skipToEnd();
|
63
|
+
return "comment";
|
64
|
+
}
|
67
65
|
}
|
68
66
|
else if (operatorChars.test(ch)) {
|
69
67
|
stream.eatWhile(operatorChars);
|
@@ -0,0 +1,114 @@
|
|
1
|
+
CodeMirror.defineMode('ocaml', function(config) {
|
2
|
+
|
3
|
+
var words = {
|
4
|
+
'true': 'atom',
|
5
|
+
'false': 'atom',
|
6
|
+
'let': 'keyword',
|
7
|
+
'rec': 'keyword',
|
8
|
+
'in': 'keyword',
|
9
|
+
'of': 'keyword',
|
10
|
+
'and': 'keyword',
|
11
|
+
'succ': 'keyword',
|
12
|
+
'if': 'keyword',
|
13
|
+
'then': 'keyword',
|
14
|
+
'else': 'keyword',
|
15
|
+
'for': 'keyword',
|
16
|
+
'to': 'keyword',
|
17
|
+
'while': 'keyword',
|
18
|
+
'do': 'keyword',
|
19
|
+
'done': 'keyword',
|
20
|
+
'fun': 'keyword',
|
21
|
+
'function': 'keyword',
|
22
|
+
'val': 'keyword',
|
23
|
+
'type': 'keyword',
|
24
|
+
'mutable': 'keyword',
|
25
|
+
'match': 'keyword',
|
26
|
+
'with': 'keyword',
|
27
|
+
'try': 'keyword',
|
28
|
+
'raise': 'keyword',
|
29
|
+
'begin': 'keyword',
|
30
|
+
'end': 'keyword',
|
31
|
+
'open': 'builtin',
|
32
|
+
'trace': 'builtin',
|
33
|
+
'ignore': 'builtin',
|
34
|
+
'exit': 'builtin',
|
35
|
+
'print_string': 'builtin',
|
36
|
+
'print_endline': 'builtin'
|
37
|
+
};
|
38
|
+
|
39
|
+
function tokenBase(stream, state) {
|
40
|
+
var sol = stream.sol();
|
41
|
+
var ch = stream.next();
|
42
|
+
|
43
|
+
if (ch === '"') {
|
44
|
+
state.tokenize = tokenString;
|
45
|
+
return state.tokenize(stream, state);
|
46
|
+
}
|
47
|
+
if (ch === '(') {
|
48
|
+
if (stream.eat('*')) {
|
49
|
+
state.commentLevel++;
|
50
|
+
state.tokenize = tokenComment;
|
51
|
+
return state.tokenize(stream, state);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
if (ch === '~') {
|
55
|
+
stream.eatWhile(/\w/);
|
56
|
+
return 'variable-2';
|
57
|
+
}
|
58
|
+
if (ch === '`') {
|
59
|
+
stream.eatWhile(/\w/);
|
60
|
+
return 'quote';
|
61
|
+
}
|
62
|
+
if (/\d/.test(ch)) {
|
63
|
+
stream.eatWhile(/[\d]/);
|
64
|
+
if (stream.eat('.')) {
|
65
|
+
stream.eatWhile(/[\d]/);
|
66
|
+
}
|
67
|
+
return 'number';
|
68
|
+
}
|
69
|
+
if ( /[+\-*&%=<>!?|]/.test(ch)) {
|
70
|
+
return 'operator';
|
71
|
+
}
|
72
|
+
stream.eatWhile(/\w/);
|
73
|
+
var cur = stream.current();
|
74
|
+
return words[cur] || 'variable';
|
75
|
+
}
|
76
|
+
|
77
|
+
function tokenString(stream, state) {
|
78
|
+
var next, end = false, escaped = false;
|
79
|
+
while ((next = stream.next()) != null) {
|
80
|
+
if (next === '"' && !escaped) {
|
81
|
+
end = true;
|
82
|
+
break;
|
83
|
+
}
|
84
|
+
escaped = !escaped && next === '\\';
|
85
|
+
}
|
86
|
+
if (end && !escaped) {
|
87
|
+
state.tokenize = tokenBase;
|
88
|
+
}
|
89
|
+
return 'string';
|
90
|
+
};
|
91
|
+
|
92
|
+
function tokenComment(stream, state) {
|
93
|
+
var prev, next;
|
94
|
+
while(state.commentLevel > 0 && (next = stream.next()) != null) {
|
95
|
+
if (prev === '(' && next === '*') state.commentLevel++;
|
96
|
+
if (prev === '*' && next === ')') state.commentLevel--;
|
97
|
+
prev = next;
|
98
|
+
}
|
99
|
+
if (state.commentLevel <= 0) {
|
100
|
+
state.tokenize = tokenBase;
|
101
|
+
}
|
102
|
+
return 'comment';
|
103
|
+
}
|
104
|
+
|
105
|
+
return {
|
106
|
+
startState: function() {return {tokenize: tokenBase, commentLevel: 0}},
|
107
|
+
token: function(stream, state) {
|
108
|
+
if (stream.eatSpace()) return null;
|
109
|
+
return state.tokenize(stream, state);
|
110
|
+
}
|
111
|
+
};
|
112
|
+
});
|
113
|
+
|
114
|
+
CodeMirror.defineMIME('text/x-ocaml', 'ocaml');
|