mirror of https://github.com/gorhill/uBlock.git
fine tuning codemirror styles
This commit is contained in:
parent
273c80564a
commit
8680bbc086
|
@ -8,3 +8,7 @@
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
.cm-s-default .cm-comment {color: #777;}
|
||||||
|
.cm-staticext {color: #008;}
|
||||||
|
.cm-staticnet.cm-block {color: #800;}
|
||||||
|
.cm-staticnet.cm-allow {color: #060;}
|
||||||
|
|
|
@ -24,26 +24,29 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
CodeMirror.defineMode("ubo-static-filtering", function() {
|
CodeMirror.defineMode("ubo-static-filtering", function() {
|
||||||
|
var reNotSpace = /\S/;
|
||||||
|
var reComment = /^(?:!|#[^#@]|#@[^#])/;
|
||||||
|
var reExt = /^[^#]*#(?:#[^#]|##[^#]|@#)/;
|
||||||
|
var reNetAllow = /^@@/;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
token: function(stream) {
|
token: function(stream) {
|
||||||
if ( stream.sol() === false ) {
|
var style = null;
|
||||||
return null;
|
var pos = stream.string.search(reNotSpace);
|
||||||
}
|
if ( pos !== -1 ) {
|
||||||
stream.eatSpace();
|
var s = stream.string.slice(pos);
|
||||||
var c = stream.next();
|
if ( reComment.test(s) ) {
|
||||||
if ( c === '!' ) {
|
style = 'comment';
|
||||||
stream.skipToEnd();
|
} else if ( reExt.test(s) ) {
|
||||||
return 'comment';
|
style = 'staticext';
|
||||||
}
|
} else if ( reNetAllow.test(s) ) {
|
||||||
if ( c === '#' ) {
|
style = 'staticnet allow';
|
||||||
c = stream.next();
|
} else {
|
||||||
if ( c !== '#' && c !== '@' ) {
|
style = 'staticnet block';
|
||||||
stream.skipToEnd();
|
|
||||||
return 'comment';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stream.skipToEnd();
|
stream.skipToEnd();
|
||||||
return null;
|
return style;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue