codemirror-rails 3.24 → 4.0
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 +3001 -1798
- data/vendor/assets/javascripts/codemirror/addons/comment/comment.js +24 -4
- data/vendor/assets/javascripts/codemirror/addons/comment/continuecomment.js +47 -32
- data/vendor/assets/javascripts/codemirror/addons/dialog/dialog.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/display/fullscreen.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/display/placeholder.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/display/rulers.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +76 -37
- data/vendor/assets/javascripts/codemirror/addons/edit/closetag.js +59 -37
- data/vendor/assets/javascripts/codemirror/addons/edit/continuelist.js +25 -17
- data/vendor/assets/javascripts/codemirror/addons/edit/matchbrackets.js +67 -46
- data/vendor/assets/javascripts/codemirror/addons/edit/matchtags.js +10 -3
- data/vendor/assets/javascripts/codemirror/addons/edit/trailingspace.js +23 -14
- data/vendor/assets/javascripts/codemirror/addons/fold/brace-fold.js +12 -3
- data/vendor/assets/javascripts/codemirror/addons/fold/comment-fold.js +12 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/foldcode.js +28 -3
- data/vendor/assets/javascripts/codemirror/addons/fold/foldgutter.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/fold/indent-fold.js +12 -1
- data/vendor/assets/javascripts/codemirror/addons/fold/markdown-fold.js +12 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/xml-fold.js +9 -4
- data/vendor/assets/javascripts/codemirror/addons/hint/anyword-hint.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/hint/css-hint.js +10 -3
- data/vendor/assets/javascripts/codemirror/addons/hint/html-hint.js +11 -3
- data/vendor/assets/javascripts/codemirror/addons/hint/javascript-hint.js +9 -4
- data/vendor/assets/javascripts/codemirror/addons/hint/python-hint.js +11 -3
- data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +10 -4
- data/vendor/assets/javascripts/codemirror/addons/hint/sql-hint.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/hint/xml-hint.js +22 -34
- data/vendor/assets/javascripts/codemirror/addons/lint/coffeescript-lint.js +12 -1
- data/vendor/assets/javascripts/codemirror/addons/lint/css-lint.js +12 -1
- data/vendor/assets/javascripts/codemirror/addons/lint/javascript-lint.js +9 -4
- data/vendor/assets/javascripts/codemirror/addons/lint/json-lint.js +12 -1
- data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +12 -8
- data/vendor/assets/javascripts/codemirror/addons/lint/yaml-lint.js +12 -1
- data/vendor/assets/javascripts/codemirror/addons/merge/merge.js +18 -16
- data/vendor/assets/javascripts/codemirror/addons/mode/loadmode.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/mode/multiplex.js +12 -0
- data/vendor/assets/javascripts/codemirror/addons/mode/overlay.js +15 -10
- data/vendor/assets/javascripts/codemirror/addons/runmode/colorize.js +11 -3
- data/vendor/assets/javascripts/codemirror/addons/runmode/runmode-standalone.js +0 -2
- data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.js +12 -0
- data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +4 -0
- data/vendor/assets/javascripts/codemirror/addons/scroll/scrollpastend.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js +12 -3
- data/vendor/assets/javascripts/codemirror/addons/search/search.js +24 -16
- data/vendor/assets/javascripts/codemirror/addons/search/searchcursor.js +21 -2
- data/vendor/assets/javascripts/codemirror/addons/selection/active-line.js +38 -17
- data/vendor/assets/javascripts/codemirror/addons/selection/mark-selection.js +16 -9
- data/vendor/assets/javascripts/codemirror/addons/tern/tern.js +33 -5
- data/vendor/assets/javascripts/codemirror/addons/wrap/hardwrap.js +27 -2
- data/vendor/assets/javascripts/codemirror/keymaps/emacs.js +12 -5
- data/vendor/assets/javascripts/codemirror/keymaps/sublime.js +505 -0
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +138 -179
- data/vendor/assets/javascripts/codemirror/modes/apl.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/asterisk.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/clike.js +15 -4
- data/vendor/assets/javascripts/codemirror/modes/clojure.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/cobol.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/commonlisp.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/css.js +18 -27
- data/vendor/assets/javascripts/codemirror/modes/d.js +12 -2
- data/vendor/assets/javascripts/codemirror/modes/diff.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/dtd.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/ecl.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/eiffel.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/erlang.js +13 -1
- data/vendor/assets/javascripts/codemirror/modes/fortran.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/gas.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/gfm.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/gherkin.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/go.js +12 -1
- data/vendor/assets/javascripts/codemirror/modes/groovy.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/haml.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/haskell.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/haxe.js +18 -9
- data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/http.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/jade.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +23 -16
- data/vendor/assets/javascripts/codemirror/modes/jinja2.js +53 -118
- data/vendor/assets/javascripts/codemirror/modes/julia.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/livescript.js +17 -4
- data/vendor/assets/javascripts/codemirror/modes/lua.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/mirc.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/mllike.js +12 -1
- data/vendor/assets/javascripts/codemirror/modes/nginx.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/ntriples.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/octave.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/pascal.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/pegjs.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/perl.js +84 -73
- data/vendor/assets/javascripts/codemirror/modes/php.js +20 -101
- data/vendor/assets/javascripts/codemirror/modes/pig.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/properties.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/puppet.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/python.js +21 -11
- data/vendor/assets/javascripts/codemirror/modes/q.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/r.js +13 -3
- data/vendor/assets/javascripts/codemirror/modes/{rpm-spec.js → rpm.js} +34 -2
- data/vendor/assets/javascripts/codemirror/modes/rst.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/ruby.js +11 -0
- data/vendor/assets/javascripts/codemirror/modes/rust.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/sass.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/scheme.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/shell.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/sieve.js +11 -4
- data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/smarty.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/smartymixed.js +14 -2
- data/vendor/assets/javascripts/codemirror/modes/solr.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/sparql.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/sql.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/stex.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/tcl.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/tiki.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/toml.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/turtle.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/vb.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/vbscript.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/velocity.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/verilog.js +89 -236
- data/vendor/assets/javascripts/codemirror/modes/xml.js +41 -60
- data/vendor/assets/javascripts/codemirror/modes/xquery.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/yaml.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/z80.js +12 -0
- data/vendor/assets/stylesheets/codemirror.css +15 -10
- data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +1 -0
- data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +4 -0
- data/vendor/assets/stylesheets/codemirror/themes/mdn-like.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/pastel-on-dark.css +1 -0
- data/vendor/assets/stylesheets/codemirror/themes/rubyblue.css +2 -0
- data/vendor/assets/stylesheets/codemirror/themes/solarized.css +17 -3
- metadata +20 -25
- data/vendor/assets/javascripts/codemirror/keymaps/extra.js +0 -43
- data/vendor/assets/javascripts/codemirror/modes/django.js +0 -55
- data/vendor/assets/javascripts/codemirror/modes/dylan.js +0 -284
- data/vendor/assets/javascripts/codemirror/modes/less.js +0 -347
- data/vendor/assets/javascripts/codemirror/modes/rpm-changes.js +0 -19
- data/vendor/assets/stylesheets/codemirror/modes/rpm-spec.css +0 -5
@@ -1,43 +0,0 @@
|
|
1
|
-
// A number of additional default bindings that are too obscure to
|
2
|
-
// include in the core codemirror.js file.
|
3
|
-
|
4
|
-
(function() {
|
5
|
-
"use strict";
|
6
|
-
|
7
|
-
var Pos = CodeMirror.Pos;
|
8
|
-
|
9
|
-
function moveLines(cm, start, end, dist) {
|
10
|
-
if (!dist || start > end) return 0;
|
11
|
-
|
12
|
-
var from = cm.clipPos(Pos(start, 0)), to = cm.clipPos(Pos(end));
|
13
|
-
var text = cm.getRange(from, to);
|
14
|
-
|
15
|
-
if (start <= cm.firstLine())
|
16
|
-
cm.replaceRange("", from, Pos(to.line + 1, 0));
|
17
|
-
else
|
18
|
-
cm.replaceRange("", Pos(from.line - 1), to);
|
19
|
-
var target = from.line + dist;
|
20
|
-
if (target <= cm.firstLine()) {
|
21
|
-
cm.replaceRange(text + "\n", Pos(target, 0));
|
22
|
-
return cm.firstLine() - from.line;
|
23
|
-
} else {
|
24
|
-
var targetPos = cm.clipPos(Pos(target - 1));
|
25
|
-
cm.replaceRange("\n" + text, targetPos);
|
26
|
-
return targetPos.line + 1 - from.line;
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
function moveSelectedLines(cm, dist) {
|
31
|
-
var head = cm.getCursor("head"), anchor = cm.getCursor("anchor");
|
32
|
-
cm.operation(function() {
|
33
|
-
var moved = moveLines(cm, Math.min(head.line, anchor.line), Math.max(head.line, anchor.line), dist);
|
34
|
-
cm.setSelection(Pos(anchor.line + moved, anchor.ch), Pos(head.line + moved, head.ch));
|
35
|
-
});
|
36
|
-
}
|
37
|
-
|
38
|
-
CodeMirror.commands.moveLinesUp = function(cm) { moveSelectedLines(cm, -1); };
|
39
|
-
CodeMirror.commands.moveLinesDown = function(cm) { moveSelectedLines(cm, 1); };
|
40
|
-
|
41
|
-
CodeMirror.keyMap["default"]["Alt-Up"] = "moveLinesUp";
|
42
|
-
CodeMirror.keyMap["default"]["Alt-Down"] = "moveLinesDown";
|
43
|
-
})();
|
@@ -1,55 +0,0 @@
|
|
1
|
-
(function(CodeMirror) {
|
2
|
-
"use strict";
|
3
|
-
|
4
|
-
CodeMirror.defineMode("django:inner", function() {
|
5
|
-
var keywords = ["block", "endblock", "for", "endfor", "in", "true", "false",
|
6
|
-
"loop", "none", "self", "super", "if", "endif", "as", "not", "and",
|
7
|
-
"else", "import", "with", "endwith", "without", "context", "ifequal", "endifequal",
|
8
|
-
"ifnotequal", "endifnotequal", "extends", "include", "load", "length", "comment",
|
9
|
-
"endcomment", "empty"];
|
10
|
-
keywords = new RegExp("^((" + keywords.join(")|(") + "))\\b");
|
11
|
-
|
12
|
-
function tokenBase (stream, state) {
|
13
|
-
stream.eatWhile(/[^\{]/);
|
14
|
-
var ch = stream.next();
|
15
|
-
if (ch == "{") {
|
16
|
-
if (ch = stream.eat(/\{|%|#/)) {
|
17
|
-
state.tokenize = inTag(ch);
|
18
|
-
return "tag";
|
19
|
-
}
|
20
|
-
}
|
21
|
-
}
|
22
|
-
function inTag (close) {
|
23
|
-
if (close == "{") {
|
24
|
-
close = "}";
|
25
|
-
}
|
26
|
-
return function (stream, state) {
|
27
|
-
var ch = stream.next();
|
28
|
-
if ((ch == close) && stream.eat("}")) {
|
29
|
-
state.tokenize = tokenBase;
|
30
|
-
return "tag";
|
31
|
-
}
|
32
|
-
if (stream.match(keywords)) {
|
33
|
-
return "keyword";
|
34
|
-
}
|
35
|
-
return close == "#" ? "comment" : "string";
|
36
|
-
};
|
37
|
-
}
|
38
|
-
return {
|
39
|
-
startState: function () {
|
40
|
-
return {tokenize: tokenBase};
|
41
|
-
},
|
42
|
-
token: function (stream, state) {
|
43
|
-
return state.tokenize(stream, state);
|
44
|
-
}
|
45
|
-
};
|
46
|
-
});
|
47
|
-
|
48
|
-
CodeMirror.defineMode("django", function(config) {
|
49
|
-
var htmlBase = CodeMirror.getMode(config, "text/html");
|
50
|
-
var djangoInner = CodeMirror.getMode(config, "django:inner");
|
51
|
-
return CodeMirror.overlayMode(htmlBase, djangoInner);
|
52
|
-
});
|
53
|
-
|
54
|
-
CodeMirror.defineMIME("text/x-django", "django");
|
55
|
-
})(CodeMirror);
|
@@ -1,284 +0,0 @@
|
|
1
|
-
CodeMirror.defineMode("dylan", function(_config) {
|
2
|
-
// Words
|
3
|
-
var words = {
|
4
|
-
// Words that introduce unnamed definitions like "define interface"
|
5
|
-
unnamedDefinition: ["interface"],
|
6
|
-
|
7
|
-
// Words that introduce simple named definitions like "define library"
|
8
|
-
namedDefinition: ["module", "library", "macro",
|
9
|
-
"C-struct", "C-union",
|
10
|
-
"C-function", "C-callable-wrapper"
|
11
|
-
],
|
12
|
-
|
13
|
-
// Words that introduce type definitions like "define class".
|
14
|
-
// These are also parameterized like "define method" and are
|
15
|
-
// appended to otherParameterizedDefinitionWords
|
16
|
-
typeParameterizedDefinition: ["class", "C-subtype", "C-mapped-subtype"],
|
17
|
-
|
18
|
-
// Words that introduce trickier definitions like "define method".
|
19
|
-
// These require special definitions to be added to startExpressions
|
20
|
-
otherParameterizedDefinition: ["method", "function",
|
21
|
-
"C-variable", "C-address"
|
22
|
-
],
|
23
|
-
|
24
|
-
// Words that introduce module constant definitions.
|
25
|
-
// These must also be simple definitions and are
|
26
|
-
// appended to otherSimpleDefinitionWords
|
27
|
-
constantSimpleDefinition: ["constant"],
|
28
|
-
|
29
|
-
// Words that introduce module variable definitions.
|
30
|
-
// These must also be simple definitions and are
|
31
|
-
// appended to otherSimpleDefinitionWords
|
32
|
-
variableSimpleDefinition: ["variable"],
|
33
|
-
|
34
|
-
// Other words that introduce simple definitions
|
35
|
-
// (without implicit bodies).
|
36
|
-
otherSimpleDefinition: ["generic", "domain",
|
37
|
-
"C-pointer-type",
|
38
|
-
"table"
|
39
|
-
],
|
40
|
-
|
41
|
-
// Words that begin statements with implicit bodies.
|
42
|
-
statement: ["if", "block", "begin", "method", "case",
|
43
|
-
"for", "select", "when", "unless", "until",
|
44
|
-
"while", "iterate", "profiling", "dynamic-bind"
|
45
|
-
],
|
46
|
-
|
47
|
-
// Patterns that act as separators in compound statements.
|
48
|
-
// This may include any general pattern that must be indented
|
49
|
-
// specially.
|
50
|
-
separator: ["finally", "exception", "cleanup", "else",
|
51
|
-
"elseif", "afterwards"
|
52
|
-
],
|
53
|
-
|
54
|
-
// Keywords that do not require special indentation handling,
|
55
|
-
// but which should be highlighted
|
56
|
-
other: ["above", "below", "by", "from", "handler", "in",
|
57
|
-
"instance", "let", "local", "otherwise", "slot",
|
58
|
-
"subclass", "then", "to", "keyed-by", "virtual"
|
59
|
-
],
|
60
|
-
|
61
|
-
// Condition signaling function calls
|
62
|
-
signalingCalls: ["signal", "error", "cerror",
|
63
|
-
"break", "check-type", "abort"
|
64
|
-
]
|
65
|
-
};
|
66
|
-
|
67
|
-
words["otherDefinition"] =
|
68
|
-
words["unnamedDefinition"]
|
69
|
-
.concat(words["namedDefinition"])
|
70
|
-
.concat(words["otherParameterizedDefinition"]);
|
71
|
-
|
72
|
-
words["definition"] =
|
73
|
-
words["typeParameterizedDefinition"]
|
74
|
-
.concat(words["otherDefinition"]);
|
75
|
-
|
76
|
-
words["parameterizedDefinition"] =
|
77
|
-
words["typeParameterizedDefinition"]
|
78
|
-
.concat(words["otherParameterizedDefinition"]);
|
79
|
-
|
80
|
-
words["simpleDefinition"] =
|
81
|
-
words["constantSimpleDefinition"]
|
82
|
-
.concat(words["variableSimpleDefinition"])
|
83
|
-
.concat(words["otherSimpleDefinition"]);
|
84
|
-
|
85
|
-
words["keyword"] =
|
86
|
-
words["statement"]
|
87
|
-
.concat(words["separator"])
|
88
|
-
.concat(words["other"]);
|
89
|
-
|
90
|
-
// Patterns
|
91
|
-
var symbolPattern = "[-_a-zA-Z?!*@<>$%]+";
|
92
|
-
var symbol = new RegExp("^" + symbolPattern);
|
93
|
-
var patterns = {
|
94
|
-
// Symbols with special syntax
|
95
|
-
symbolKeyword: symbolPattern + ":",
|
96
|
-
symbolClass: "<" + symbolPattern + ">",
|
97
|
-
symbolGlobal: "\\*" + symbolPattern + "\\*",
|
98
|
-
symbolConstant: "\\$" + symbolPattern
|
99
|
-
};
|
100
|
-
var patternStyles = {
|
101
|
-
symbolKeyword: "atom",
|
102
|
-
symbolClass: "tag",
|
103
|
-
symbolGlobal: "variable-2",
|
104
|
-
symbolConstant: "variable-3"
|
105
|
-
};
|
106
|
-
|
107
|
-
// Compile all patterns to regular expressions
|
108
|
-
for (var patternName in patterns)
|
109
|
-
if (patterns.hasOwnProperty(patternName))
|
110
|
-
patterns[patternName] = new RegExp("^" + patterns[patternName]);
|
111
|
-
|
112
|
-
// Names beginning "with-" and "without-" are commonly
|
113
|
-
// used as statement macro
|
114
|
-
patterns["keyword"] = [/^with(?:out)?-[-_a-zA-Z?!*@<>$%]+/];
|
115
|
-
|
116
|
-
var styles = {};
|
117
|
-
styles["keyword"] = "keyword";
|
118
|
-
styles["definition"] = "def";
|
119
|
-
styles["simpleDefinition"] = "def";
|
120
|
-
styles["signalingCalls"] = "builtin";
|
121
|
-
|
122
|
-
// protected words lookup table
|
123
|
-
var wordLookup = {};
|
124
|
-
var styleLookup = {};
|
125
|
-
|
126
|
-
[
|
127
|
-
"keyword",
|
128
|
-
"definition",
|
129
|
-
"simpleDefinition",
|
130
|
-
"signalingCalls"
|
131
|
-
].forEach(function(type) {
|
132
|
-
words[type].forEach(function(word) {
|
133
|
-
wordLookup[word] = type;
|
134
|
-
styleLookup[word] = styles[type];
|
135
|
-
});
|
136
|
-
});
|
137
|
-
|
138
|
-
|
139
|
-
function chain(stream, state, f) {
|
140
|
-
state.tokenize = f;
|
141
|
-
return f(stream, state);
|
142
|
-
}
|
143
|
-
|
144
|
-
var type, content;
|
145
|
-
|
146
|
-
function ret(_type, style, _content) {
|
147
|
-
type = _type;
|
148
|
-
content = _content;
|
149
|
-
return style;
|
150
|
-
}
|
151
|
-
|
152
|
-
function tokenBase(stream, state) {
|
153
|
-
// String
|
154
|
-
var ch = stream.peek();
|
155
|
-
if (ch == "'" || ch == '"') {
|
156
|
-
stream.next();
|
157
|
-
return chain(stream, state, tokenString(ch, "string", "string"));
|
158
|
-
}
|
159
|
-
// Comment
|
160
|
-
else if (ch == "/") {
|
161
|
-
stream.next();
|
162
|
-
if (stream.eat("*")) {
|
163
|
-
return chain(stream, state, tokenComment);
|
164
|
-
} else if (stream.eat("/")) {
|
165
|
-
stream.skipToEnd();
|
166
|
-
return ret("comment", "comment");
|
167
|
-
} else {
|
168
|
-
stream.skipTo(" ");
|
169
|
-
return ret("operator", "operator");
|
170
|
-
}
|
171
|
-
}
|
172
|
-
// Decimal
|
173
|
-
else if (/\d/.test(ch)) {
|
174
|
-
stream.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/);
|
175
|
-
return ret("number", "number");
|
176
|
-
}
|
177
|
-
// Hash
|
178
|
-
else if (ch == "#") {
|
179
|
-
stream.next();
|
180
|
-
// Symbol with string syntax
|
181
|
-
ch = stream.peek();
|
182
|
-
if (ch == '"') {
|
183
|
-
stream.next();
|
184
|
-
return chain(stream, state, tokenString('"', "symbol", "string-2"));
|
185
|
-
}
|
186
|
-
// Binary number
|
187
|
-
else if (ch == "b") {
|
188
|
-
stream.next();
|
189
|
-
stream.eatWhile(/[01]/);
|
190
|
-
return ret("number", "number");
|
191
|
-
}
|
192
|
-
// Hex number
|
193
|
-
else if (ch == "x") {
|
194
|
-
stream.next();
|
195
|
-
stream.eatWhile(/[\da-f]/i);
|
196
|
-
return ret("number", "number");
|
197
|
-
}
|
198
|
-
// Octal number
|
199
|
-
else if (ch == "o") {
|
200
|
-
stream.next();
|
201
|
-
stream.eatWhile(/[0-7]/);
|
202
|
-
return ret("number", "number");
|
203
|
-
}
|
204
|
-
// Hash symbol
|
205
|
-
else {
|
206
|
-
stream.eatWhile(/[-a-zA-Z]/);
|
207
|
-
return ret("hash", "keyword");
|
208
|
-
}
|
209
|
-
} else if (stream.match("end")) {
|
210
|
-
return ret("end", "keyword");
|
211
|
-
}
|
212
|
-
for (var name in patterns) {
|
213
|
-
if (patterns.hasOwnProperty(name)) {
|
214
|
-
var pattern = patterns[name];
|
215
|
-
if ((pattern instanceof Array && pattern.some(function(p) {
|
216
|
-
return stream.match(p);
|
217
|
-
})) || stream.match(pattern))
|
218
|
-
return ret(name, patternStyles[name], stream.current());
|
219
|
-
}
|
220
|
-
}
|
221
|
-
if (stream.match("define")) {
|
222
|
-
return ret("definition", "def");
|
223
|
-
} else {
|
224
|
-
stream.eatWhile(/[\w\-]/);
|
225
|
-
// Keyword
|
226
|
-
if (wordLookup[stream.current()]) {
|
227
|
-
return ret(wordLookup[stream.current()], styleLookup[stream.current()], stream.current());
|
228
|
-
} else if (stream.current().match(symbol)) {
|
229
|
-
return ret("variable", "variable");
|
230
|
-
} else {
|
231
|
-
stream.next();
|
232
|
-
return ret("other", "variable-2");
|
233
|
-
}
|
234
|
-
}
|
235
|
-
}
|
236
|
-
|
237
|
-
function tokenComment(stream, state) {
|
238
|
-
var maybeEnd = false,
|
239
|
-
ch;
|
240
|
-
while ((ch = stream.next())) {
|
241
|
-
if (ch == "/" && maybeEnd) {
|
242
|
-
state.tokenize = tokenBase;
|
243
|
-
break;
|
244
|
-
}
|
245
|
-
maybeEnd = (ch == "*");
|
246
|
-
}
|
247
|
-
return ret("comment", "comment");
|
248
|
-
}
|
249
|
-
|
250
|
-
function tokenString(quote, type, style) {
|
251
|
-
return function(stream, state) {
|
252
|
-
var next, end = false;
|
253
|
-
while ((next = stream.next()) != null) {
|
254
|
-
if (next == quote) {
|
255
|
-
end = true;
|
256
|
-
break;
|
257
|
-
}
|
258
|
-
}
|
259
|
-
if (end)
|
260
|
-
state.tokenize = tokenBase;
|
261
|
-
return ret(type, style);
|
262
|
-
};
|
263
|
-
}
|
264
|
-
|
265
|
-
// Interface
|
266
|
-
return {
|
267
|
-
startState: function() {
|
268
|
-
return {
|
269
|
-
tokenize: tokenBase,
|
270
|
-
currentIndent: 0
|
271
|
-
};
|
272
|
-
},
|
273
|
-
token: function(stream, state) {
|
274
|
-
if (stream.eatSpace())
|
275
|
-
return null;
|
276
|
-
var style = state.tokenize(stream, state);
|
277
|
-
return style;
|
278
|
-
},
|
279
|
-
blockCommentStart: "/*",
|
280
|
-
blockCommentEnd: "*/"
|
281
|
-
};
|
282
|
-
});
|
283
|
-
|
284
|
-
CodeMirror.defineMIME("text/x-dylan", "dylan");
|
@@ -1,347 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
LESS mode - http://www.lesscss.org/
|
3
|
-
Ported to CodeMirror by Peter Kroon <plakroon@gmail.com>
|
4
|
-
Report bugs/issues here: https://github.com/marijnh/CodeMirror/issues
|
5
|
-
GitHub: @peterkroon
|
6
|
-
*/
|
7
|
-
|
8
|
-
CodeMirror.defineMode("less", function(config) {
|
9
|
-
var indentUnit = config.indentUnit, type;
|
10
|
-
function ret(style, tp) {type = tp; return style;}
|
11
|
-
|
12
|
-
var selectors = /(^\:root$|^\:nth\-child$|^\:nth\-last\-child$|^\:nth\-of\-type$|^\:nth\-last\-of\-type$|^\:first\-child$|^\:last\-child$|^\:first\-of\-type$|^\:last\-of\-type$|^\:only\-child$|^\:only\-of\-type$|^\:empty$|^\:link|^\:visited$|^\:active$|^\:hover$|^\:focus$|^\:target$|^\:lang$|^\:enabled^\:disabled$|^\:checked$|^\:first\-line$|^\:first\-letter$|^\:before$|^\:after$|^\:not$|^\:required$|^\:invalid$)/;
|
13
|
-
|
14
|
-
function tokenBase(stream, state) {
|
15
|
-
var ch = stream.next();
|
16
|
-
|
17
|
-
if (ch == "@") {stream.eatWhile(/[\w\-]/); return ret("meta", stream.current());}
|
18
|
-
else if (ch == "/" && stream.eat("*")) {
|
19
|
-
state.tokenize = tokenCComment;
|
20
|
-
return tokenCComment(stream, state);
|
21
|
-
} else if (ch == "<" && stream.eat("!")) {
|
22
|
-
state.tokenize = tokenSGMLComment;
|
23
|
-
return tokenSGMLComment(stream, state);
|
24
|
-
} else if (ch == "=") ret(null, "compare");
|
25
|
-
else if (ch == "|" && stream.eat("=")) return ret(null, "compare");
|
26
|
-
else if (ch == "\"" || ch == "'") {
|
27
|
-
state.tokenize = tokenString(ch);
|
28
|
-
return state.tokenize(stream, state);
|
29
|
-
} else if (ch == "/") { // e.g.: .png will not be parsed as a class
|
30
|
-
if(stream.eat("/")){
|
31
|
-
state.tokenize = tokenSComment;
|
32
|
-
return tokenSComment(stream, state);
|
33
|
-
} else {
|
34
|
-
if(type == "string" || type == "(") return ret("string", "string");
|
35
|
-
if(state.stack[state.stack.length-1] !== undefined) return ret(null, ch);
|
36
|
-
stream.eatWhile(/[\a-zA-Z0-9\-_.\s]/);
|
37
|
-
if( /\/|\)|#/.test(stream.peek() || (stream.eatSpace() && stream.peek() === ")")) || stream.eol() )return ret("string", "string"); // let url(/images/logo.png) without quotes return as string
|
38
|
-
}
|
39
|
-
} else if (ch == "!") {
|
40
|
-
stream.match(/^\s*\w*/);
|
41
|
-
return ret("keyword", "important");
|
42
|
-
} else if (/\d/.test(ch)) {
|
43
|
-
stream.eatWhile(/[\w.%]/);
|
44
|
-
return ret("number", "unit");
|
45
|
-
} else if (/[,+<>*\/]/.test(ch)) {
|
46
|
-
if(stream.peek() == "=" || type == "a")return ret("string", "string");
|
47
|
-
if(ch === ",")return ret(null, ch);
|
48
|
-
return ret(null, "select-op");
|
49
|
-
} else if (/[;{}:\[\]()~\|]/.test(ch)) {
|
50
|
-
if(ch == ":"){
|
51
|
-
stream.eatWhile(/[a-z\\\-]/);
|
52
|
-
if( selectors.test(stream.current()) ){
|
53
|
-
return ret("tag", "tag");
|
54
|
-
} else if(stream.peek() == ":"){//::-webkit-search-decoration
|
55
|
-
stream.next();
|
56
|
-
stream.eatWhile(/[a-z\\\-]/);
|
57
|
-
if(stream.current().match(/\:\:\-(o|ms|moz|webkit)\-/))return ret("string", "string");
|
58
|
-
if( selectors.test(stream.current().substring(1)) )return ret("tag", "tag");
|
59
|
-
return ret(null, ch);
|
60
|
-
} else {
|
61
|
-
return ret(null, ch);
|
62
|
-
}
|
63
|
-
} else if(ch == "~"){
|
64
|
-
if(type == "r")return ret("string", "string");
|
65
|
-
} else {
|
66
|
-
return ret(null, ch);
|
67
|
-
}
|
68
|
-
} else if (ch == ".") {
|
69
|
-
if(type == "(")return ret("string", "string"); // allow url(../image.png)
|
70
|
-
stream.eatWhile(/[\a-zA-Z0-9\-_]/);
|
71
|
-
if(stream.peek() === " ")stream.eatSpace();
|
72
|
-
if(stream.peek() === ")" || type === ":")return ret("number", "unit");//rgba(0,0,0,.25);
|
73
|
-
else if(stream.current().length >1){
|
74
|
-
if(state.stack[state.stack.length-1] === "rule" && !stream.match(/^[{,+(]/, false)) return ret("number", "unit");
|
75
|
-
}
|
76
|
-
return ret("tag", "tag");
|
77
|
-
} else if (ch == "#") {
|
78
|
-
//we don't eat white-space, we want the hex color and or id only
|
79
|
-
stream.eatWhile(/[A-Za-z0-9]/);
|
80
|
-
//check if there is a proper hex color length e.g. #eee || #eeeEEE
|
81
|
-
if(stream.current().length == 4 || stream.current().length == 7){
|
82
|
-
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
|
83
|
-
//when not a valid hex value, parse as id
|
84
|
-
if(stream.current().substring(1) != stream.current().match(/[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/,false))return ret("atom", "tag");
|
85
|
-
//eat white-space
|
86
|
-
stream.eatSpace();
|
87
|
-
//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[;,]
|
88
|
-
if( /[\/<>.(){!$%^&*_\-\\?=+\|#'~`]/.test(stream.peek()) ){
|
89
|
-
if(type === "select-op")return ret("number", "unit"); else return ret("atom", "tag");
|
90
|
-
}
|
91
|
-
//#time { color: #aaa }
|
92
|
-
else if(stream.peek() == "}" )return ret("number", "unit");
|
93
|
-
//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
|
94
|
-
else if( /[a-zA-Z\\]/.test(stream.peek()) )return ret("atom", "tag");
|
95
|
-
//when a hex value is on the end of a line, parse as id
|
96
|
-
else if(stream.eol())return ret("atom", "tag");
|
97
|
-
//default
|
98
|
-
else return ret("number", "unit");
|
99
|
-
} else {//when not a valid hexvalue in the current stream e.g. #footer
|
100
|
-
stream.eatWhile(/[\w\\\-]/);
|
101
|
-
return ret("atom", stream.current());
|
102
|
-
}
|
103
|
-
} else {//when not a valid hexvalue length
|
104
|
-
stream.eatWhile(/[\w\\\-]/);
|
105
|
-
if(state.stack[state.stack.length-1] === "rule")return ret("atom", stream.current());return ret("atom", stream.current());
|
106
|
-
return ret("atom", "tag");
|
107
|
-
}
|
108
|
-
} else if (ch == "&") {
|
109
|
-
stream.eatWhile(/[\w\-]/);
|
110
|
-
return ret(null, ch);
|
111
|
-
} else {
|
112
|
-
stream.eatWhile(/[\w\\\-_%.{]/);
|
113
|
-
if(stream.current().match(/\\/) !== null){
|
114
|
-
if(stream.current().charAt(stream.current().length-1) === "\\"){
|
115
|
-
stream.eat(/\'|\"|\)|\(/);
|
116
|
-
while(stream.eatWhile(/[\w\\\-_%.{]/)){
|
117
|
-
stream.eat(/\'|\"|\)|\(/);
|
118
|
-
}
|
119
|
-
return ret("string", stream.current());
|
120
|
-
}
|
121
|
-
} //else if(type === "tag")return ret("tag", "tag");
|
122
|
-
else if(type == "string"){
|
123
|
-
if(state.stack[state.stack.length-1] === "{" && stream.peek() === ":")return ret("variable", "variable");
|
124
|
-
if(stream.peek() === "/")stream.eatWhile(/[\w\\\-_%.{:\/]/);
|
125
|
-
return ret(type, stream.current());
|
126
|
-
} else if(stream.current().match(/(^http$|^https$)/) != null){
|
127
|
-
stream.eatWhile(/[\w\\\-_%.{:\/]/);
|
128
|
-
if(stream.peek() === "/")stream.eatWhile(/[\w\\\-_%.{:\/]/);
|
129
|
-
return ret("string", "string");
|
130
|
-
} else if(stream.peek() == "<" || stream.peek() == ">" || stream.peek() == "+"){
|
131
|
-
if(type === "(" && (stream.current() === "n" || stream.current() === "-n"))return ret("string", stream.current());
|
132
|
-
return ret("tag", "tag");
|
133
|
-
} else if( /\(/.test(stream.peek()) ){
|
134
|
-
if(stream.current() === "when")return ret("variable","variable");
|
135
|
-
else if(state.stack[state.stack.length-1] === "@media" && stream.current() === "and")return ret("variable",stream.current());
|
136
|
-
return ret(null, ch);
|
137
|
-
} else if (stream.peek() == "/" && state.stack[state.stack.length-1] !== undefined){ // url(dir/center/image.png)
|
138
|
-
if(stream.peek() === "/")stream.eatWhile(/[\w\\\-_%.{:\/]/);
|
139
|
-
return ret("string", stream.current());
|
140
|
-
} else if( stream.current().match(/\-\d|\-.\d/) ){ // match e.g.: -5px -0.4 etc... only colorize the minus sign
|
141
|
-
//commment out these 2 comment if you want the minus sign to be parsed as null -500px
|
142
|
-
//stream.backUp(stream.current().length-1);
|
143
|
-
//return ret(null, ch);
|
144
|
-
return ret("number", "unit");
|
145
|
-
} else if( /\/|[\s\)]/.test(stream.peek() || stream.eol() || (stream.eatSpace() && stream.peek() == "/")) && stream.current().indexOf(".") !== -1){
|
146
|
-
if(stream.current().substring(stream.current().length-1,stream.current().length) == "{"){
|
147
|
-
stream.backUp(1);
|
148
|
-
return ret("tag", "tag");
|
149
|
-
}//end if
|
150
|
-
stream.eatSpace();
|
151
|
-
if( /[{<>.a-zA-Z\/]/.test(stream.peek()) || stream.eol() )return ret("tag", "tag"); // e.g. button.icon-plus
|
152
|
-
return ret("string", "string"); // let url(/images/logo.png) without quotes return as string
|
153
|
-
} else if( stream.eol() || stream.peek() == "[" || stream.peek() == "#" || type == "tag" ){
|
154
|
-
|
155
|
-
if(stream.current().substring(stream.current().length-1,stream.current().length) == "{")stream.backUp(1);
|
156
|
-
else if(state.stack[state.stack.length-1] === "border-color" || state.stack[state.stack.length-1] === "background-position" || state.stack[state.stack.length-1] === "font-family")return ret(null, stream.current());
|
157
|
-
else if(type === "tag")return ret("tag", "tag");
|
158
|
-
else if((type === ":" || type === "unit") && state.stack[state.stack.length-1] === "rule")return ret(null, stream.current());
|
159
|
-
else if(state.stack[state.stack.length-1] === "rule" && type === "tag")return ret("string", stream.current());
|
160
|
-
else if(state.stack[state.stack.length-1] === ";" && type === ":")return ret(null, stream.current());
|
161
|
-
//else if(state.stack[state.stack.length-1] === ";" || type === "")return ret("variable", stream.current());
|
162
|
-
else if(stream.peek() === "#" && type !== undefined && type.match(/\+|,|tag|select\-op|}|{|;/g) === null)return ret("string", stream.current());
|
163
|
-
else if(type === "variable")return ret(null, stream.current());
|
164
|
-
else if(state.stack[state.stack.length-1] === "{" && type === "comment")return ret("variable", stream.current());
|
165
|
-
else if(state.stack.length === 0 && (type === ";" || type === "comment"))return ret("tag", stream.current());
|
166
|
-
else if((state.stack[state.stack.length-1] === "{" || type === ";") && state.stack[state.stack.length-1] !== "@media{")return ret("variable", stream.current());
|
167
|
-
else if(state.stack[state.stack.length-2] === "{" && state.stack[state.stack.length-1] === ";")return ret("variable", stream.current());
|
168
|
-
|
169
|
-
return ret("tag", "tag");
|
170
|
-
} else if(type == "compare" || type == "a" || type == "("){
|
171
|
-
return ret("string", "string");
|
172
|
-
} else if(type == "|" || stream.current() == "-" || type == "["){
|
173
|
-
if (type == "|" && stream.match(/^[\]=~]/, false)) return ret("number", stream.current());
|
174
|
-
else if(type == "|" )return ret("tag", "tag");
|
175
|
-
else if(type == "["){
|
176
|
-
stream.eatWhile(/\w\-/);
|
177
|
-
return ret("number", stream.current());
|
178
|
-
}
|
179
|
-
return ret(null, ch);
|
180
|
-
} else if((stream.peek() == ":") || ( stream.eatSpace() && stream.peek() == ":")) {
|
181
|
-
stream.next();
|
182
|
-
var t_v = stream.peek() == ":" ? true : false;
|
183
|
-
if(!t_v){
|
184
|
-
var old_pos = stream.pos;
|
185
|
-
var sc = stream.current().length;
|
186
|
-
stream.eatWhile(/[a-z\\\-]/);
|
187
|
-
var new_pos = stream.pos;
|
188
|
-
if(stream.current().substring(sc-1).match(selectors) != null){
|
189
|
-
stream.backUp(new_pos-(old_pos-1));
|
190
|
-
return ret("tag", "tag");
|
191
|
-
} else stream.backUp(new_pos-(old_pos-1));
|
192
|
-
} else {
|
193
|
-
stream.backUp(1);
|
194
|
-
}
|
195
|
-
if(t_v)return ret("tag", "tag"); else return ret("variable", "variable");
|
196
|
-
} else if(state.stack[state.stack.length-1] === "font-family" || state.stack[state.stack.length-1] === "background-position" || state.stack[state.stack.length-1] === "border-color"){
|
197
|
-
return ret(null, null);
|
198
|
-
} else {
|
199
|
-
|
200
|
-
if(state.stack[state.stack.length-1] === null && type === ":")return ret(null, stream.current());
|
201
|
-
|
202
|
-
//else if((type === ")" && state.stack[state.stack.length-1] === "rule") || (state.stack[state.stack.length-2] === "{" && state.stack[state.stack.length-1] === "rule" && type === "variable"))return ret(null, stream.current());
|
203
|
-
|
204
|
-
else if (/\^|\$/.test(stream.current()) && stream.match(/^[~=]/, false)) return ret("string", "string");//att^=val
|
205
|
-
|
206
|
-
else if(type === "unit" && state.stack[state.stack.length-1] === "rule")return ret(null, "unit");
|
207
|
-
else if(type === "unit" && state.stack[state.stack.length-1] === ";")return ret(null, "unit");
|
208
|
-
else if(type === ")" && state.stack[state.stack.length-1] === "rule")return ret(null, "unit");
|
209
|
-
else if(type && type.match("@") !== null && state.stack[state.stack.length-1] === "rule")return ret(null, "unit");
|
210
|
-
//else if(type === "unit" && state.stack[state.stack.length-1] === "rule")return ret(null, stream.current());
|
211
|
-
|
212
|
-
else if((type === ";" || type === "}" || type === ",") && state.stack[state.stack.length-1] === ";")return ret("tag", stream.current());
|
213
|
-
else if((type === ";" && stream.peek() !== undefined && !stream.match(/^[{\.]/, false)) ||
|
214
|
-
(type === ";" && stream.eatSpace() && !stream.match(/^[{\.]/))) return ret("variable", stream.current());
|
215
|
-
else if((type === "@media" && state.stack[state.stack.length-1] === "@media") || type === "@namespace")return ret("tag", stream.current());
|
216
|
-
|
217
|
-
else if(type === "{" && state.stack[state.stack.length-1] === ";" && stream.peek() === "{")return ret("tag", "tag");
|
218
|
-
else if((type === "{" || type === ":") && state.stack[state.stack.length-1] === ";")return ret(null, stream.current());
|
219
|
-
else if((state.stack[state.stack.length-1] === "{" && stream.eatSpace() && !stream.match(/^[\.#]/)) || type === "select-op" || (state.stack[state.stack.length-1] === "rule" && type === ",") )return ret("tag", "tag");
|
220
|
-
else if(type === "variable" && state.stack[state.stack.length-1] === "rule")return ret("tag", "tag");
|
221
|
-
else if((stream.eatSpace() && stream.peek() === "{") || stream.eol() || stream.peek() === "{")return ret("tag", "tag");
|
222
|
-
//this one messes up indentation
|
223
|
-
//else if((type === "}" && stream.peek() !== ":") || (type === "}" && stream.eatSpace() && stream.peek() !== ":"))return(type, "tag");
|
224
|
-
|
225
|
-
else if(type === ")" && (stream.current() == "and" || stream.current() == "and "))return ret("variable", "variable");
|
226
|
-
else if(type === ")" && (stream.current() == "when" || stream.current() == "when "))return ret("variable", "variable");
|
227
|
-
else if(type === ")" || type === "comment" || type === "{")return ret("tag", "tag");
|
228
|
-
else if(stream.sol())return ret("tag", "tag");
|
229
|
-
else if((stream.eatSpace() && stream.peek() === "#") || stream.peek() === "#")return ret("tag", "tag");
|
230
|
-
else if(state.stack.length === 0)return ret("tag", "tag");
|
231
|
-
else if(type === ";" && stream.peek() !== undefined && stream.match(/^[\.|#]/g)) return ret("tag", "tag");
|
232
|
-
|
233
|
-
else if(type === ":"){stream.eatSpace();return ret(null, stream.current());}
|
234
|
-
|
235
|
-
else if(stream.current() === "and " || stream.current() === "and")return ret("variable", stream.current());
|
236
|
-
else if(type === ";" && state.stack[state.stack.length-1] === "{")return ret("variable", stream.current());
|
237
|
-
|
238
|
-
else if(state.stack[state.stack.length-1] === "rule")return ret(null, stream.current());
|
239
|
-
|
240
|
-
return ret("tag", stream.current());
|
241
|
-
}
|
242
|
-
}
|
243
|
-
}
|
244
|
-
|
245
|
-
function tokenSComment(stream, state) { // SComment = Slash comment
|
246
|
-
stream.skipToEnd();
|
247
|
-
state.tokenize = tokenBase;
|
248
|
-
return ret("comment", "comment");
|
249
|
-
}
|
250
|
-
|
251
|
-
function tokenCComment(stream, state) {
|
252
|
-
var maybeEnd = false, ch;
|
253
|
-
while ((ch = stream.next()) != null) {
|
254
|
-
if (maybeEnd && ch == "/") {
|
255
|
-
state.tokenize = tokenBase;
|
256
|
-
break;
|
257
|
-
}
|
258
|
-
maybeEnd = (ch == "*");
|
259
|
-
}
|
260
|
-
return ret("comment", "comment");
|
261
|
-
}
|
262
|
-
|
263
|
-
function tokenSGMLComment(stream, state) {
|
264
|
-
var dashes = 0, ch;
|
265
|
-
while ((ch = stream.next()) != null) {
|
266
|
-
if (dashes >= 2 && ch == ">") {
|
267
|
-
state.tokenize = tokenBase;
|
268
|
-
break;
|
269
|
-
}
|
270
|
-
dashes = (ch == "-") ? dashes + 1 : 0;
|
271
|
-
}
|
272
|
-
return ret("comment", "comment");
|
273
|
-
}
|
274
|
-
|
275
|
-
function tokenString(quote) {
|
276
|
-
return function(stream, state) {
|
277
|
-
var escaped = false, ch;
|
278
|
-
while ((ch = stream.next()) != null) {
|
279
|
-
if (ch == quote && !escaped)
|
280
|
-
break;
|
281
|
-
escaped = !escaped && ch == "\\";
|
282
|
-
}
|
283
|
-
if (!escaped) state.tokenize = tokenBase;
|
284
|
-
return ret("string", "string");
|
285
|
-
};
|
286
|
-
}
|
287
|
-
|
288
|
-
return {
|
289
|
-
startState: function(base) {
|
290
|
-
return {tokenize: tokenBase,
|
291
|
-
baseIndent: base || 0,
|
292
|
-
stack: []};
|
293
|
-
},
|
294
|
-
|
295
|
-
token: function(stream, state) {
|
296
|
-
if (stream.eatSpace()) return null;
|
297
|
-
var style = state.tokenize(stream, state);
|
298
|
-
|
299
|
-
var context = state.stack[state.stack.length-1];
|
300
|
-
if (type == "hash" && context == "rule") style = "atom";
|
301
|
-
else if (style == "variable") {
|
302
|
-
if (context == "rule") style = null; //"tag"
|
303
|
-
else if (!context || context == "@media{") {
|
304
|
-
style = stream.current() == "when" ? "variable" :
|
305
|
-
/[\s,|\s\)|\s]/.test(stream.peek()) ? "tag" : type;
|
306
|
-
}
|
307
|
-
}
|
308
|
-
|
309
|
-
if (context == "rule" && /^[\{\};]$/.test(type))
|
310
|
-
state.stack.pop();
|
311
|
-
if (type == "{") {
|
312
|
-
if (context == "@media") state.stack[state.stack.length-1] = "@media{";
|
313
|
-
else state.stack.push("{");
|
314
|
-
}
|
315
|
-
else if (type == "}") state.stack.pop();
|
316
|
-
else if (type == "@media") state.stack.push("@media");
|
317
|
-
else if (stream.current() === "font-family") state.stack[state.stack.length-1] = "font-family";
|
318
|
-
else if (stream.current() === "background-position") state.stack[state.stack.length-1] = "background-position";
|
319
|
-
else if (stream.current() === "border-color") state.stack[state.stack.length-1] = "border-color";
|
320
|
-
else if (context == "{" && type != "comment" && type !== "tag") state.stack.push("rule");
|
321
|
-
else if (stream.peek() === ":" && stream.current().match(/@|#/) === null) style = type;
|
322
|
-
if(type === ";" && (state.stack[state.stack.length-1] == "font-family" || state.stack[state.stack.length-1] == "background-position" || state.stack[state.stack.length-1] == "border-color"))state.stack[state.stack.length-1] = stream.current();
|
323
|
-
else if(type === "tag" && stream.peek() === ")" && stream.current().match(/\:/) === null){type = null; style = null;}
|
324
|
-
// ????
|
325
|
-
else if((type === "variable" && stream.peek() === ")") || (type === "variable" && stream.eatSpace() && stream.peek() === ")"))return ret(null,stream.current());
|
326
|
-
return style;
|
327
|
-
},
|
328
|
-
|
329
|
-
indent: function(state, textAfter) {
|
330
|
-
var n = state.stack.length;
|
331
|
-
if (/^\}/.test(textAfter))
|
332
|
-
n -= state.stack[state.stack.length-1] === "rule" ? 2 : 1;
|
333
|
-
else if (state.stack[state.stack.length-2] === "{")
|
334
|
-
n -= state.stack[state.stack.length-1] === "rule" ? 1 : 0;
|
335
|
-
return state.baseIndent + n * indentUnit;
|
336
|
-
},
|
337
|
-
|
338
|
-
electricChars: "}",
|
339
|
-
blockCommentStart: "/*",
|
340
|
-
blockCommentEnd: "*/",
|
341
|
-
lineComment: "//"
|
342
|
-
};
|
343
|
-
});
|
344
|
-
|
345
|
-
CodeMirror.defineMIME("text/x-less", "less");
|
346
|
-
if (!CodeMirror.mimeModes.hasOwnProperty("text/css"))
|
347
|
-
CodeMirror.defineMIME("text/css", "less");
|