codemirror-rails 5.3 → 5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror.js +26 -36
- data/vendor/assets/javascripts/codemirror/addons/edit/continuelist.js +4 -4
- data/vendor/assets/javascripts/codemirror/addons/hint/sql-hint.js +3 -3
- data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +69 -11
- data/vendor/assets/javascripts/codemirror/addons/tern/tern.js +4 -2
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +24 -3
- data/vendor/assets/javascripts/codemirror/modes/clike.js +60 -25
- data/vendor/assets/javascripts/codemirror/modes/elm.js +205 -0
- data/vendor/assets/javascripts/codemirror/modes/factor.js +83 -0
- data/vendor/assets/javascripts/codemirror/modes/groovy.js +8 -5
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +5 -2
- data/vendor/assets/javascripts/codemirror/modes/kotlin.js +5 -2
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +37 -23
- data/vendor/assets/javascripts/codemirror/modes/php.js +20 -17
- data/vendor/assets/javascripts/codemirror/modes/python.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/swift.js +203 -0
- data/vendor/assets/javascripts/codemirror/modes/twig.js +132 -0
- data/vendor/assets/javascripts/codemirror/modes/vb.js +2 -1
- data/vendor/assets/stylesheets/codemirror.css +9 -9
- data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +3 -2
- data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +2 -2
- data/vendor/assets/stylesheets/codemirror/themes/monokai.css +1 -0
- data/vendor/assets/stylesheets/codemirror/themes/solarized.css +2 -2
- data/vendor/assets/stylesheets/codemirror/themes/ttcn.css +9 -10
- metadata +6 -2
@@ -0,0 +1,205 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
(function(mod) {
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6
|
+
mod(require("../../lib/codemirror"));
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
8
|
+
define(["../../lib/codemirror"], mod);
|
9
|
+
else // Plain browser env
|
10
|
+
mod(CodeMirror);
|
11
|
+
})(function(CodeMirror) {
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
CodeMirror.defineMode("elm", function() {
|
15
|
+
|
16
|
+
function switchState(source, setState, f) {
|
17
|
+
setState(f);
|
18
|
+
return f(source, setState);
|
19
|
+
}
|
20
|
+
|
21
|
+
// These should all be Unicode extended, as per the Haskell 2010 report
|
22
|
+
var smallRE = /[a-z_]/;
|
23
|
+
var largeRE = /[A-Z]/;
|
24
|
+
var digitRE = /[0-9]/;
|
25
|
+
var hexitRE = /[0-9A-Fa-f]/;
|
26
|
+
var octitRE = /[0-7]/;
|
27
|
+
var idRE = /[a-z_A-Z0-9\']/;
|
28
|
+
var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:\u03BB\u2192]/;
|
29
|
+
var specialRE = /[(),;[\]`{}]/;
|
30
|
+
var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer
|
31
|
+
|
32
|
+
function normal() {
|
33
|
+
return function (source, setState) {
|
34
|
+
if (source.eatWhile(whiteCharRE)) {
|
35
|
+
return null;
|
36
|
+
}
|
37
|
+
|
38
|
+
var ch = source.next();
|
39
|
+
if (specialRE.test(ch)) {
|
40
|
+
if (ch == '{' && source.eat('-')) {
|
41
|
+
var t = "comment";
|
42
|
+
if (source.eat('#')) t = "meta";
|
43
|
+
return switchState(source, setState, ncomment(t, 1));
|
44
|
+
}
|
45
|
+
return null;
|
46
|
+
}
|
47
|
+
|
48
|
+
if (ch == '\'') {
|
49
|
+
if (source.eat('\\'))
|
50
|
+
source.next(); // should handle other escapes here
|
51
|
+
else
|
52
|
+
source.next();
|
53
|
+
|
54
|
+
if (source.eat('\''))
|
55
|
+
return "string";
|
56
|
+
return "error";
|
57
|
+
}
|
58
|
+
|
59
|
+
if (ch == '"') {
|
60
|
+
return switchState(source, setState, stringLiteral);
|
61
|
+
}
|
62
|
+
|
63
|
+
if (largeRE.test(ch)) {
|
64
|
+
source.eatWhile(idRE);
|
65
|
+
if (source.eat('.'))
|
66
|
+
return "qualifier";
|
67
|
+
return "variable-2";
|
68
|
+
}
|
69
|
+
|
70
|
+
if (smallRE.test(ch)) {
|
71
|
+
var isDef = source.pos === 1;
|
72
|
+
source.eatWhile(idRE);
|
73
|
+
return isDef ? "variable-3" : "variable";
|
74
|
+
}
|
75
|
+
|
76
|
+
if (digitRE.test(ch)) {
|
77
|
+
if (ch == '0') {
|
78
|
+
if (source.eat(/[xX]/)) {
|
79
|
+
source.eatWhile(hexitRE); // should require at least 1
|
80
|
+
return "integer";
|
81
|
+
}
|
82
|
+
if (source.eat(/[oO]/)) {
|
83
|
+
source.eatWhile(octitRE); // should require at least 1
|
84
|
+
return "number";
|
85
|
+
}
|
86
|
+
}
|
87
|
+
source.eatWhile(digitRE);
|
88
|
+
var t = "number";
|
89
|
+
if (source.eat('.')) {
|
90
|
+
t = "number";
|
91
|
+
source.eatWhile(digitRE); // should require at least 1
|
92
|
+
}
|
93
|
+
if (source.eat(/[eE]/)) {
|
94
|
+
t = "number";
|
95
|
+
source.eat(/[-+]/);
|
96
|
+
source.eatWhile(digitRE); // should require at least 1
|
97
|
+
}
|
98
|
+
return t;
|
99
|
+
}
|
100
|
+
|
101
|
+
if (symbolRE.test(ch)) {
|
102
|
+
if (ch == '-' && source.eat(/-/)) {
|
103
|
+
source.eatWhile(/-/);
|
104
|
+
if (!source.eat(symbolRE)) {
|
105
|
+
source.skipToEnd();
|
106
|
+
return "comment";
|
107
|
+
}
|
108
|
+
}
|
109
|
+
source.eatWhile(symbolRE);
|
110
|
+
return "builtin";
|
111
|
+
}
|
112
|
+
|
113
|
+
return "error";
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
function ncomment(type, nest) {
|
118
|
+
if (nest == 0) {
|
119
|
+
return normal();
|
120
|
+
}
|
121
|
+
return function(source, setState) {
|
122
|
+
var currNest = nest;
|
123
|
+
while (!source.eol()) {
|
124
|
+
var ch = source.next();
|
125
|
+
if (ch == '{' && source.eat('-')) {
|
126
|
+
++currNest;
|
127
|
+
} else if (ch == '-' && source.eat('}')) {
|
128
|
+
--currNest;
|
129
|
+
if (currNest == 0) {
|
130
|
+
setState(normal());
|
131
|
+
return type;
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
setState(ncomment(type, currNest));
|
136
|
+
return type;
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
function stringLiteral(source, setState) {
|
141
|
+
while (!source.eol()) {
|
142
|
+
var ch = source.next();
|
143
|
+
if (ch == '"') {
|
144
|
+
setState(normal());
|
145
|
+
return "string";
|
146
|
+
}
|
147
|
+
if (ch == '\\') {
|
148
|
+
if (source.eol() || source.eat(whiteCharRE)) {
|
149
|
+
setState(stringGap);
|
150
|
+
return "string";
|
151
|
+
}
|
152
|
+
if (!source.eat('&')) source.next(); // should handle other escapes here
|
153
|
+
}
|
154
|
+
}
|
155
|
+
setState(normal());
|
156
|
+
return "error";
|
157
|
+
}
|
158
|
+
|
159
|
+
function stringGap(source, setState) {
|
160
|
+
if (source.eat('\\')) {
|
161
|
+
return switchState(source, setState, stringLiteral);
|
162
|
+
}
|
163
|
+
source.next();
|
164
|
+
setState(normal());
|
165
|
+
return "error";
|
166
|
+
}
|
167
|
+
|
168
|
+
|
169
|
+
var wellKnownWords = (function() {
|
170
|
+
var wkw = {};
|
171
|
+
|
172
|
+
var keywords = [
|
173
|
+
"case", "of", "as",
|
174
|
+
"if", "then", "else",
|
175
|
+
"let", "in",
|
176
|
+
"infix", "infixl", "infixr",
|
177
|
+
"type", "alias",
|
178
|
+
"input", "output", "foreign", "loopback",
|
179
|
+
"module", "where", "import", "exposing",
|
180
|
+
"_", "..", "|", ":", "=", "\\", "\"", "->", "<-"
|
181
|
+
];
|
182
|
+
|
183
|
+
for (var i = keywords.length; i--;)
|
184
|
+
wkw[keywords[i]] = "keyword";
|
185
|
+
|
186
|
+
return wkw;
|
187
|
+
})();
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
return {
|
192
|
+
startState: function () { return { f: normal() }; },
|
193
|
+
copyState: function (s) { return { f: s.f }; },
|
194
|
+
|
195
|
+
token: function(stream, state) {
|
196
|
+
var t = state.f(stream, function(s) { state.f = s; });
|
197
|
+
var w = stream.current();
|
198
|
+
return (wellKnownWords.hasOwnProperty(w)) ? wellKnownWords[w] : t;
|
199
|
+
}
|
200
|
+
};
|
201
|
+
|
202
|
+
});
|
203
|
+
|
204
|
+
CodeMirror.defineMIME("text/x-elm", "elm");
|
205
|
+
})();
|
@@ -0,0 +1,83 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
// Factor syntax highlight - simple mode
|
5
|
+
//
|
6
|
+
// by Dimage Sapelkin (https://github.com/kerabromsmu)
|
7
|
+
|
8
|
+
(function(mod) {
|
9
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
10
|
+
mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
|
11
|
+
else if (typeof define == "function" && define.amd) // AMD
|
12
|
+
define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
|
13
|
+
else // Plain browser env
|
14
|
+
mod(CodeMirror);
|
15
|
+
})(function(CodeMirror) {
|
16
|
+
"use strict";
|
17
|
+
|
18
|
+
CodeMirror.defineSimpleMode("factor", {
|
19
|
+
// The start state contains the rules that are intially used
|
20
|
+
start: [
|
21
|
+
// comments
|
22
|
+
{regex: /#?!.*/, token: "comment"},
|
23
|
+
// strings """, multiline --> state
|
24
|
+
{regex: /"""/, token: "string", next: "string3"},
|
25
|
+
{regex: /"/, token: "string", next: "string"},
|
26
|
+
// numbers: dec, hex, unicode, bin, fractional, complex
|
27
|
+
{regex: /(?:[+-]?)(?:0x[\d,a-f]+)|(?:0o[0-7]+)|(?:0b[0,1]+)|(?:\d+.?\d*)/, token: "number"},
|
28
|
+
//{regex: /[+-]?/} //fractional
|
29
|
+
// definition: defining word, defined word, etc
|
30
|
+
{regex: /(\:)(\s+)(\S+)(\s+)(\()/, token: ["keyword", null, "def", null, "keyword"], next: "stack"},
|
31
|
+
// vocabulary using --> state
|
32
|
+
{regex: /USING\:/, token: "keyword", next: "vocabulary"},
|
33
|
+
// vocabulary definition/use
|
34
|
+
{regex: /(USE\:|IN\:)(\s+)(\S+)/, token: ["keyword", null, "variable-2"]},
|
35
|
+
// <constructors>
|
36
|
+
{regex: /<\S+>/, token: "builtin"},
|
37
|
+
// "keywords", incl. ; t f . [ ] { } defining words
|
38
|
+
{regex: /;|t|f|if|\.|\[|\]|\{|\}|MAIN:/, token: "keyword"},
|
39
|
+
// any id (?)
|
40
|
+
{regex: /\S+/, token: "variable"},
|
41
|
+
|
42
|
+
{
|
43
|
+
regex: /./,
|
44
|
+
token: null
|
45
|
+
}
|
46
|
+
],
|
47
|
+
vocabulary: [
|
48
|
+
{regex: /;/, token: "keyword", next: "start"},
|
49
|
+
{regex: /\S+/, token: "variable-2"},
|
50
|
+
{
|
51
|
+
regex: /./,
|
52
|
+
token: null
|
53
|
+
}
|
54
|
+
],
|
55
|
+
string: [
|
56
|
+
{regex: /(?:[^\\]|\\.)*?"/, token: "string", next: "start"},
|
57
|
+
{regex: /.*/, token: "string"}
|
58
|
+
],
|
59
|
+
string3: [
|
60
|
+
{regex: /(?:[^\\]|\\.)*?"""/, token: "string", next: "start"},
|
61
|
+
{regex: /.*/, token: "string"}
|
62
|
+
],
|
63
|
+
stack: [
|
64
|
+
{regex: /\)/, token: "meta", next: "start"},
|
65
|
+
{regex: /--/, token: "meta"},
|
66
|
+
{regex: /\S+/, token: "variable-3"},
|
67
|
+
{
|
68
|
+
regex: /./,
|
69
|
+
token: null
|
70
|
+
}
|
71
|
+
],
|
72
|
+
// The meta property contains global information about the mode. It
|
73
|
+
// can contain properties like lineComment, which are supported by
|
74
|
+
// all modes, and also directives like dontIndentStates, which are
|
75
|
+
// specific to simple modes.
|
76
|
+
meta: {
|
77
|
+
dontIndentStates: ["start", "vocabulary", "string", "string3", "stack"],
|
78
|
+
lineComment: [ "!", "#!" ]
|
79
|
+
}
|
80
|
+
});
|
81
|
+
|
82
|
+
CodeMirror.defineMIME("text/x-factor", "factor");
|
83
|
+
});
|
@@ -24,6 +24,7 @@ CodeMirror.defineMode("groovy", function(config) {
|
|
24
24
|
"short static strictfp super switch synchronized threadsafe throw throws transient " +
|
25
25
|
"try void volatile while");
|
26
26
|
var blockKeywords = words("catch class do else finally for if switch try while enum interface def");
|
27
|
+
var standaloneKeywords = words("return break continue");
|
27
28
|
var atoms = words("null true false this");
|
28
29
|
|
29
30
|
var curPunc;
|
@@ -50,7 +51,7 @@ CodeMirror.defineMode("groovy", function(config) {
|
|
50
51
|
stream.skipToEnd();
|
51
52
|
return "comment";
|
52
53
|
}
|
53
|
-
if (expectExpression(state.lastToken)) {
|
54
|
+
if (expectExpression(state.lastToken, false)) {
|
54
55
|
return startString(ch, stream, state);
|
55
56
|
}
|
56
57
|
}
|
@@ -70,6 +71,7 @@ CodeMirror.defineMode("groovy", function(config) {
|
|
70
71
|
if (atoms.propertyIsEnumerable(cur)) { return "atom"; }
|
71
72
|
if (keywords.propertyIsEnumerable(cur)) {
|
72
73
|
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
74
|
+
else if (standaloneKeywords.propertyIsEnumerable(cur)) curPunc = "standalone";
|
73
75
|
return "keyword";
|
74
76
|
}
|
75
77
|
return "variable";
|
@@ -132,9 +134,10 @@ CodeMirror.defineMode("groovy", function(config) {
|
|
132
134
|
return "comment";
|
133
135
|
}
|
134
136
|
|
135
|
-
function expectExpression(last) {
|
137
|
+
function expectExpression(last, newline) {
|
136
138
|
return !last || last == "operator" || last == "->" || /[\.\[\{\(,;:]/.test(last) ||
|
137
|
-
last == "newstatement" || last == "keyword" || last == "proplabel"
|
139
|
+
last == "newstatement" || last == "keyword" || last == "proplabel" ||
|
140
|
+
(last == "standalone" && !newline);
|
138
141
|
}
|
139
142
|
|
140
143
|
function Context(indented, column, type, align, prev) {
|
@@ -174,7 +177,7 @@ CodeMirror.defineMode("groovy", function(config) {
|
|
174
177
|
state.indented = stream.indentation();
|
175
178
|
state.startOfLine = true;
|
176
179
|
// Automatic semicolon insertion
|
177
|
-
if (ctx.type == "statement" && !expectExpression(state.lastToken)) {
|
180
|
+
if (ctx.type == "statement" && !expectExpression(state.lastToken, true)) {
|
178
181
|
popContext(state); ctx = state.context;
|
179
182
|
}
|
180
183
|
}
|
@@ -209,7 +212,7 @@ CodeMirror.defineMode("groovy", function(config) {
|
|
209
212
|
indent: function(state, textAfter) {
|
210
213
|
if (!state.tokenize[state.tokenize.length-1].isBase) return 0;
|
211
214
|
var firstChar = textAfter && textAfter.charAt(0), ctx = state.context;
|
212
|
-
if (ctx.type == "statement" && !expectExpression(state.lastToken)) ctx = ctx.prev;
|
215
|
+
if (ctx.type == "statement" && !expectExpression(state.lastToken, true)) ctx = ctx.prev;
|
213
216
|
var closing = firstChar == ctx.type;
|
214
217
|
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : config.indentUnit);
|
215
218
|
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
@@ -482,8 +482,11 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|
482
482
|
function maybetype(type) {
|
483
483
|
if (isTS && type == ":") return cont(typedef);
|
484
484
|
}
|
485
|
+
function maybedefault(_, value) {
|
486
|
+
if (value == "=") return cont(expressionNoComma);
|
487
|
+
}
|
485
488
|
function typedef(type) {
|
486
|
-
if (type == "variable"){cx.marked = "variable-3"; return cont();}
|
489
|
+
if (type == "variable") {cx.marked = "variable-3"; return cont();}
|
487
490
|
}
|
488
491
|
function vardef() {
|
489
492
|
return pass(pattern, maybetype, maybeAssign, vardefCont);
|
@@ -538,7 +541,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|
538
541
|
}
|
539
542
|
function funarg(type) {
|
540
543
|
if (type == "spread") return cont(funarg);
|
541
|
-
return pass(pattern, maybetype);
|
544
|
+
return pass(pattern, maybetype, maybedefault);
|
542
545
|
}
|
543
546
|
function className(type, value) {
|
544
547
|
if (type == "variable") {register(value); return cont(classNameAfter);}
|
@@ -21,7 +21,7 @@ CodeMirror.defineMode("kotlin", function (config, parserConfig) {
|
|
21
21
|
var multiLineStrings = parserConfig.multiLineStrings;
|
22
22
|
|
23
23
|
var keywords = words(
|
24
|
-
"package continue return object while break class data trait throw super" +
|
24
|
+
"package continue return object while break class data trait interface throw super" +
|
25
25
|
" when type this else This try val var fun for is in if do as true false null get set");
|
26
26
|
var softKeywords = words("import" +
|
27
27
|
" where by get set abstract enum open annotation override private public internal" +
|
@@ -272,7 +272,10 @@ CodeMirror.defineMode("kotlin", function (config, parserConfig) {
|
|
272
272
|
},
|
273
273
|
|
274
274
|
closeBrackets: {triples: "'\""},
|
275
|
-
electricChars: "{}"
|
275
|
+
electricChars: "{}",
|
276
|
+
blockCommentStart: "/*",
|
277
|
+
blockCommentEnd: "*/",
|
278
|
+
lineComment: "//"
|
276
279
|
};
|
277
280
|
});
|
278
281
|
|
@@ -68,12 +68,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
68
68
|
, strong = 'strong'
|
69
69
|
, strikethrough = 'strikethrough';
|
70
70
|
|
71
|
-
var hrRE = /^([
|
71
|
+
var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/
|
72
72
|
, ulRE = /^[*\-+]\s+/
|
73
|
-
, olRE = /^[0-9]
|
73
|
+
, olRE = /^[0-9]+([.)])\s+/
|
74
74
|
, taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
|
75
|
-
, atxHeaderRE =
|
76
|
-
, setextHeaderRE = /^(?:\={1,}|-{1,})
|
75
|
+
, atxHeaderRE = /^(#+)(?: |$)/
|
76
|
+
, setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/
|
77
77
|
, textRE = /^[^#!\[\]*_\\<>` "'(~]+/;
|
78
78
|
|
79
79
|
function switchInline(stream, state, f) {
|
@@ -100,6 +100,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
100
100
|
state.strikethrough = false;
|
101
101
|
// Reset state.quote
|
102
102
|
state.quote = 0;
|
103
|
+
// Reset state.indentedCode
|
104
|
+
state.indentedCode = false;
|
103
105
|
if (!htmlFound && state.f == htmlBlock) {
|
104
106
|
state.f = inlineNormal;
|
105
107
|
state.block = blockNormal;
|
@@ -116,7 +118,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
116
118
|
|
117
119
|
var sol = stream.sol();
|
118
120
|
|
119
|
-
var prevLineIsList = state.list !== false
|
121
|
+
var prevLineIsList = state.list !== false,
|
122
|
+
prevLineIsIndentedCode = state.indentedCode;
|
123
|
+
|
124
|
+
state.indentedCode = false;
|
125
|
+
|
120
126
|
if (prevLineIsList) {
|
121
127
|
if (state.indentationDiff >= 0) { // Continued list
|
122
128
|
if (state.indentationDiff < 4) { // Only adjust indentation if *not* a code block
|
@@ -134,23 +140,27 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
134
140
|
|
135
141
|
var match = null;
|
136
142
|
if (state.indentationDiff >= 4) {
|
137
|
-
state.indentation -= 4;
|
138
143
|
stream.skipToEnd();
|
139
|
-
|
144
|
+
if (prevLineIsIndentedCode || !state.prevLineHasContent) {
|
145
|
+
state.indentation -= 4;
|
146
|
+
state.indentedCode = true;
|
147
|
+
return code;
|
148
|
+
} else {
|
149
|
+
return null;
|
150
|
+
}
|
140
151
|
} else if (stream.eatSpace()) {
|
141
152
|
return null;
|
142
|
-
} else if (match = stream.match(atxHeaderRE)) {
|
143
|
-
state.header =
|
153
|
+
} else if ((match = stream.match(atxHeaderRE)) && match[1].length <= 6) {
|
154
|
+
state.header = match[1].length;
|
144
155
|
if (modeCfg.highlightFormatting) state.formatting = "header";
|
145
156
|
state.f = state.inline;
|
146
157
|
return getType(state);
|
147
|
-
} else if (state.prevLineHasContent && (match = stream.match(setextHeaderRE))) {
|
158
|
+
} else if (state.prevLineHasContent && !state.quote && !prevLineIsList && !prevLineIsIndentedCode && (match = stream.match(setextHeaderRE))) {
|
148
159
|
state.header = match[0].charAt(0) == '=' ? 1 : 2;
|
149
160
|
if (modeCfg.highlightFormatting) state.formatting = "header";
|
150
161
|
state.f = state.inline;
|
151
162
|
return getType(state);
|
152
163
|
} else if (stream.eat('>')) {
|
153
|
-
state.indentation++;
|
154
164
|
state.quote = sol ? 1 : state.quote + 1;
|
155
165
|
if (modeCfg.highlightFormatting) state.formatting = "quote";
|
156
166
|
stream.eatSpace();
|
@@ -158,6 +168,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
158
168
|
} else if (stream.peek() === '[') {
|
159
169
|
return switchInline(stream, state, footnoteLink);
|
160
170
|
} else if (stream.match(hrRE, true)) {
|
171
|
+
state.hr = true;
|
161
172
|
return hr;
|
162
173
|
} else if ((!state.prevLineHasContent || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) {
|
163
174
|
var listType = null;
|
@@ -262,17 +273,16 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
262
273
|
}
|
263
274
|
|
264
275
|
if (state.linkHref) {
|
265
|
-
styles.push(linkhref);
|
266
|
-
|
267
|
-
|
276
|
+
styles.push(linkhref, "url");
|
277
|
+
} else { // Only apply inline styles to non-url text
|
278
|
+
if (state.strong) { styles.push(strong); }
|
279
|
+
if (state.em) { styles.push(em); }
|
280
|
+
if (state.strikethrough) { styles.push(strikethrough); }
|
268
281
|
|
269
|
-
|
270
|
-
if (state.em) { styles.push(em); }
|
271
|
-
if (state.strikethrough) { styles.push(strikethrough); }
|
282
|
+
if (state.linkText) { styles.push(linktext); }
|
272
283
|
|
273
|
-
|
274
|
-
|
275
|
-
if (state.code) { styles.push(code); }
|
284
|
+
if (state.code) { styles.push(code); }
|
285
|
+
}
|
276
286
|
|
277
287
|
if (state.header) { styles.push(header); styles.push(header + "-" + state.header); }
|
278
288
|
|
@@ -626,7 +636,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
626
636
|
stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true);
|
627
637
|
}
|
628
638
|
state.f = state.inline = inlineNormal;
|
629
|
-
return linkhref;
|
639
|
+
return linkhref + " url";
|
630
640
|
}
|
631
641
|
|
632
642
|
var savedInlineRE = [];
|
@@ -663,6 +673,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
663
673
|
em: false,
|
664
674
|
strong: false,
|
665
675
|
header: 0,
|
676
|
+
hr: false,
|
666
677
|
taskList: false,
|
667
678
|
list: false,
|
668
679
|
listDepth: 0,
|
@@ -695,10 +706,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
695
706
|
strong: s.strong,
|
696
707
|
strikethrough: s.strikethrough,
|
697
708
|
header: s.header,
|
709
|
+
hr: s.hr,
|
698
710
|
taskList: s.taskList,
|
699
711
|
list: s.list,
|
700
712
|
listDepth: s.listDepth,
|
701
713
|
quote: s.quote,
|
714
|
+
indentedCode: s.indentedCode,
|
702
715
|
trailingSpace: s.trailingSpace,
|
703
716
|
trailingSpaceNewLine: s.trailingSpaceNewLine,
|
704
717
|
md_inside: s.md_inside
|
@@ -711,10 +724,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
711
724
|
state.formatting = false;
|
712
725
|
|
713
726
|
if (stream.sol()) {
|
714
|
-
var forceBlankLine = !!state.header;
|
727
|
+
var forceBlankLine = !!state.header || state.hr;
|
715
728
|
|
716
|
-
// Reset state.header
|
729
|
+
// Reset state.header and state.hr
|
717
730
|
state.header = 0;
|
731
|
+
state.hr = false;
|
718
732
|
|
719
733
|
if (stream.match(/^\s*$/, true) || forceBlankLine) {
|
720
734
|
state.prevLineHasContent = false;
|