codemirror-rails 2.21.1 → 2.22
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -0
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror.js +160 -86
- data/vendor/assets/javascripts/codemirror/modes/clike.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/clojure.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/ecl.js +203 -0
- data/vendor/assets/javascripts/codemirror/modes/gfm.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/go.js +20 -22
- data/vendor/assets/javascripts/codemirror/modes/less.js +5 -2
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +58 -24
- data/vendor/assets/javascripts/codemirror/modes/pascal.js +2 -46
- data/vendor/assets/javascripts/codemirror/modes/perl.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/php.js +53 -24
- data/vendor/assets/javascripts/codemirror/modes/properties.js +57 -0
- data/vendor/assets/javascripts/codemirror/modes/rpm-spec.css +5 -0
- data/vendor/assets/javascripts/codemirror/modes/rpm-spec.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/ruby.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +16 -16
- data/vendor/assets/javascripts/codemirror/modes/verilog.js +194 -194
- data/vendor/assets/javascripts/codemirror/modes/xml.js +15 -8
- data/vendor/assets/javascripts/codemirror/utils/dialog.js +63 -0
- data/vendor/assets/javascripts/codemirror/utils/foldcode.js +186 -0
- data/vendor/assets/javascripts/codemirror/utils/formatting.js +294 -0
- data/vendor/assets/javascripts/codemirror/utils/javascript-hint.js +132 -0
- data/vendor/assets/javascripts/codemirror/utils/match-highlighter.js +44 -0
- data/vendor/assets/javascripts/codemirror/{overlay.js → utils/overlay.js} +0 -0
- data/vendor/assets/javascripts/codemirror/utils/runmode.js +49 -0
- data/vendor/assets/javascripts/codemirror/utils/search.js +114 -0
- data/vendor/assets/javascripts/codemirror/utils/searchcursor.js +117 -0
- data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +66 -0
- data/vendor/assets/stylesheets/codemirror.css +3 -0
- data/vendor/assets/stylesheets/codemirror/modes/properties.css +3 -0
- data/vendor/assets/stylesheets/codemirror/themes/rubyblue.css +1 -1
- data/vendor/assets/stylesheets/codemirror/utils/dialog.css +23 -0
- data/vendor/assets/stylesheets/codemirror/utils/simple-hint.css +16 -0
- metadata +20 -6
- data/vendor/assets/javascripts/codemirror/runmode.js +0 -27
@@ -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 =
|
62
|
+
state.tokenize = null;
|
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 =
|
71
|
+
state.tokenize = null;
|
72
72
|
break;
|
73
73
|
}
|
74
74
|
maybeEnd = (ch == "*");
|
@@ -0,0 +1,203 @@
|
|
1
|
+
CodeMirror.defineMode("ecl", function(config) {
|
2
|
+
|
3
|
+
function words(str) {
|
4
|
+
var obj = {}, words = str.split(" ");
|
5
|
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
6
|
+
return obj;
|
7
|
+
}
|
8
|
+
|
9
|
+
function metaHook(stream, state) {
|
10
|
+
if (!state.startOfLine) return false;
|
11
|
+
stream.skipToEnd();
|
12
|
+
return "meta";
|
13
|
+
}
|
14
|
+
|
15
|
+
function tokenAtString(stream, state) {
|
16
|
+
var next;
|
17
|
+
while ((next = stream.next()) != null) {
|
18
|
+
if (next == '"' && !stream.eat('"')) {
|
19
|
+
state.tokenize = null;
|
20
|
+
break;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
return "string";
|
24
|
+
}
|
25
|
+
|
26
|
+
var indentUnit = config.indentUnit;
|
27
|
+
var keyword = words("abs acos allnodes ascii asin asstring atan atan2 ave case choose choosen choosesets clustersize combine correlation cos cosh count covariance cron dataset dedup define denormalize distribute distributed distribution ebcdic enth error evaluate event eventextra eventname exists exp failcode failmessage fetch fromunicode getisvalid global graph group hash hash32 hash64 hashcrc hashmd5 having if index intformat isvalid iterate join keyunicode length library limit ln local log loop map matched matchlength matchposition matchtext matchunicode max merge mergejoin min nolocal nonempty normalize parse pipe power preload process project pull random range rank ranked realformat recordof regexfind regexreplace regroup rejected rollup round roundup row rowdiff sample set sin sinh sizeof soapcall sort sorted sqrt stepped stored sum table tan tanh thisnode topn tounicode transfer trim truncate typeof ungroup unicodeorder variance which workunit xmldecode xmlencode xmltext xmlunicode");
|
28
|
+
var variable = words("apply assert build buildindex evaluate fail keydiff keypatch loadxml nothor notify output parallel sequential soapcall wait");
|
29
|
+
var variable_2 = words("__compressed__ all and any as atmost before beginc++ best between case const counter csv descend encrypt end endc++ endmacro except exclusive expire export extend false few first flat from full function group header heading hole ifblock import in interface joined keep keyed last left limit load local locale lookup macro many maxcount maxlength min skew module named nocase noroot noscan nosort not of only opt or outer overwrite packed partition penalty physicallength pipe quote record relationship repeat return right scan self separator service shared skew skip sql store terminator thor threshold token transform trim true type unicodeorder unsorted validate virtual whole wild within xml xpath");
|
30
|
+
var variable_3 = words("ascii big_endian boolean data decimal ebcdic integer pattern qstring real record rule set of string token udecimal unicode unsigned varstring varunicode");
|
31
|
+
var builtin = words("checkpoint deprecated failcode failmessage failure global independent onwarning persist priority recovery stored success wait when");
|
32
|
+
var blockKeywords = words("catch class do else finally for if switch try while");
|
33
|
+
var atoms = words("true false null");
|
34
|
+
var hooks = {"#": metaHook};
|
35
|
+
var multiLineStrings;
|
36
|
+
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
37
|
+
|
38
|
+
var curPunc;
|
39
|
+
|
40
|
+
function tokenBase(stream, state) {
|
41
|
+
var ch = stream.next();
|
42
|
+
if (hooks[ch]) {
|
43
|
+
var result = hooks[ch](stream, state);
|
44
|
+
if (result !== false) return result;
|
45
|
+
}
|
46
|
+
if (ch == '"' || ch == "'") {
|
47
|
+
state.tokenize = tokenString(ch);
|
48
|
+
return state.tokenize(stream, state);
|
49
|
+
}
|
50
|
+
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
51
|
+
curPunc = ch;
|
52
|
+
return null
|
53
|
+
}
|
54
|
+
if (/\d/.test(ch)) {
|
55
|
+
stream.eatWhile(/[\w\.]/);
|
56
|
+
return "number";
|
57
|
+
}
|
58
|
+
if (ch == "/") {
|
59
|
+
if (stream.eat("*")) {
|
60
|
+
state.tokenize = tokenComment;
|
61
|
+
return tokenComment(stream, state);
|
62
|
+
}
|
63
|
+
if (stream.eat("/")) {
|
64
|
+
stream.skipToEnd();
|
65
|
+
return "comment";
|
66
|
+
}
|
67
|
+
}
|
68
|
+
if (isOperatorChar.test(ch)) {
|
69
|
+
stream.eatWhile(isOperatorChar);
|
70
|
+
return "operator";
|
71
|
+
}
|
72
|
+
stream.eatWhile(/[\w\$_]/);
|
73
|
+
var cur = stream.current().toLowerCase();
|
74
|
+
if (keyword.propertyIsEnumerable(cur)) {
|
75
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
76
|
+
return "keyword";
|
77
|
+
} else if (variable.propertyIsEnumerable(cur)) {
|
78
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
79
|
+
return "variable";
|
80
|
+
} else if (variable_2.propertyIsEnumerable(cur)) {
|
81
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
82
|
+
return "variable-2";
|
83
|
+
} else if (variable_3.propertyIsEnumerable(cur)) {
|
84
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
85
|
+
return "variable-3";
|
86
|
+
} else if (builtin.propertyIsEnumerable(cur)) {
|
87
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
88
|
+
return "builtin";
|
89
|
+
} else { //Data types are of from KEYWORD##
|
90
|
+
var i = cur.length - 1;
|
91
|
+
while(i >= 0 && (!isNaN(cur[i]) || cur[i] == '_'))
|
92
|
+
--i;
|
93
|
+
|
94
|
+
if (i > 0) {
|
95
|
+
var cur2 = cur.substr(0, i + 1);
|
96
|
+
if (variable_3.propertyIsEnumerable(cur2)) {
|
97
|
+
if (blockKeywords.propertyIsEnumerable(cur2)) curPunc = "newstatement";
|
98
|
+
return "variable-3";
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
103
|
+
return "word";
|
104
|
+
}
|
105
|
+
|
106
|
+
function tokenString(quote) {
|
107
|
+
return function(stream, state) {
|
108
|
+
var escaped = false, next, end = false;
|
109
|
+
while ((next = stream.next()) != null) {
|
110
|
+
if (next == quote && !escaped) {end = true; break;}
|
111
|
+
escaped = !escaped && next == "\\";
|
112
|
+
}
|
113
|
+
if (end || !(escaped || multiLineStrings))
|
114
|
+
state.tokenize = tokenBase;
|
115
|
+
return "string";
|
116
|
+
};
|
117
|
+
}
|
118
|
+
|
119
|
+
function tokenComment(stream, state) {
|
120
|
+
var maybeEnd = false, ch;
|
121
|
+
while (ch = stream.next()) {
|
122
|
+
if (ch == "/" && maybeEnd) {
|
123
|
+
state.tokenize = tokenBase;
|
124
|
+
break;
|
125
|
+
}
|
126
|
+
maybeEnd = (ch == "*");
|
127
|
+
}
|
128
|
+
return "comment";
|
129
|
+
}
|
130
|
+
|
131
|
+
function Context(indented, column, type, align, prev) {
|
132
|
+
this.indented = indented;
|
133
|
+
this.column = column;
|
134
|
+
this.type = type;
|
135
|
+
this.align = align;
|
136
|
+
this.prev = prev;
|
137
|
+
}
|
138
|
+
function pushContext(state, col, type) {
|
139
|
+
return state.context = new Context(state.indented, col, type, null, state.context);
|
140
|
+
}
|
141
|
+
function popContext(state) {
|
142
|
+
var t = state.context.type;
|
143
|
+
if (t == ")" || t == "]" || t == "}")
|
144
|
+
state.indented = state.context.indented;
|
145
|
+
return state.context = state.context.prev;
|
146
|
+
}
|
147
|
+
|
148
|
+
// Interface
|
149
|
+
|
150
|
+
return {
|
151
|
+
startState: function(basecolumn) {
|
152
|
+
return {
|
153
|
+
tokenize: null,
|
154
|
+
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
155
|
+
indented: 0,
|
156
|
+
startOfLine: true
|
157
|
+
};
|
158
|
+
},
|
159
|
+
|
160
|
+
token: function(stream, state) {
|
161
|
+
var ctx = state.context;
|
162
|
+
if (stream.sol()) {
|
163
|
+
if (ctx.align == null) ctx.align = false;
|
164
|
+
state.indented = stream.indentation();
|
165
|
+
state.startOfLine = true;
|
166
|
+
}
|
167
|
+
if (stream.eatSpace()) return null;
|
168
|
+
curPunc = null;
|
169
|
+
var style = (state.tokenize || tokenBase)(stream, state);
|
170
|
+
if (style == "comment" || style == "meta") return style;
|
171
|
+
if (ctx.align == null) ctx.align = true;
|
172
|
+
|
173
|
+
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
174
|
+
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
175
|
+
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
176
|
+
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
177
|
+
else if (curPunc == "}") {
|
178
|
+
while (ctx.type == "statement") ctx = popContext(state);
|
179
|
+
if (ctx.type == "}") ctx = popContext(state);
|
180
|
+
while (ctx.type == "statement") ctx = popContext(state);
|
181
|
+
}
|
182
|
+
else if (curPunc == ctx.type) popContext(state);
|
183
|
+
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
184
|
+
pushContext(state, stream.column(), "statement");
|
185
|
+
state.startOfLine = false;
|
186
|
+
return style;
|
187
|
+
},
|
188
|
+
|
189
|
+
indent: function(state, textAfter) {
|
190
|
+
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
|
191
|
+
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
192
|
+
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
193
|
+
var closing = firstChar == ctx.type;
|
194
|
+
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
|
195
|
+
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
196
|
+
else return ctx.indented + (closing ? 0 : indentUnit);
|
197
|
+
},
|
198
|
+
|
199
|
+
electricChars: "{}"
|
200
|
+
};
|
201
|
+
});
|
202
|
+
|
203
|
+
CodeMirror.defineMIME("text/x-ecl");
|
@@ -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
|
-
"
|
9
|
-
"
|
10
|
-
"
|
11
|
-
"
|
12
|
-
"
|
13
|
-
"uint":true, "uintptr":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
|
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
|
-
"
|
20
|
-
"real":true, "recover":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
|
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 (
|
69
|
+
if (cur == "case" || cur == "default") curPunc = "case";
|
70
70
|
return "keyword";
|
71
71
|
}
|
72
72
|
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
@@ -133,6 +133,7 @@ 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 = "}";
|
136
137
|
}
|
137
138
|
if (stream.eatSpace()) return null;
|
138
139
|
curPunc = null;
|
@@ -143,14 +144,9 @@ CodeMirror.defineMode("go", function(config, parserConfig) {
|
|
143
144
|
if (curPunc == "{") pushContext(state, stream.column(), "}");
|
144
145
|
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
145
146
|
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
146
|
-
else if (curPunc == "
|
147
|
-
|
148
|
-
if (ctx.type == "}") ctx = popContext(state);
|
149
|
-
while (ctx.type == "statement") ctx = popContext(state);
|
150
|
-
}
|
147
|
+
else if (curPunc == "case") ctx.type = "case"
|
148
|
+
else if (curPunc == "}" && ctx.type == "}") ctx = popContext(state);
|
151
149
|
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");
|
154
150
|
state.startOfLine = false;
|
155
151
|
return style;
|
156
152
|
},
|
@@ -158,14 +154,16 @@ CodeMirror.defineMode("go", function(config, parserConfig) {
|
|
158
154
|
indent: function(state, textAfter) {
|
159
155
|
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
|
160
156
|
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
161
|
-
if (ctx.type == "
|
157
|
+
if (ctx.type == "case" && /^(?:case|default)\b/.test(textAfter)) {
|
158
|
+
state.context.type = "}";
|
159
|
+
return ctx.indented;
|
160
|
+
}
|
162
161
|
var closing = firstChar == ctx.type;
|
163
|
-
if (ctx.
|
164
|
-
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
162
|
+
if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
165
163
|
else return ctx.indented + (closing ? 0 : indentUnit);
|
166
164
|
},
|
167
165
|
|
168
|
-
electricChars: "{}"
|
166
|
+
electricChars: "{}:"
|
169
167
|
};
|
170
168
|
});
|
171
169
|
|
@@ -36,6 +36,7 @@ CodeMirror.defineMode("less", function(config) {
|
|
36
36
|
return tokenSComment(stream, state);
|
37
37
|
}else{
|
38
38
|
stream.eatWhile(/[\a-zA-Z0-9\-_.]/);
|
39
|
+
if(stream.peek() == ")" || stream.peek() == "/")return ret("string", "string");//let url(/images/logo.png) without quotes return as string
|
39
40
|
return ret("number", "unit");
|
40
41
|
}
|
41
42
|
}
|
@@ -53,7 +54,7 @@ CodeMirror.defineMode("less", function(config) {
|
|
53
54
|
else if (/[;{}:\[\]()]/.test(ch)) { //added () char for lesscss original was [;{}:\[\]]
|
54
55
|
if(ch == ":"){
|
55
56
|
stream.eatWhile(/[active|hover|link|visited]/);
|
56
|
-
if( stream.current().match(/
|
57
|
+
if( stream.current().match(/active|hover|link|visited/)){
|
57
58
|
return ret("tag", "tag");
|
58
59
|
}else{
|
59
60
|
return ret(null, ch);
|
@@ -85,13 +86,15 @@ CodeMirror.defineMode("less", function(config) {
|
|
85
86
|
return ret(null, ch);
|
86
87
|
}
|
87
88
|
else {
|
88
|
-
stream.eatWhile(/[\w\\\-_.%
|
89
|
+
stream.eatWhile(/[\w\\\-_.%]/);
|
89
90
|
if( stream.eat("(") ){ // lesscss
|
90
91
|
return ret(null, ch);
|
91
92
|
}else if( stream.current().match(/\-\d|\-.\d/) ){ // lesscss match e.g.: -5px -0.4 etc...
|
92
93
|
return ret("number", "unit");
|
93
94
|
}else if( inTagsArray(stream.current()) ){ // lesscss match html tags
|
94
95
|
return ret("tag", "tag");
|
96
|
+
}else if( (stream.peek() == ")" || stream.peek() == "/") && stream.current().indexOf('.') !== -1){
|
97
|
+
return ret("string", "string");//let url(logo.png) without quotes and froward slash return as string
|
95
98
|
}else{
|
96
99
|
return ret("variable", "variable");
|
97
100
|
}
|
@@ -15,7 +15,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
15
15
|
|
16
16
|
var hrRE = /^[*-=_]/
|
17
17
|
, ulRE = /^[*-+]\s+/
|
18
|
-
, olRE = /^[0-9]
|
18
|
+
, olRE = /^[0-9]+\.\s+/
|
19
19
|
, headerRE = /^(?:\={3,}|-{3,})$/
|
20
20
|
, codeRE = /^(k:\t|\s{4,})/
|
21
21
|
, textRE = /^[^\[*_\\<>`]+/;
|
@@ -34,35 +34,25 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
34
34
|
// Blocks
|
35
35
|
|
36
36
|
function blockNormal(stream, state) {
|
37
|
+
var match;
|
37
38
|
if (stream.match(codeRE)) {
|
38
39
|
stream.skipToEnd();
|
39
40
|
return code;
|
40
|
-
}
|
41
|
-
|
42
|
-
if (stream.eatSpace()) {
|
41
|
+
} else if (stream.eatSpace()) {
|
43
42
|
return null;
|
44
|
-
}
|
45
|
-
|
46
|
-
if (stream.
|
47
|
-
stream.skipToEnd();
|
48
|
-
return header;
|
49
|
-
}
|
50
|
-
if (stream.eat('>')) {
|
43
|
+
} else if (stream.peek() === '#' || stream.match(headerRE)) {
|
44
|
+
state.header = true;
|
45
|
+
} else if (stream.eat('>')) {
|
51
46
|
state.indentation++;
|
52
|
-
|
53
|
-
}
|
54
|
-
if (stream.peek() === '[') {
|
47
|
+
state.quote = true;
|
48
|
+
} else if (stream.peek() === '[') {
|
55
49
|
return switchInline(stream, state, footnoteLink);
|
56
|
-
}
|
57
|
-
if (hrRE.test(stream.peek())) {
|
50
|
+
} else if (hrRE.test(stream.peek())) {
|
58
51
|
var re = new RegExp('(?:\s*['+stream.peek()+']){3,}$');
|
59
52
|
if (stream.match(re, true)) {
|
60
53
|
return hr;
|
61
54
|
}
|
62
|
-
}
|
63
|
-
|
64
|
-
var match;
|
65
|
-
if (match = stream.match(ulRE, true) || stream.match(olRE, true)) {
|
55
|
+
} else if (match = stream.match(ulRE, true) || stream.match(olRE, true)) {
|
66
56
|
state.indentation += match[0].length;
|
67
57
|
return list;
|
68
58
|
}
|
@@ -82,8 +72,39 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
82
72
|
|
83
73
|
// Inline
|
84
74
|
function getType(state) {
|
85
|
-
|
86
|
-
|
75
|
+
|
76
|
+
// Set defaults
|
77
|
+
returnValue = '';
|
78
|
+
|
79
|
+
// Strong / Emphasis
|
80
|
+
if(state.strong){
|
81
|
+
if(state.em){
|
82
|
+
returnValue += (returnValue ? ' ' : '') + emstrong;
|
83
|
+
} else {
|
84
|
+
returnValue += (returnValue ? ' ' : '') + strong;
|
85
|
+
}
|
86
|
+
} else {
|
87
|
+
if(state.em){
|
88
|
+
returnValue += (returnValue ? ' ' : '') + em;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
// Header
|
93
|
+
if(state.header){
|
94
|
+
returnValue += (returnValue ? ' ' : '') + header;
|
95
|
+
}
|
96
|
+
|
97
|
+
// Quotes
|
98
|
+
if(state.quote){
|
99
|
+
returnValue += (returnValue ? ' ' : '') + quote;
|
100
|
+
}
|
101
|
+
|
102
|
+
// Check valud and return
|
103
|
+
if(!returnValue){
|
104
|
+
returnValue = null;
|
105
|
+
}
|
106
|
+
return returnValue;
|
107
|
+
|
87
108
|
}
|
88
109
|
|
89
110
|
function handleText(stream, state) {
|
@@ -192,7 +213,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
192
213
|
inline: inlineNormal,
|
193
214
|
text: handleText,
|
194
215
|
em: false,
|
195
|
-
strong: false
|
216
|
+
strong: false,
|
217
|
+
header: false,
|
218
|
+
quote: false
|
196
219
|
};
|
197
220
|
},
|
198
221
|
|
@@ -207,12 +230,23 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
207
230
|
inline: s.inline,
|
208
231
|
text: s.text,
|
209
232
|
em: s.em,
|
210
|
-
strong: s.strong
|
233
|
+
strong: s.strong,
|
234
|
+
header: s.header,
|
235
|
+
quote: s.quote
|
211
236
|
};
|
212
237
|
},
|
213
238
|
|
214
239
|
token: function(stream, state) {
|
215
240
|
if (stream.sol()) {
|
241
|
+
// Reset EM state
|
242
|
+
state.em = false;
|
243
|
+
// Reset STRONG state
|
244
|
+
state.strong = false;
|
245
|
+
// Reset state.header
|
246
|
+
state.header = false;
|
247
|
+
// Reset state.quote
|
248
|
+
state.quote = false;
|
249
|
+
|
216
250
|
state.f = state.block;
|
217
251
|
var previousIndentation = state.indentation
|
218
252
|
, currentIndentation = 0;
|