restore syntax highlight
This commit is contained in:
parent
467b7f0aa4
commit
9035bbb0ab
|
@ -7,13 +7,15 @@
|
|||
|
||||
Mime::Type.register "text/plain", 'diff'
|
||||
Mime::Type.register "text/plain", 'patch'
|
||||
#Mime::Type.register "text/x-markdown", 'md'
|
||||
|
||||
# add rpm spec as mime type for *.spec files
|
||||
[["text/x-python", ['py'], '8bit'],
|
||||
["text/x-rpm-spec", ['spec'], '8bit'],
|
||||
["text/x-csrc", ['h', 'c'], '8bit'],
|
||||
["text/x-c++src", ['cpp'], '8bit'],
|
||||
["text/x-diff", ['diff'], '8bit']
|
||||
["text/x-diff", ['diff'], '8bit'],
|
||||
["text/x-markdown", ['md'], '8bit']
|
||||
].each do |type|
|
||||
MIME::Types.add MIME::Type.from_array(type)
|
||||
end
|
||||
|
|
|
@ -176,14 +176,14 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
return "string";
|
||||
}
|
||||
|
||||
CodeMirror.defineMIME("text/x-csrc", {
|
||||
CodeMirror.defineMIME("application/x-csrc", {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords),
|
||||
blockKeywords: words("case do else for if switch while struct"),
|
||||
atoms: words("null"),
|
||||
hooks: {"#": cppHook}
|
||||
});
|
||||
CodeMirror.defineMIME("text/x-c++src", {
|
||||
CodeMirror.defineMIME("application/x-c++src", {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
|
||||
"static_cast typeid catch operator template typename class friend private " +
|
||||
|
@ -193,7 +193,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
atoms: words("true false null"),
|
||||
hooks: {"#": cppHook}
|
||||
});
|
||||
CodeMirror.defineMIME("text/x-java", {
|
||||
CodeMirror.defineMIME("application/x-java", {
|
||||
name: "clike",
|
||||
keywords: words("abstract assert boolean break byte case catch char class const continue default " +
|
||||
"do double else enum extends final finally float for goto if implements import " +
|
||||
|
@ -209,7 +209,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
}
|
||||
}
|
||||
});
|
||||
CodeMirror.defineMIME("text/x-csharp", {
|
||||
CodeMirror.defineMIME("application/x-csharp", {
|
||||
name: "clike",
|
||||
keywords: words("abstract as base bool break byte case catch char checked class const continue decimal" +
|
||||
" default delegate do double else enum event explicit extern finally fixed float for" +
|
||||
|
|
|
@ -205,3 +205,4 @@ CodeMirror.defineMode("clojure", function (config, mode) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-clojure", "clojure");
|
||||
CodeMirror.defineMIME("application/x-clojure", "clojure");
|
||||
|
|
|
@ -339,3 +339,4 @@ CodeMirror.defineMode('coffeescript', function(conf) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME('text/x-coffeescript', 'coffeescript');
|
||||
CodeMirror.defineMIME('application/x-coffeescript', 'coffeescript');
|
||||
|
|
|
@ -122,3 +122,4 @@ CodeMirror.defineMode("css", function(config) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/css", "css");
|
||||
CodeMirror.defineMIME('application/x-coffeescript', 'css');
|
|
@ -11,3 +11,4 @@ CodeMirror.defineMode("diff", function() {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-diff", "diff");
|
||||
CodeMirror.defineMIME("application/x-diff", "diff");
|
||||
|
|
|
@ -170,3 +170,4 @@ CodeMirror.defineMode("go", function(config, parserConfig) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-go", "go");
|
||||
CodeMirror.defineMIME("application/x-go", "go");
|
||||
|
|
|
@ -208,3 +208,4 @@ CodeMirror.defineMode("groovy", function(config, parserConfig) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-groovy", "groovy");
|
||||
CodeMirror.defineMIME("application/x-groovy", "groovy");
|
||||
|
|
|
@ -240,3 +240,4 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-haskell", "haskell");
|
||||
CodeMirror.defineMIME("application/x-haskell", "haskell");
|
||||
|
|
|
@ -81,3 +81,4 @@ CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/html", "htmlmixed");
|
||||
CodeMirror.defineMIME("application/html", "htmlmixed");
|
||||
|
|
|
@ -357,4 +357,5 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/javascript", "javascript");
|
||||
CodeMirror.defineMIME("application/javascript", "javascript");
|
||||
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
|
||||
|
|
|
@ -138,3 +138,4 @@ CodeMirror.defineMode("lua", function(config, parserConfig) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-lua", "lua");
|
||||
CodeMirror.defineMIME("application/x-lua", "lua");
|
||||
|
|
|
@ -240,3 +240,4 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-markdown", "markdown");
|
||||
CodeMirror.defineMIME("application/x-markdown", "markdown");
|
||||
|
|
|
@ -186,3 +186,4 @@ CodeMirror.defineMode("mysql", function(config) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-mysql", "mysql");
|
||||
CodeMirror.defineMIME("application/x-mysql", "mysql");
|
||||
|
|
|
@ -136,3 +136,4 @@ CodeMirror.defineMode("pascal", function(config) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-pascal", "pascal");
|
||||
CodeMirror.defineMIME("application/x-pascal", "pascal");
|
||||
|
|
|
@ -778,6 +778,7 @@ CodeMirror.defineMode("perl",function(config,parserConfig){
|
|||
electricChars:"{}"}});
|
||||
|
||||
CodeMirror.defineMIME("text/x-perl", "perl");
|
||||
CodeMirror.defineMIME("application/x-perl", "perl");
|
||||
|
||||
// it's like "peek", but need for look-ahead or look-behind if index < 0
|
||||
CodeMirror.StringStream.prototype.look=function(c){
|
||||
|
|
|
@ -118,4 +118,5 @@
|
|||
CodeMirror.defineMIME("application/x-httpd-php", "php");
|
||||
CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
|
||||
CodeMirror.defineMIME("text/x-php", phpConfig);
|
||||
CodeMirror.defineMIME("application/x-php", phpConfig);
|
||||
})();
|
||||
|
|
|
@ -207,7 +207,7 @@ CodeMirror.defineMode("plsql", function(config, parserConfig) {
|
|||
"verify version " +
|
||||
"wrap";
|
||||
|
||||
CodeMirror.defineMIME("text/x-plsql", {
|
||||
CodeMirror.defineMIME("application/x-plsql", {
|
||||
name: "plsql",
|
||||
keywords: keywords(cKeywords),
|
||||
functions: keywords(cFunctions),
|
||||
|
|
|
@ -338,3 +338,4 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-python", "python");
|
||||
CodeMirror.defineMIME("application/x-python", "python");
|
||||
|
|
|
@ -139,3 +139,4 @@ CodeMirror.defineMode("r", function(config) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-rsrc", "r");
|
||||
CodeMirror.defineMIME("application/x-rsrc", "r");
|
||||
|
|
|
@ -17,3 +17,4 @@ CodeMirror.defineMode("changes", function(config, modeConfig) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-rpm-changes", "changes");
|
||||
CodeMirror.defineMIME("application/x-rpm-changes", "changes");
|
||||
|
|
|
@ -64,3 +64,4 @@ CodeMirror.defineMode("spec", function(config, modeConfig) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-rpm-spec", "spec");
|
||||
CodeMirror.defineMIME("application/x-rpm-spec", "spec");
|
||||
|
|
|
@ -324,3 +324,4 @@ CodeMirror.defineMode('rst', function(config, options) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-rst", "rst");
|
||||
CodeMirror.defineMIME("application/x-rst", "rst");
|
||||
|
|
|
@ -197,4 +197,5 @@ CodeMirror.defineMode("ruby", function(config, parserConfig) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-ruby", "ruby");
|
||||
CodeMirror.defineMIME("application/x-ruby", "ruby");
|
||||
|
||||
|
|
|
@ -430,3 +430,4 @@ CodeMirror.defineMode("rust", function() {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-rustsrc", "rust");
|
||||
CodeMirror.defineMIME("application/x-rustsrc", "rust");
|
||||
|
|
|
@ -200,3 +200,4 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-scheme", "scheme");
|
||||
CodeMirror.defineMIME("application/x-scheme", "scheme");
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
CodeMirror.defineMode('shell', function(config) {
|
||||
|
||||
var words = {};
|
||||
function define(style, string) {
|
||||
var split = string.split(' ');
|
||||
for(var i = 0; i < split.length; i++) {
|
||||
words[split[i]] = style;
|
||||
}
|
||||
};
|
||||
|
||||
// Atoms
|
||||
define('atom', 'true false');
|
||||
|
||||
// Keywords
|
||||
define('keyword', 'if then do else elif while until for in esac fi fin ' +
|
||||
'fil done exit set unset export function');
|
||||
|
||||
// Commands
|
||||
define('builtin', 'ab awk bash beep cat cc cd chown chmod chroot clear cp ' +
|
||||
'curl cut diff echo find gawk gcc get git grep kill killall ln ls make ' +
|
||||
'mkdir openssl mv nc node npm ping ps restart rm rmdir sed service sh ' +
|
||||
'shopt shred source sort sleep ssh start stop su sudo tee telnet top ' +
|
||||
'touch vi vim wall wc wget who write yes zsh');
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
|
||||
var sol = stream.sol();
|
||||
var ch = stream.next();
|
||||
|
||||
if (ch === '\'' || ch === '"' || ch === '`') {
|
||||
state.tokens.unshift(tokenString(ch));
|
||||
return tokenize(stream, state);
|
||||
}
|
||||
if (ch === '#') {
|
||||
if (sol && stream.eat('!')) {
|
||||
stream.skipToEnd();
|
||||
return 'meta'; // 'comment'?
|
||||
}
|
||||
stream.skipToEnd();
|
||||
return 'comment';
|
||||
}
|
||||
if (ch === '$') {
|
||||
state.tokens.unshift(tokenDollar);
|
||||
return tokenize(stream, state);
|
||||
}
|
||||
if (ch === '+' || ch === '=') {
|
||||
return 'operator';
|
||||
}
|
||||
if (ch === '-') {
|
||||
stream.eat('-');
|
||||
stream.eatWhile(/\w/);
|
||||
return 'attribute';
|
||||
}
|
||||
if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/\d/);
|
||||
if(!/\w/.test(stream.peek())) {
|
||||
return 'number';
|
||||
}
|
||||
}
|
||||
stream.eatWhile(/\w/);
|
||||
var cur = stream.current();
|
||||
if (stream.peek() === '=' && /\w+/.test(cur)) return 'def';
|
||||
return words.hasOwnProperty(cur) ? words[cur] : null;
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var next, end = false, escaped = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next === quote && !escaped) {
|
||||
end = true;
|
||||
break;
|
||||
}
|
||||
if (next === '$' && !escaped && quote !== '\'') {
|
||||
escaped = true;
|
||||
stream.backUp(1);
|
||||
state.tokens.unshift(tokenDollar);
|
||||
break;
|
||||
}
|
||||
escaped = !escaped && next === '\\';
|
||||
}
|
||||
if (end || !escaped) {
|
||||
state.tokens.shift();
|
||||
}
|
||||
return (quote === '`' || quote === ')' ? 'quote' : 'string');
|
||||
};
|
||||
};
|
||||
|
||||
var tokenDollar = function(stream, state) {
|
||||
if (state.tokens.length > 1) stream.eat('$');
|
||||
var ch = stream.next(), hungry = /\w/;
|
||||
if (ch === '{') hungry = /[^}]/;
|
||||
if (ch === '(') {
|
||||
state.tokens[0] = tokenString(')');
|
||||
return tokenize(stream, state);
|
||||
}
|
||||
if (!/\d/.test(ch)) {
|
||||
stream.eatWhile(hungry);
|
||||
stream.eat('}');
|
||||
}
|
||||
state.tokens.shift();
|
||||
return 'def';
|
||||
};
|
||||
|
||||
function tokenize(stream, state) {
|
||||
return (state.tokens[0] || tokenBase) (stream, state);
|
||||
};
|
||||
|
||||
return {
|
||||
startState: function() {return {tokens:[]};},
|
||||
token: function(stream, state) {
|
||||
if (stream.eatSpace()) return null;
|
||||
return tokenize(stream, state);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME('text/x-sh', 'shell');
|
||||
CodeMirror.defineMIME('application/x-sh', 'shell');
|
|
@ -137,3 +137,4 @@ CodeMirror.defineMode('smalltalk', function(config, modeConfig) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME('text/x-stsrc', {name: 'smalltalk'});
|
||||
CodeMirror.defineMIME('application/x-stsrc', {name: 'smalltalk'});
|
||||
|
|
|
@ -165,3 +165,4 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
|
|||
|
||||
|
||||
CodeMirror.defineMIME("text/x-stex", "stex");
|
||||
CodeMirror.defineMIME("application/x-stex", "stex");
|
||||
|
|
|
@ -371,4 +371,5 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-tiddlywiki", "tiddlywiki");
|
||||
CodeMirror.defineMIME("application/x-tiddlywiki", "tiddlywiki");
|
||||
//}}}
|
||||
|
|
|
@ -144,3 +144,4 @@ CodeMirror.defineMode("velocity", function(config) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/velocity", "velocity");
|
||||
CodeMirror.defineMIME("application/velocity", "velocity");
|
||||
|
|
|
@ -184,7 +184,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
|
|||
return "string";
|
||||
}
|
||||
|
||||
CodeMirror.defineMIME("text/x-verilog", {
|
||||
CodeMirror.defineMIME("application/x-verilog", {
|
||||
name: "verilog",
|
||||
keywords: words(verilogKeywords),
|
||||
blockKeywords: words(verilogBlockKeywords),
|
||||
|
|
|
@ -256,5 +256,6 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
|||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("application/xml", "xml");
|
||||
//CodeMirror.defineMIME("application/xml", "xml");
|
||||
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
|
||||
CodeMirror.defineMIME("application/html", {name: "xml", htmlMode: true});
|
||||
|
|
|
@ -93,3 +93,4 @@ CodeMirror.defineMode("yaml", function() {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-yaml", "yaml");
|
||||
CodeMirror.defineMIME("application/x-yaml", "yaml");
|
||||
|
|
Loading…
Reference in New Issue