diff options
author | Jonathan Duran | 2012-07-17 11:42:09 -0700 |
---|---|---|
committer | Jonathan Duran | 2012-07-17 11:42:09 -0700 |
commit | b4b3e45d6684e77d361b4f8ca5be4889428320c5 (patch) | |
tree | 2156d9920ea1b7db49ed6460545fea7cda121bae /imports/codemirror/mode/less/less.js | |
parent | 4a87ff575693509ac578d46af26fa137c0dc3f58 (diff) | |
parent | 4f737b24c19ddc02d20f9783b8b080fc6ef11142 (diff) | |
download | ninja-b4b3e45d6684e77d361b4f8ca5be4889428320c5.tar.gz |
Merge branch 'refs/heads/NINJA-master' into TimelineUber
Diffstat (limited to 'imports/codemirror/mode/less/less.js')
-rw-r--r-- | imports/codemirror/mode/less/less.js | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/imports/codemirror/mode/less/less.js b/imports/codemirror/mode/less/less.js index 1c20bd81..51163890 100644 --- a/imports/codemirror/mode/less/less.js +++ b/imports/codemirror/mode/less/less.js | |||
@@ -3,7 +3,7 @@ LESS mode - http://www.lesscss.org/ | |||
3 | Ported to CodeMirror by Peter Kroon | 3 | Ported to CodeMirror by Peter Kroon |
4 | */ | 4 | */ |
5 | 5 | ||
6 | CodeMirror.defineMode("css", function(config) { | 6 | CodeMirror.defineMode("less", function(config) { |
7 | var indentUnit = config.indentUnit, type; | 7 | var indentUnit = config.indentUnit, type; |
8 | function ret(style, tp) {type = tp; return style;} | 8 | function ret(style, tp) {type = tp; return style;} |
9 | //html5 tags | 9 | //html5 tags |
@@ -41,7 +41,7 @@ CodeMirror.defineMode("css", function(config) { | |||
41 | return tokenSComment(stream, state); | 41 | return tokenSComment(stream, state); |
42 | }else{ | 42 | }else{ |
43 | stream.eatWhile(/[\a-zA-Z0-9\-_.\s]/); | 43 | stream.eatWhile(/[\a-zA-Z0-9\-_.\s]/); |
44 | if(/\/|\)/.test(stream.peek() || stream.eol() || (stream.eatSpace() && stream.peek() == ")")))return ret("string", "string");//let url(/images/logo.png) without quotes return as string | 44 | if(/\/|\)|#/.test(stream.peek() || stream.eol() || (stream.eatSpace() && stream.peek() == ")")))return ret("string", "string");//let url(/images/logo.png) without quotes return as string |
45 | return ret("number", "unit"); | 45 | return ret("number", "unit"); |
46 | } | 46 | } |
47 | } | 47 | } |
@@ -105,21 +105,33 @@ CodeMirror.defineMode("css", function(config) { | |||
105 | stream.eatWhile(/[\w\-]/); | 105 | stream.eatWhile(/[\w\-]/); |
106 | return ret(null, ch); | 106 | return ret(null, ch); |
107 | } | 107 | } |
108 | else if (ch == "&") { | ||
109 | stream.eatWhile(/[\w\-]/); | ||
110 | return ret(null, ch); | ||
111 | } | ||
112 | else { | 108 | else { |
113 | stream.eatWhile(/[\w\\\-_.%]/); | 109 | stream.eatWhile(/[\w\\\-_%.{]/); |
114 | if( stream.peek().match(/\(/) != null ){// lesscss | 110 | if(stream.current().match(/http|https/) != null){ |
115 | stream.eatWhile(/[a-zA-Z\s]/); | 111 | stream.eatWhile(/[\w\\\-_%.{:\/]/); |
116 | if(stream.peek() == "(")return ret(null, ch); | 112 | return ret("string", "string"); |
117 | }else if( stream.current().match(/\-\d|\-.\d/) ){ // lesscss match e.g.: -5px -0.4 etc... | 113 | }else if(stream.peek() == "<" || stream.peek() == ">"){ |
118 | return ret("number", "unit"); | 114 | return ret("tag", "tag"); |
115 | }else if( stream.peek().match(/\(/) != null ){// lessc | ||
116 | return ret(null, ch); | ||
117 | }else if (stream.peek() == "/" && state.stack[state.stack.length-1] != undefined){ // url(dir/center/image.png) | ||
118 | return ret("string", "string"); | ||
119 | }else if( stream.current().match(/\-\d|\-.\d/) ){ // lesscss match e.g.: -5px -0.4 etc... only colorize the minus sign | ||
120 | //stream.backUp(stream.current().length-1); //commment out these 2 comment if you want the minus sign to be parsed as null -500px | ||
121 | //return ret(null, ch); | ||
122 | return ret("number", "unit"); | ||
119 | }else if( inTagsArray(stream.current()) ){ // lesscss match html tags | 123 | }else if( inTagsArray(stream.current()) ){ // lesscss match html tags |
120 | return ret("tag", "tag"); | 124 | return ret("tag", "tag"); |
121 | }else if( /\/|\)/.test(stream.peek() || stream.eol() || (stream.eatSpace() && stream.peek() == ")")) && stream.current().indexOf(".") !== -1){ | 125 | }else if( /\/|[\s\)]/.test(stream.peek() || stream.eol() || (stream.eatSpace() && stream.peek() == "/")) && stream.current().indexOf(".") !== -1){ |
126 | if(stream.current().substring(stream.current().length-1,stream.current().length) == "{"){ | ||
127 | stream.backUp(1); | ||
128 | return ret("tag", "tag"); | ||
129 | }//end if | ||
130 | if( (stream.eatSpace() && stream.peek().match(/[{<>.a-zA-Z]/) != null) || stream.eol() )return ret("tag", "tag");//e.g. button.icon-plus | ||
122 | return ret("string", "string");//let url(/images/logo.png) without quotes return as string | 131 | return ret("string", "string");//let url(/images/logo.png) without quotes return as string |
132 | }else if( stream.eol() ){ | ||
133 | if(stream.current().substring(stream.current().length-1,stream.current().length) == "{")stream.backUp(1); | ||
134 | return ret("tag", "tag"); | ||
123 | }else{ | 135 | }else{ |
124 | return ret("variable", "variable"); | 136 | return ret("variable", "variable"); |
125 | } | 137 | } |
@@ -215,4 +227,6 @@ CodeMirror.defineMode("css", function(config) { | |||
215 | }; | 227 | }; |
216 | }); | 228 | }); |
217 | 229 | ||
218 | CodeMirror.defineMIME("text/css", "css"); | 230 | CodeMirror.defineMIME("text/x-less", "less"); |
231 | if (!CodeMirror.mimeModes.hasOwnProperty("text/css")) | ||
232 | CodeMirror.defineMIME("text/css", "less"); | ||