aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/less/less.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-07-17 11:28:39 -0700
committerValerio Virgillito2012-07-17 11:28:39 -0700
commit4f737b24c19ddc02d20f9783b8b080fc6ef11142 (patch)
tree212d164c0f83d80394e34f1df532ea0461ad328d /imports/codemirror/mode/less/less.js
parent5146f224258929415adf4a8022e492454b4e2476 (diff)
parent0e04fff0ea80fa5cbe96b8354db38bd334aea83a (diff)
downloadninja-4f737b24c19ddc02d20f9783b8b080fc6ef11142.tar.gz
Merge pull request #396 from ananyasen/codemirror2.3-upgrade
upgrade to codemirror 2.3
Diffstat (limited to 'imports/codemirror/mode/less/less.js')
-rw-r--r--imports/codemirror/mode/less/less.js42
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/
3Ported to CodeMirror by Peter Kroon 3Ported to CodeMirror by Peter Kroon
4*/ 4*/
5 5
6CodeMirror.defineMode("css", function(config) { 6CodeMirror.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
218CodeMirror.defineMIME("text/css", "css"); 230CodeMirror.defineMIME("text/x-less", "less");
231if (!CodeMirror.mimeModes.hasOwnProperty("text/css"))
232 CodeMirror.defineMIME("text/css", "less");