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%;
|
||||
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';
|
||||
|
||||
CodeMirror.defineMode("ubo-static-filtering", function() {
|
||||
var reNotSpace = /\S/;
|
||||
var reComment = /^(?:!|#[^#@]|#@[^#])/;
|
||||
var reExt = /^[^#]*#(?:#[^#]|##[^#]|@#)/;
|
||||
var reNetAllow = /^@@/;
|
||||
|
||||
return {
|
||||
token: function(stream) {
|
||||
if ( stream.sol() === false ) {
|
||||
return null;
|
||||
}
|
||||
stream.eatSpace();
|
||||
var c = stream.next();
|
||||
if ( c === '!' ) {
|
||||
stream.skipToEnd();
|
||||
return 'comment';
|
||||
}
|
||||
if ( c === '#' ) {
|
||||
c = stream.next();
|
||||
if ( c !== '#' && c !== '@' ) {
|
||||
stream.skipToEnd();
|
||||
return 'comment';
|
||||
var style = null;
|
||||
var pos = stream.string.search(reNotSpace);
|
||||
if ( pos !== -1 ) {
|
||||
var s = stream.string.slice(pos);
|
||||
if ( reComment.test(s) ) {
|
||||
style = 'comment';
|
||||
} else if ( reExt.test(s) ) {
|
||||
style = 'staticext';
|
||||
} else if ( reNetAllow.test(s) ) {
|
||||
style = 'staticnet allow';
|
||||
} else {
|
||||
style = 'staticnet block';
|
||||
}
|
||||
}
|
||||
stream.skipToEnd();
|
||||
return null;
|
||||
return style;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue