codemirror-rails 2.3 → 2.21
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +0 -16
- data/codemirror-rails.gemspec +1 -1
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror.js +323 -687
- data/vendor/assets/javascripts/codemirror/modes/clike.js +3 -40
- data/vendor/assets/javascripts/codemirror/modes/clojure.js +14 -14
- data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +0 -6
- data/vendor/assets/javascripts/codemirror/modes/css.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/diff.js +5 -24
- data/vendor/assets/javascripts/codemirror/modes/gfm.js +4 -40
- data/vendor/assets/javascripts/codemirror/modes/go.js +22 -20
- data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +2 -4
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +7 -8
- data/vendor/assets/javascripts/codemirror/modes/less.js +54 -100
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +49 -52
- data/vendor/assets/javascripts/codemirror/modes/pascal.js +46 -2
- data/vendor/assets/javascripts/codemirror/modes/perl.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/php.js +25 -54
- data/vendor/assets/javascripts/codemirror/modes/python.js +16 -14
- data/vendor/assets/javascripts/codemirror/modes/rpm-spec.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/rst.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/ruby.js +9 -4
- data/vendor/assets/javascripts/codemirror/modes/scheme.js +46 -74
- data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +16 -16
- data/vendor/assets/javascripts/codemirror/modes/stex.js +6 -21
- data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +45 -55
- data/vendor/assets/javascripts/codemirror/modes/xml.js +14 -79
- data/vendor/assets/javascripts/codemirror/{utils/overlay.js → overlay.js} +2 -3
- data/vendor/assets/javascripts/codemirror/runmode.js +27 -0
- data/vendor/assets/stylesheets/codemirror.css +2 -63
- data/vendor/assets/stylesheets/codemirror/modes/tiddlywiki.css +21 -14
- data/vendor/assets/stylesheets/codemirror/themes/eclipse.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/elegant.css +2 -2
- data/vendor/assets/stylesheets/codemirror/themes/neat.css +3 -3
- data/vendor/assets/stylesheets/codemirror/themes/night.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/rubyblue.css +2 -2
- metadata +6 -39
- data/vendor/assets/javascripts/codemirror/keymaps/emacs.js +0 -29
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +0 -766
- data/vendor/assets/javascripts/codemirror/modes/ecl.js +0 -203
- data/vendor/assets/javascripts/codemirror/modes/erlang.js +0 -251
- data/vendor/assets/javascripts/codemirror/modes/pig.js +0 -172
- data/vendor/assets/javascripts/codemirror/modes/properties.js +0 -63
- data/vendor/assets/javascripts/codemirror/modes/shell.js +0 -103
- data/vendor/assets/javascripts/codemirror/modes/smarty.js +0 -148
- data/vendor/assets/javascripts/codemirror/modes/tiki.js +0 -316
- data/vendor/assets/javascripts/codemirror/modes/vbscript.js +0 -26
- data/vendor/assets/javascripts/codemirror/modes/xquery.js +0 -448
- data/vendor/assets/javascripts/codemirror/utils/closetag.js +0 -146
- data/vendor/assets/javascripts/codemirror/utils/dialog.js +0 -63
- data/vendor/assets/javascripts/codemirror/utils/foldcode.js +0 -196
- data/vendor/assets/javascripts/codemirror/utils/formatting.js +0 -297
- data/vendor/assets/javascripts/codemirror/utils/javascript-hint.js +0 -134
- data/vendor/assets/javascripts/codemirror/utils/loadmode.js +0 -51
- data/vendor/assets/javascripts/codemirror/utils/match-highlighter.js +0 -44
- data/vendor/assets/javascripts/codemirror/utils/multiplex.js +0 -72
- data/vendor/assets/javascripts/codemirror/utils/pig-hint.js +0 -123
- data/vendor/assets/javascripts/codemirror/utils/runmode.js +0 -49
- data/vendor/assets/javascripts/codemirror/utils/search.js +0 -118
- data/vendor/assets/javascripts/codemirror/utils/searchcursor.js +0 -117
- data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +0 -72
- data/vendor/assets/stylesheets/codemirror/modes/tiki.css +0 -26
- data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +0 -81
- data/vendor/assets/stylesheets/codemirror/themes/blackboard.css +0 -25
- data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +0 -21
- data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +0 -44
- data/vendor/assets/stylesheets/codemirror/themes/vibrant-ink.css +0 -27
- data/vendor/assets/stylesheets/codemirror/themes/xq-dark.css +0 -46
- data/vendor/assets/stylesheets/codemirror/utils/dialog.css +0 -23
- data/vendor/assets/stylesheets/codemirror/utils/simple-hint.css +0 -16
@@ -30,10 +30,10 @@ CodeMirror.defineMode("ruby", function(config, parserConfig) {
|
|
30
30
|
return "comment";
|
31
31
|
}
|
32
32
|
if (stream.eatSpace()) return null;
|
33
|
-
var ch = stream.next()
|
33
|
+
var ch = stream.next();
|
34
34
|
if (ch == "`" || ch == "'" || ch == '"' ||
|
35
35
|
(ch == "/" && !stream.eol() && stream.peek() != " ")) {
|
36
|
-
return chain(readQuoted(ch, "string", ch == '"'
|
36
|
+
return chain(readQuoted(ch, "string", ch == '"'), stream, state);
|
37
37
|
} else if (ch == "%") {
|
38
38
|
var style, embed = false;
|
39
39
|
if (stream.eat("s")) style = "atom";
|
@@ -46,8 +46,13 @@ CodeMirror.defineMode("ruby", function(config, parserConfig) {
|
|
46
46
|
} else if (ch == "#") {
|
47
47
|
stream.skipToEnd();
|
48
48
|
return "comment";
|
49
|
-
} else if (ch == "<" &&
|
50
|
-
|
49
|
+
} else if (ch == "<" && stream.eat("<")) {
|
50
|
+
stream.eat("-");
|
51
|
+
stream.eat(/[\'\"\`]/);
|
52
|
+
var match = stream.match(/^\w+/);
|
53
|
+
stream.eat(/[\'\"\`]/);
|
54
|
+
if (match) return chain(readHereDoc(match[0]), stream, state);
|
55
|
+
return null;
|
51
56
|
} else if (ch == "0") {
|
52
57
|
if (stream.eat("x")) stream.eatWhile(/[\da-fA-F]/);
|
53
58
|
else if (stream.eat("b")) stream.eatWhile(/[01]/);
|
@@ -5,7 +5,7 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
5
5
|
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
|
6
6
|
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD="keyword";
|
7
7
|
var INDENT_WORD_SKIP = 2, KEYWORDS_SKIP = 1;
|
8
|
-
|
8
|
+
|
9
9
|
function makeKeywords(str) {
|
10
10
|
var obj = {}, words = str.split(" ");
|
11
11
|
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
@@ -14,6 +14,7 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
14
14
|
|
15
15
|
var keywords = makeKeywords("λ case-lambda call/cc class define-class exit-handler field import inherit init-field interface let*-values let-values let/ec mixin opt-lambda override protect provide public rename require require-for-syntax syntax syntax-case syntax-error unit/sig unless when with-syntax and begin call-with-current-continuation call-with-input-file call-with-output-file case cond define define-syntax delay do dynamic-wind else for-each if lambda let let* let-syntax letrec letrec-syntax map or syntax-rules abs acos angle append apply asin assoc assq assv atan boolean? caar cadr call-with-input-file call-with-output-file call-with-values car cdddar cddddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci<? char-ci=? char-ci>=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char<? char=? char>=? char>? char? close-input-port close-output-port complex? cons cos current-input-port current-output-port denominator display eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt #f floor force gcd imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lcm length list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file output-port? pair? peek-char port? positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci<? string-ci=? string-ci>=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string<? string=? string>=? string>? string? substring symbol->string symbol? #t tan transcript-off transcript-on truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! with-input-from-file with-output-to-file write write-char zero?");
|
16
16
|
var indentKeys = makeKeywords("define let letrec let* lambda");
|
17
|
+
|
17
18
|
|
18
19
|
function stateStack(indent, type, prev) { // represents a state stack object
|
19
20
|
this.indent = indent;
|
@@ -28,29 +29,21 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
28
29
|
function popStack(state) {
|
29
30
|
state.indentStack = state.indentStack.prev;
|
30
31
|
}
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
function
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
function isDecimalNumber (stream, backup) {
|
46
|
-
if (backup === true) {
|
47
|
-
stream.backUp(1);
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Scheme numbers are complicated unfortunately.
|
35
|
+
* Checks if we're looking at a number, which might be possibly a fraction.
|
36
|
+
* Also checks that it is not part of a longer identifier. Returns true/false accordingly.
|
37
|
+
*/
|
38
|
+
function isNumber(ch, stream){
|
39
|
+
if(/[0-9]/.exec(ch) != null){
|
40
|
+
stream.eatWhile(/[0-9]/);
|
41
|
+
stream.eat(/\//);
|
42
|
+
stream.eatWhile(/[0-9]/);
|
43
|
+
if (stream.eol() || !(/[a-zA-Z\-\_\/]/.exec(stream.peek()))) return true;
|
44
|
+
stream.backUp(stream.current().length - 1); // undo all the eating
|
48
45
|
}
|
49
|
-
return
|
50
|
-
}
|
51
|
-
|
52
|
-
function isHexNumber (stream) {
|
53
|
-
return stream.match(hexMatcher);
|
46
|
+
return false;
|
54
47
|
}
|
55
48
|
|
56
49
|
return {
|
@@ -74,13 +67,13 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
74
67
|
return null;
|
75
68
|
}
|
76
69
|
var returnType = null;
|
77
|
-
|
70
|
+
|
78
71
|
switch(state.mode){
|
79
72
|
case "string": // multi-line string parsing mode
|
80
73
|
var next, escaped = false;
|
81
74
|
while ((next = stream.next()) != null) {
|
82
75
|
if (next == "\"" && !escaped) {
|
83
|
-
|
76
|
+
|
84
77
|
state.mode = false;
|
85
78
|
break;
|
86
79
|
}
|
@@ -92,7 +85,7 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
92
85
|
var next, maybeEnd = false;
|
93
86
|
while ((next = stream.next()) != null) {
|
94
87
|
if (next == "#" && maybeEnd) {
|
95
|
-
|
88
|
+
|
96
89
|
state.mode = false;
|
97
90
|
break;
|
98
91
|
}
|
@@ -113,73 +106,52 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
113
106
|
}
|
114
107
|
default: // default parsing mode
|
115
108
|
var ch = stream.next();
|
116
|
-
|
109
|
+
|
117
110
|
if (ch == "\"") {
|
118
111
|
state.mode = "string";
|
119
112
|
returnType = STRING;
|
120
|
-
|
113
|
+
|
121
114
|
} else if (ch == "'") {
|
122
115
|
returnType = ATOM;
|
123
116
|
} else if (ch == '#') {
|
124
|
-
if (stream.eat("|")) {
|
117
|
+
if (stream.eat("|")) { // Multi-line comment
|
125
118
|
state.mode = "comment"; // toggle to comment mode
|
126
119
|
returnType = COMMENT;
|
127
|
-
} else if (stream.eat(/[tf]/
|
120
|
+
} else if (stream.eat(/[tf]/)) { // #t/#f (atom)
|
128
121
|
returnType = ATOM;
|
129
|
-
} else if (stream.eat(';')) {
|
122
|
+
} else if (stream.eat(';')) { // S-Expr comment
|
130
123
|
state.mode = "s-expr-comment";
|
131
124
|
returnType = COMMENT;
|
132
|
-
} else {
|
133
|
-
var numTest = null, hasExactness = false, hasRadix = true;
|
134
|
-
if (stream.eat(/[ei]/i)) {
|
135
|
-
hasExactness = true;
|
136
|
-
} else {
|
137
|
-
stream.backUp(1); // must be radix specifier
|
138
|
-
}
|
139
|
-
if (stream.match(/^#b/i)) {
|
140
|
-
numTest = isBinaryNumber;
|
141
|
-
} else if (stream.match(/^#o/i)) {
|
142
|
-
numTest = isOctalNumber;
|
143
|
-
} else if (stream.match(/^#x/i)) {
|
144
|
-
numTest = isHexNumber;
|
145
|
-
} else if (stream.match(/^#d/i)) {
|
146
|
-
numTest = isDecimalNumber;
|
147
|
-
} else if (stream.match(/^[-+0-9.]/, false)) {
|
148
|
-
hasRadix = false;
|
149
|
-
numTest = isDecimalNumber;
|
150
|
-
// re-consume the intial # if all matches failed
|
151
|
-
} else if (!hasExactness) {
|
152
|
-
stream.eat('#');
|
153
|
-
}
|
154
|
-
if (numTest != null) {
|
155
|
-
if (hasRadix && !hasExactness) {
|
156
|
-
// consume optional exactness after radix
|
157
|
-
stream.match(/^#[ei]/i);
|
158
|
-
}
|
159
|
-
if (numTest(stream))
|
160
|
-
returnType = NUMBER;
|
161
|
-
}
|
162
125
|
}
|
163
|
-
|
164
|
-
returnType = NUMBER;
|
126
|
+
|
165
127
|
} else if (ch == ";") { // comment
|
166
128
|
stream.skipToEnd(); // rest of the line is a comment
|
167
129
|
returnType = COMMENT;
|
130
|
+
} else if (ch == "-"){
|
131
|
+
|
132
|
+
if(!isNaN(parseInt(stream.peek()))){
|
133
|
+
stream.eatWhile(/[\/0-9]/);
|
134
|
+
returnType = NUMBER;
|
135
|
+
}else{
|
136
|
+
returnType = null;
|
137
|
+
}
|
138
|
+
} else if (isNumber(ch,stream)){
|
139
|
+
returnType = NUMBER;
|
168
140
|
} else if (ch == "(" || ch == "[") {
|
169
141
|
var keyWord = ''; var indentTemp = stream.column();
|
170
142
|
/**
|
171
|
-
Either
|
143
|
+
Either
|
172
144
|
(indent-word ..
|
173
145
|
(non-indent-word ..
|
174
146
|
(;something else, bracket, etc.
|
175
147
|
*/
|
176
|
-
|
148
|
+
|
177
149
|
while ((letter = stream.eat(/[^\s\(\[\;\)\]]/)) != null) {
|
178
150
|
keyWord += letter;
|
179
151
|
}
|
180
|
-
|
152
|
+
|
181
153
|
if (keyWord.length > 0 && indentKeys.propertyIsEnumerable(keyWord)) { // indent-word
|
182
|
-
|
154
|
+
|
183
155
|
pushStack(state, indentTemp + INDENT_WORD_SKIP, ch);
|
184
156
|
} else { // non-indent word
|
185
157
|
// we continue eating the spaces
|
@@ -193,15 +165,15 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
193
165
|
}
|
194
166
|
}
|
195
167
|
stream.backUp(stream.current().length - 1); // undo all the eating
|
196
|
-
|
168
|
+
|
197
169
|
if(typeof state.sExprComment == "number") state.sExprComment++;
|
198
|
-
|
170
|
+
|
199
171
|
returnType = BRACKET;
|
200
172
|
} else if (ch == ")" || ch == "]") {
|
201
173
|
returnType = BRACKET;
|
202
174
|
if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : "[")) {
|
203
175
|
popStack(state);
|
204
|
-
|
176
|
+
|
205
177
|
if(typeof state.sExprComment == "number"){
|
206
178
|
if(--state.sExprComment == 0){
|
207
179
|
returnType = COMMENT; // final closing bracket
|
@@ -210,11 +182,11 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
210
182
|
}
|
211
183
|
}
|
212
184
|
} else {
|
213
|
-
stream.eatWhile(/[\w\$_
|
214
|
-
|
185
|
+
stream.eatWhile(/[\w\$_\-]/);
|
186
|
+
|
215
187
|
if (keywords && keywords.propertyIsEnumerable(stream.current())) {
|
216
188
|
returnType = BUILTIN;
|
217
|
-
}
|
189
|
+
}else returnType = null;
|
218
190
|
}
|
219
191
|
}
|
220
192
|
return (typeof state.sExprComment == "number") ? COMMENT : returnType;
|
@@ -227,4 +199,4 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
227
199
|
};
|
228
200
|
});
|
229
201
|
|
230
|
-
CodeMirror.defineMIME("text/x-scheme", "scheme");
|
202
|
+
CodeMirror.defineMIME("text/x-scheme", "scheme");
|
@@ -27,45 +27,45 @@ CodeMirror.defineMode('smalltalk', function(config, modeConfig) {
|
|
27
27
|
|
28
28
|
var next = function(stream, context, state) {
|
29
29
|
var token = new Token(null, context, false);
|
30
|
-
var
|
30
|
+
var char = stream.next();
|
31
31
|
|
32
|
-
if (
|
32
|
+
if (char === '"') {
|
33
33
|
token = nextComment(stream, new Context(nextComment, context));
|
34
34
|
|
35
|
-
} else if (
|
35
|
+
} else if (char === '\'') {
|
36
36
|
token = nextString(stream, new Context(nextString, context));
|
37
37
|
|
38
|
-
} else if (
|
38
|
+
} else if (char === '#') {
|
39
39
|
stream.eatWhile(/[^ .]/);
|
40
40
|
token.name = 'string-2';
|
41
41
|
|
42
|
-
} else if (
|
42
|
+
} else if (char === '$') {
|
43
43
|
stream.eatWhile(/[^ ]/);
|
44
44
|
token.name = 'string-2';
|
45
45
|
|
46
|
-
} else if (
|
46
|
+
} else if (char === '|' && state.expectVariable) {
|
47
47
|
token.context = new Context(nextTemporaries, context);
|
48
48
|
|
49
|
-
} else if (/[\[\]{}()]/.test(
|
49
|
+
} else if (/[\[\]{}()]/.test(char)) {
|
50
50
|
token.name = 'bracket';
|
51
|
-
token.eos = /[\[{(]/.test(
|
51
|
+
token.eos = /[\[{(]/.test(char);
|
52
52
|
|
53
|
-
if (
|
53
|
+
if (char === '[') {
|
54
54
|
state.indentation++;
|
55
|
-
} else if (
|
55
|
+
} else if (char === ']') {
|
56
56
|
state.indentation = Math.max(0, state.indentation - 1);
|
57
57
|
}
|
58
58
|
|
59
|
-
} else if (specialChars.test(
|
59
|
+
} else if (specialChars.test(char)) {
|
60
60
|
stream.eatWhile(specialChars);
|
61
61
|
token.name = 'operator';
|
62
|
-
token.eos =
|
62
|
+
token.eos = char !== ';'; // ; cascaded message expression
|
63
63
|
|
64
|
-
} else if (/\d/.test(
|
64
|
+
} else if (/\d/.test(char)) {
|
65
65
|
stream.eatWhile(/[\w\d]/);
|
66
66
|
token.name = 'number'
|
67
67
|
|
68
|
-
} else if (/[\w_]/.test(
|
68
|
+
} else if (/[\w_]/.test(char)) {
|
69
69
|
stream.eatWhile(/[\w\d_]/);
|
70
70
|
token.name = state.expectVariable ? (keywords.test(stream.current()) ? 'keyword' : 'variable') : null;
|
71
71
|
|
@@ -88,9 +88,9 @@ CodeMirror.defineMode('smalltalk', function(config, modeConfig) {
|
|
88
88
|
|
89
89
|
var nextTemporaries = function(stream, context, state) {
|
90
90
|
var token = new Token(null, context, false);
|
91
|
-
var
|
91
|
+
var char = stream.next();
|
92
92
|
|
93
|
-
if (
|
93
|
+
if (char === '|') {
|
94
94
|
token.context = context.parent;
|
95
95
|
token.eos = true;
|
96
96
|
|
@@ -82,37 +82,22 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
|
|
82
82
|
}
|
83
83
|
|
84
84
|
function normal(source, state) {
|
85
|
-
if (source.match(/^\\[a-
|
85
|
+
if (source.match(/^\\[a-z]+/)) {
|
86
86
|
var cmdName = source.current();
|
87
87
|
cmdName = cmdName.substr(1, cmdName.length-1);
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
plug = plugins["DEFAULT"];
|
93
|
-
}
|
88
|
+
var plug = plugins[cmdName];
|
89
|
+
if (typeof(plug) == 'undefined') {
|
90
|
+
plug = plugins["DEFAULT"];
|
91
|
+
}
|
94
92
|
plug = new plug();
|
95
93
|
pushCommand(state, plug);
|
96
94
|
setState(state, beginParams);
|
97
95
|
return plug.style;
|
98
96
|
}
|
99
97
|
|
100
|
-
// escape characters
|
101
|
-
if (source.match(/^\\[$&%#{}_]/)) {
|
102
|
-
return "tag";
|
103
|
-
}
|
104
|
-
|
105
|
-
// white space control characters
|
106
|
-
if (source.match(/^\\[,;!\/]/)) {
|
107
|
-
return "tag";
|
108
|
-
}
|
109
|
-
|
110
98
|
var ch = source.next();
|
111
99
|
if (ch == "%") {
|
112
|
-
|
113
|
-
if (!source.eol()) {
|
114
|
-
setState(state, inCComment);
|
115
|
-
}
|
100
|
+
setState(state, inCComment);
|
116
101
|
return "comment";
|
117
102
|
}
|
118
103
|
else if (ch=='}' || ch==']') {
|
@@ -1,18 +1,18 @@
|
|
1
1
|
/***
|
2
|
-
|''Name''|tiddlywiki.js|
|
3
|
-
|''Description''|Enables TiddlyWikiy syntax highlighting using
|
4
|
-
|''Author''|PMario|
|
5
|
-
|''Version''|0.1.
|
6
|
-
|''Status''|''
|
7
|
-
|''Source''|[[GitHub|https://github.com/pmario/CodeMirror2/blob/tw-syntax/mode/tiddlywiki]]|
|
8
|
-
|''Documentation''|http://codemirror.tiddlyspace.com/|
|
9
|
-
|''License''|[[MIT License|http://www.opensource.org/licenses/mit-license.php]]|
|
10
|
-
|''CoreVersion''|2.5.0|
|
11
|
-
|''Requires''|codemirror.js|
|
12
|
-
|''Keywords''|syntax highlighting color code mirror codemirror|
|
13
|
-
! Info
|
14
|
-
CoreVersion parameter is needed for TiddlyWiki only!
|
15
|
-
***/
|
2
|
+
|''Name''|tiddlywiki.js|
|
3
|
+
|''Description''|Enables TiddlyWikiy syntax highlighting using CodeMirror2|
|
4
|
+
|''Author''|PMario|
|
5
|
+
|''Version''|0.1.6|
|
6
|
+
|''Status''|''beta''|
|
7
|
+
|''Source''|[[GitHub|https://github.com/pmario/CodeMirror2/blob/tw-syntax/mode/tiddlywiki]]|
|
8
|
+
|''Documentation''|http://codemirror.tiddlyspace.com/|
|
9
|
+
|''License''|[[MIT License|http://www.opensource.org/licenses/mit-license.php]]|
|
10
|
+
|''CoreVersion''|2.5.0|
|
11
|
+
|''Requires''|codemirror.js|
|
12
|
+
|''Keywords''|syntax highlighting color code mirror codemirror|
|
13
|
+
! Info
|
14
|
+
CoreVersion parameter is needed for TiddlyWiki only!
|
15
|
+
***/
|
16
16
|
//{{{
|
17
17
|
CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
18
18
|
var indentUnit = config.indentUnit;
|
@@ -47,20 +47,20 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
47
47
|
}();
|
48
48
|
|
49
49
|
var isSpaceName = /[\w_\-]/i,
|
50
|
-
reHR = /^\-\-\-\-+$/,
|
50
|
+
reHR = /^\-\-\-\-+$/,
|
51
51
|
reWikiCommentStart = /^\/\*\*\*$/, // /***
|
52
52
|
reWikiCommentStop = /^\*\*\*\/$/, // ***/
|
53
53
|
reBlockQuote = /^<<<$/,
|
54
54
|
|
55
|
-
reJsCodeStart = /^\/\/\{\{\{$/, // //{{{
|
56
|
-
reJsCodeStop = /^\/\/\}\}\}$/, // //}}}
|
57
|
-
reXmlCodeStart = /^<!--\{\{\{-->$/,
|
58
|
-
reXmlCodeStop = /^<!--\}\}\}-->$/,
|
55
|
+
reJsCodeStart = /^\/\/\{\{\{$/, // //{{{
|
56
|
+
reJsCodeStop = /^\/\/\}\}\}$/, // //}}}
|
57
|
+
reXmlCodeStart = /^<!--\{\{\{-->$/,
|
58
|
+
reXmlCodeStop = /^<!--\}\}\}-->$/,
|
59
59
|
|
60
|
-
reCodeBlockStart = /^\{\{\{$/,
|
61
|
-
reCodeBlockStop = /^\}\}\}$/,
|
60
|
+
reCodeBlockStart = /^\{\{\{$/,
|
61
|
+
reCodeBlockStop = /^\}\}\}$/,
|
62
62
|
|
63
|
-
reCodeStart = /\{\{\{/,
|
63
|
+
reCodeStart = /\{\{\{/,
|
64
64
|
reUntilCodeStop = /.*?\}\}\}/;
|
65
65
|
|
66
66
|
function chain(stream, state, f) {
|
@@ -95,9 +95,9 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
95
95
|
|
96
96
|
state.block = false; // indicates the start of a code block.
|
97
97
|
|
98
|
-
ch = stream.peek();
|
98
|
+
ch = stream.peek(); // don't eat, to make match simpler
|
99
99
|
|
100
|
-
// check start of blocks
|
100
|
+
// check start of blocks
|
101
101
|
if (sol && /[<\/\*{}\-]/.test(ch)) {
|
102
102
|
if (stream.match(reCodeBlockStart)) {
|
103
103
|
state.block = true;
|
@@ -107,16 +107,16 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
107
107
|
return ret('quote', 'quote');
|
108
108
|
}
|
109
109
|
if (stream.match(reWikiCommentStart) || stream.match(reWikiCommentStop)) {
|
110
|
-
return ret('code', '
|
110
|
+
return ret('code', 'code');
|
111
111
|
}
|
112
112
|
if (stream.match(reJsCodeStart) || stream.match(reJsCodeStop) || stream.match(reXmlCodeStart) || stream.match(reXmlCodeStop)) {
|
113
|
-
return ret('code', '
|
113
|
+
return ret('code', 'code');
|
114
114
|
}
|
115
115
|
if (stream.match(reHR)) {
|
116
116
|
return ret('hr', 'hr');
|
117
117
|
}
|
118
118
|
} // sol
|
119
|
-
ch = stream.next();
|
119
|
+
var ch = stream.next();
|
120
120
|
|
121
121
|
if (sol && /[\/\*!#;:>|]/.test(ch)) {
|
122
122
|
if (ch == "!") { // tw header
|
@@ -125,26 +125,26 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
125
125
|
}
|
126
126
|
if (ch == "*") { // tw list
|
127
127
|
stream.eatWhile('*');
|
128
|
-
return ret("list", "
|
128
|
+
return ret("list", "list");
|
129
129
|
}
|
130
130
|
if (ch == "#") { // tw numbered list
|
131
131
|
stream.eatWhile('#');
|
132
|
-
return ret("list", "
|
132
|
+
return ret("list", "list");
|
133
133
|
}
|
134
|
-
if (ch == ";") { //
|
134
|
+
if (ch == ";") { // tw list
|
135
135
|
stream.eatWhile(';');
|
136
|
-
return ret("list", "
|
136
|
+
return ret("list", "list");
|
137
137
|
}
|
138
|
-
if (ch == ":") { //
|
138
|
+
if (ch == ":") { // tw list
|
139
139
|
stream.eatWhile(':');
|
140
|
-
return ret("list", "
|
140
|
+
return ret("list", "list");
|
141
141
|
}
|
142
142
|
if (ch == ">") { // single line quote
|
143
143
|
stream.eatWhile(">");
|
144
144
|
return ret("quote", "quote");
|
145
145
|
}
|
146
146
|
if (ch == '|') {
|
147
|
-
return ret('table', '
|
147
|
+
return ret('table', 'table');
|
148
148
|
}
|
149
149
|
}
|
150
150
|
|
@@ -155,16 +155,13 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
155
155
|
// rudimentary html:// file:// link matching. TW knows much more ...
|
156
156
|
if (/[hf]/i.test(ch)) {
|
157
157
|
if (/[ti]/i.test(stream.peek()) && stream.match(/\b(ttps?|tp|ile):\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i)) {
|
158
|
-
return ret("link", "link");
|
158
|
+
return ret("link-external", "link-external");
|
159
159
|
}
|
160
160
|
}
|
161
161
|
// just a little string indicator, don't want to have the whole string covered
|
162
162
|
if (ch == '"') {
|
163
163
|
return ret('string', 'string');
|
164
164
|
}
|
165
|
-
if (ch == '~') { // _no_ CamelCase indicator should be bold
|
166
|
-
return ret('text', 'brace');
|
167
|
-
}
|
168
165
|
if (/[\[\]]/.test(ch)) { // check for [[..]]
|
169
166
|
if (stream.peek() == ch) {
|
170
167
|
stream.next();
|
@@ -173,7 +170,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
173
170
|
}
|
174
171
|
if (ch == "@") { // check for space link. TODO fix @@...@@ highlighting
|
175
172
|
stream.eatWhile(isSpaceName);
|
176
|
-
return ret("link", "link");
|
173
|
+
return ret("link-external", "link-external");
|
177
174
|
}
|
178
175
|
if (/\d/.test(ch)) { // numbers
|
179
176
|
stream.eatWhile(/\d/);
|
@@ -192,15 +189,9 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
192
189
|
return chain(stream, state, twTokenUnderline);
|
193
190
|
}
|
194
191
|
}
|
195
|
-
// strikethrough
|
196
|
-
if (ch == "-") {
|
192
|
+
if (ch == "-") { // tw strikethrough TODO looks ugly .. different handling see below;
|
197
193
|
if (stream.eat("-")) {
|
198
|
-
|
199
|
-
if (stream.peek() != ' ')
|
200
|
-
return chain(stream, state, twTokenStrike);
|
201
|
-
// mdash
|
202
|
-
if (stream.peek() == ' ')
|
203
|
-
return ret('text', 'brace');
|
194
|
+
return chain(stream, state, twTokenStrike);
|
204
195
|
}
|
205
196
|
}
|
206
197
|
if (ch == "'") { // tw bold
|
@@ -217,7 +208,6 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
217
208
|
return ret(ch);
|
218
209
|
}
|
219
210
|
|
220
|
-
// core macro handling
|
221
211
|
stream.eatWhile(/[\w\$_]/);
|
222
212
|
var word = stream.current(),
|
223
213
|
known = textwords.propertyIsEnumerable(word) && textwords[word];
|
@@ -266,21 +256,21 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
266
256
|
var ch, sb = state.block;
|
267
257
|
|
268
258
|
if (sb && stream.current()) {
|
269
|
-
return ret("code", "
|
259
|
+
return ret("code", "code");
|
270
260
|
}
|
271
261
|
|
272
262
|
if (!sb && stream.match(reUntilCodeStop)) {
|
273
263
|
state.tokenize = jsTokenBase;
|
274
|
-
return ret("code", "
|
264
|
+
return ret("code", "code-inline");
|
275
265
|
}
|
276
266
|
|
277
267
|
if (sb && stream.sol() && stream.match(reCodeBlockStop)) {
|
278
268
|
state.tokenize = jsTokenBase;
|
279
|
-
return ret("code", "
|
269
|
+
return ret("code", "code");
|
280
270
|
}
|
281
271
|
|
282
272
|
ch = stream.next();
|
283
|
-
return (sb) ? ret("code", "
|
273
|
+
return (sb) ? ret("code", "code") : ret("code", "code-inline");
|
284
274
|
}
|
285
275
|
|
286
276
|
// tw em / italic
|
@@ -311,8 +301,8 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
311
301
|
return ret("text", "underlined");
|
312
302
|
}
|
313
303
|
|
314
|
-
// tw strike through text looks ugly
|
315
|
-
//
|
304
|
+
// tw strike through text looks ugly
|
305
|
+
// TODO just strike through the first and last 2 chars if possible.
|
316
306
|
function twTokenStrike(stream, state) {
|
317
307
|
var maybeEnd = false,
|
318
308
|
ch, nr;
|
@@ -324,7 +314,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
324
314
|
}
|
325
315
|
maybeEnd = (ch == "-");
|
326
316
|
}
|
327
|
-
return ret("text", "
|
317
|
+
return ret("text", "line-through");
|
328
318
|
}
|
329
319
|
|
330
320
|
// macro
|