Skip to content

Commit

Permalink
Remove tabs and trailing whitespace in a few modes
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephPecoraro committed Mar 28, 2013
1 parent 56def7d commit 36141fe
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
46 changes: 23 additions & 23 deletions mode/less/less.js
Expand Up @@ -41,7 +41,7 @@ CodeMirror.defineMode("less", function(config) {
}else{
if(type == "string" || type == "(")return ret("string", "string");
if(state.stack[state.stack.length-1] != undefined)return ret(null, ch);
stream.eatWhile(/[\a-zA-Z0-9\-_.\s]/);
stream.eatWhile(/[\a-zA-Z0-9\-_.\s]/);
if( /\/|\)|#/.test(stream.peek() || (stream.eatSpace() && stream.peek() == ")")) || stream.eol() )return ret("string", "string"); // let url(/images/logo.png) without quotes return as string
}
}
Expand All @@ -58,7 +58,7 @@ CodeMirror.defineMode("less", function(config) {
return ret(null, "select-op");
}
else if (/[;{}:\[\]()~\|]/.test(ch)) {
if(ch == ":"){
if(ch == ":"){
stream.eatWhile(/[a-z\\\-]/);
if( selectors.test(stream.current()) ){
return ret("tag", "tag");
Expand All @@ -69,15 +69,15 @@ CodeMirror.defineMode("less", function(config) {
if( selectors.test(stream.current().substring(1)) )return ret("tag", "tag");
return ret(null, ch);
}else{
return ret(null, ch);
return ret(null, ch);
}
}else if(ch == "~"){
if(type == "r")return ret("string", "string");
}else{
return ret(null, ch);
}
}
else if (ch == ".") {
else if (ch == ".") {
if(type == "(" || type == "string")return ret("string", "string"); // allow url(../image.png)
stream.eatWhile(/[\a-zA-Z0-9\-_]/);
if(stream.peek() == " ")stream.eatSpace();
Expand Down Expand Up @@ -106,7 +106,7 @@ CodeMirror.defineMode("less", function(config) {
else return ret("number", "unit");
}else{//when not a valid hexvalue in the current stream e.g. #footer
stream.eatWhile(/[\w\\\-]/);
return ret("atom", "tag");
return ret("atom", "tag");
}
}else{//when not a valid hexvalue length
stream.eatWhile(/[\w\\\-]/);
Expand All @@ -126,14 +126,14 @@ CodeMirror.defineMode("less", function(config) {
return ret("string", "string");
}else if(stream.peek() == "<" || stream.peek() == ">"){
return ret("tag", "tag");
}else if( /\(/.test(stream.peek()) ){
}else if( /\(/.test(stream.peek()) ){
return ret(null, ch);
}else if (stream.peek() == "/" && state.stack[state.stack.length-1] != undefined){ // url(dir/center/image.png)
return ret("string", "string");
}else if( stream.current().match(/\-\d|\-.\d/) ){ // match e.g.: -5px -0.4 etc... only colorize the minus sign
//commment out these 2 comment if you want the minus sign to be parsed as null -500px
//stream.backUp(stream.current().length-1);
//return ret(null, ch); //console.log( stream.current() );
//return ret(null, ch); //console.log( stream.current() );
return ret("number", "unit");
}else if( inTagsArray(stream.current().toLowerCase()) ){ // match html tags
return ret("tag", "tag");
Expand All @@ -156,22 +156,22 @@ CodeMirror.defineMode("less", function(config) {
stream.next();
var t_v = stream.peek() == ":" ? true : false;
if(!t_v){
var old_pos = stream.pos;
var sc = stream.current().length;
stream.eatWhile(/[a-z\\\-]/);
var new_pos = stream.pos;
if(stream.current().substring(sc-1).match(selectors) != null){
stream.backUp(new_pos-(old_pos-1));
return ret("tag", "tag");
} else stream.backUp(new_pos-(old_pos-1));
}else{
stream.backUp(1);
}
if(t_v)return ret("tag", "tag"); else return ret("variable", "variable");
}else{
return ret("variable", "variable");
var old_pos = stream.pos;
var sc = stream.current().length;
stream.eatWhile(/[a-z\\\-]/);
var new_pos = stream.pos;
if(stream.current().substring(sc-1).match(selectors) != null){
stream.backUp(new_pos-(old_pos-1));
return ret("tag", "tag");
} else stream.backUp(new_pos-(old_pos-1));
}else{
stream.backUp(1);
}
if(t_v)return ret("tag", "tag"); else return ret("variable", "variable");
}else{
return ret("variable", "variable");
}
}
}
}

function tokenSComment(stream, state) { // SComment = Slash comment
Expand Down Expand Up @@ -218,7 +218,7 @@ CodeMirror.defineMode("less", function(config) {
}

return {
startState: function(base) {
startState: function(base) {
return {tokenize: tokenBase,
baseIndent: base || 0,
stack: []};
Expand Down
36 changes: 18 additions & 18 deletions mode/sql/sql.js
Expand Up @@ -20,11 +20,11 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
}

if ((ch == "0" && stream.match(/^[xX][0-9a-fA-F]+/))
|| (ch == "x" || ch == "X") && stream.match(/^'[0-9a-fA-F]+'/)) {
|| (ch == "x" || ch == "X") && stream.match(/^'[0-9a-fA-F]+'/)) {
// hex
return "number";
} else if (((ch == "b" || ch == "B") && stream.match(/^'[01]+'/))
|| (ch == "0" && stream.match(/^b[01]+/))) {
|| (ch == "0" && stream.match(/^b[01]+/))) {
// bitstring
return "number";
} else if (ch.charCodeAt(0) > 47 && ch.charCodeAt(0) < 58) {
Expand All @@ -43,7 +43,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
return null;
} else if (ch == "#" || (ch == "-" && stream.eat("-") && stream.eat(" "))) {
// 1-line comments
stream.skipToEnd();
stream.skipToEnd();
return "comment";
} else if (ch == "/" && stream.eat("*")) {
// multi-line comments
Expand Down Expand Up @@ -85,26 +85,26 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
return function(stream, state) {
var escaped = false, ch;
while ((ch = stream.next()) != null) {
if (ch == quote && !escaped) {
state.tokenize = tokenBase;
break;
}
escaped = !escaped && ch == "\\";
if (ch == quote && !escaped) {
state.tokenize = tokenBase;
break;
}
escaped = !escaped && ch == "\\";
}
return "string";
};
}
function tokenComment(stream, state) {
while (true) {
if (stream.skipTo("*")) {
stream.next();
if (stream.eat("/")) {
state.tokenize = tokenBase;
break;
}
stream.next();
if (stream.eat("/")) {
state.tokenize = tokenBase;
break;
}
} else {
stream.skipToEnd();
break;
stream.skipToEnd();
break;
}
}
return "comment";
Expand All @@ -131,16 +131,16 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {

token: function(stream, state) {
if (stream.sol()) {
if (state.context && state.context.align == null)
state.context.align = false;
if (state.context && state.context.align == null)
state.context.align = false;
}
if (stream.eatSpace()) return null;

var style = state.tokenize(stream, state);
if (style == "comment") return style;

if (state.context && state.context.align == null)
state.context.align = true;
state.context.align = true;

var tok = stream.current();
if (tok == "(")
Expand Down

0 comments on commit 36141fe

Please sign in to comment.