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");
|
||||
|
|
|
@ -4,7 +4,7 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
|
|||
setState(f);
|
||||
return f(source, setState);
|
||||
}
|
||||
|
||||
|
||||
// These should all be Unicode extended, as per the Haskell 2010 report
|
||||
var smallRE = /[a-z_]/;
|
||||
var largeRE = /[A-Z]/;
|
||||
|
@ -15,12 +15,12 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
|
|||
var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:]/;
|
||||
var specialRE = /[(),;[\]`{}]/;
|
||||
var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer
|
||||
|
||||
|
||||
function normal(source, setState) {
|
||||
if (source.eatWhile(whiteCharRE)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
var ch = source.next();
|
||||
if (specialRE.test(ch)) {
|
||||
if (ch == '{' && source.eat('-')) {
|
||||
|
@ -32,7 +32,7 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (ch == '\'') {
|
||||
if (source.eat('\\')) {
|
||||
source.next(); // should handle other escapes here
|
||||
|
@ -45,11 +45,11 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
|
|||
}
|
||||
return "error";
|
||||
}
|
||||
|
||||
|
||||
if (ch == '"') {
|
||||
return switchState(source, setState, stringLiteral);
|
||||
}
|
||||
|
||||
|
||||
if (largeRE.test(ch)) {
|
||||
source.eatWhile(idRE);
|
||||
if (source.eat('.')) {
|
||||
|
@ -57,12 +57,12 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
|
|||
}
|
||||
return "variable-2";
|
||||
}
|
||||
|
||||
|
||||
if (smallRE.test(ch)) {
|
||||
source.eatWhile(idRE);
|
||||
return "variable";
|
||||
}
|
||||
|
||||
|
||||
if (digitRE.test(ch)) {
|
||||
if (ch == '0') {
|
||||
if (source.eat(/[xX]/)) {
|
||||
|
@ -87,7 +87,7 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
|
|||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
if (symbolRE.test(ch)) {
|
||||
if (ch == '-' && source.eat(/-/)) {
|
||||
source.eatWhile(/-/);
|
||||
|
@ -101,12 +101,12 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
|
|||
t = "variable-2";
|
||||
}
|
||||
source.eatWhile(symbolRE);
|
||||
return t;
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
return "error";
|
||||
}
|
||||
|
||||
|
||||
function ncomment(type, nest) {
|
||||
if (nest == 0) {
|
||||
return normal;
|
||||
|
@ -130,7 +130,7 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
|
|||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function stringLiteral(source, setState) {
|
||||
while (!source.eol()) {
|
||||
var ch = source.next();
|
||||
|
@ -153,7 +153,7 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
|
|||
setState(normal);
|
||||
return "error";
|
||||
}
|
||||
|
||||
|
||||
function stringGap(source, setState) {
|
||||
if (source.eat('\\')) {
|
||||
return switchState(source, setState, stringLiteral);
|
||||
|
@ -162,8 +162,8 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
|
|||
setState(normal);
|
||||
return "error";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var wellKnownWords = (function() {
|
||||
var wkw = {};
|
||||
function setType(t) {
|
||||
|
@ -172,19 +172,19 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
|
|||
wkw[arguments[i]] = t;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setType("keyword")(
|
||||
"case", "class", "data", "default", "deriving", "do", "else", "foreign",
|
||||
"if", "import", "in", "infix", "infixl", "infixr", "instance", "let",
|
||||
"module", "newtype", "of", "then", "type", "where", "_");
|
||||
|
||||
|
||||
setType("keyword")(
|
||||
"\.\.", ":", "::", "=", "\\", "\"", "<-", "->", "@", "~", "=>");
|
||||
|
||||
|
||||
setType("builtin")(
|
||||
"!!", "$!", "$", "&&", "+", "++", "-", ".", "/", "/=", "<", "<=", "=<<",
|
||||
"==", ">", ">=", ">>", ">>=", "^", "^^", "||", "*", "**");
|
||||
|
||||
|
||||
setType("builtin")(
|
||||
"Bool", "Bounded", "Char", "Double", "EQ", "Either", "Enum", "Eq",
|
||||
"False", "FilePath", "Float", "Floating", "Fractional", "Functor", "GT",
|
||||
|
@ -192,7 +192,7 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
|
|||
"Maybe", "Monad", "Nothing", "Num", "Ord", "Ordering", "Rational", "Read",
|
||||
"ReadS", "Real", "RealFloat", "RealFrac", "Right", "Show", "ShowS",
|
||||
"String", "True");
|
||||
|
||||
|
||||
setType("builtin")(
|
||||
"abs", "acos", "acosh", "all", "and", "any", "appendFile", "asTypeOf",
|
||||
"asin", "asinh", "atan", "atan2", "atanh", "break", "catch", "ceiling",
|
||||
|
@ -220,16 +220,16 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
|
|||
"toRational", "truncate", "uncurry", "undefined", "unlines", "until",
|
||||
"unwords", "unzip", "unzip3", "userError", "words", "writeFile", "zip",
|
||||
"zip3", "zipWith", "zipWith3");
|
||||
|
||||
|
||||
return wkw;
|
||||
})();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return {
|
||||
startState: function () { return { f: normal }; },
|
||||
copyState: function (s) { return { f: s.f }; },
|
||||
|
||||
|
||||
token: function(stream, state) {
|
||||
var t = state.f(stream, function(s) { state.f = s; });
|
||||
var w = stream.current();
|
||||
|
@ -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");
|
||||
|
|
|
@ -53,7 +53,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
else if (ch == "0" && stream.eat(/x/i)) {
|
||||
stream.eatWhile(/[\da-f]/i);
|
||||
return ret("number", "number");
|
||||
}
|
||||
}
|
||||
else if (/\d/.test(ch)) {
|
||||
stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
|
||||
return ret("number", "number");
|
||||
|
@ -135,7 +135,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
// Communicate our context to the combinators.
|
||||
// (Less wasteful than consing up a hundred closures on every call.)
|
||||
cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
|
||||
|
||||
|
||||
if (!state.lexical.hasOwnProperty("align"))
|
||||
state.lexical.align = true;
|
||||
|
||||
|
@ -240,7 +240,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
if (type.match(/[;\}\)\],]/)) return pass();
|
||||
return pass(expression);
|
||||
}
|
||||
|
||||
|
||||
function maybeoperator(type, value) {
|
||||
if (type == "operator" && /\+\+|--/.test(value)) return cont(maybeoperator);
|
||||
if (type == "operator") return cont(expression);
|
||||
|
@ -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});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// LUA mode. Ported to CodeMirror 2 from Franciszek Wawrzak's
|
||||
// CodeMirror 1 mode.
|
||||
// highlights keywords, strings, comments (no leveling supported! ("[==[")), tokens, basic indenting
|
||||
|
||||
|
||||
CodeMirror.defineMode("lua", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit;
|
||||
|
||||
|
@ -12,7 +12,7 @@ CodeMirror.defineMode("lua", function(config, parserConfig) {
|
|||
return new RegExp("^(?:" + words.join("|") + ")$", "i");
|
||||
}
|
||||
var specials = wordRE(parserConfig.specials || []);
|
||||
|
||||
|
||||
// long list of standard functions from lua manual
|
||||
var builtins = wordRE([
|
||||
"_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load",
|
||||
|
@ -47,7 +47,7 @@ CodeMirror.defineMode("lua", function(config, parserConfig) {
|
|||
"table.concat","table.insert","table.maxn","table.remove","table.sort"
|
||||
]);
|
||||
var keywords = wordRE(["and","break","elseif","false","nil","not","or","return",
|
||||
"true","function", "end", "if", "then", "else", "do",
|
||||
"true","function", "end", "if", "then", "else", "do",
|
||||
"while", "repeat", "until", "for", "in", "local" ]);
|
||||
|
||||
var indentTokens = wordRE(["function", "if","repeat","do", "\\(", "{"]);
|
||||
|
@ -68,7 +68,7 @@ CodeMirror.defineMode("lua", function(config, parserConfig) {
|
|||
return (state.cur = bracketed(readBracket(stream), "comment"))(stream, state);
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
}
|
||||
if (ch == "\"" || ch == "'")
|
||||
return (state.cur = string(ch))(stream, state);
|
||||
if (ch == "[" && /[\[=]/.test(stream.peek()))
|
||||
|
@ -108,7 +108,7 @@ CodeMirror.defineMode("lua", function(config, parserConfig) {
|
|||
return "string";
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
startState: function(basecol) {
|
||||
return {basecol: basecol || 0, indentDepth: 0, cur: normal};
|
||||
|
@ -138,3 +138,4 @@ CodeMirror.defineMode("lua", function(config, parserConfig) {
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-lua", "lua");
|
||||
CodeMirror.defineMIME("application/x-lua", "lua");
|
||||
|
|
|
@ -38,11 +38,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
stream.skipToEnd();
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
if (stream.eatSpace()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (stream.peek() === '#' || stream.match(headerRE)) {
|
||||
stream.skipToEnd();
|
||||
return header;
|
||||
|
@ -60,13 +60,13 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var match;
|
||||
if (match = stream.match(ulRE, true) || stream.match(olRE, true)) {
|
||||
state.indentation += match[0].length;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
return switchInline(stream, state, state.inline);
|
||||
}
|
||||
|
||||
|
@ -90,16 +90,16 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
if (stream.match(textRE, true)) {
|
||||
return getType(state);
|
||||
}
|
||||
return undefined;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function inlineNormal(stream, state) {
|
||||
var style = state.text(stream, state)
|
||||
if (typeof style !== 'undefined')
|
||||
return style;
|
||||
|
||||
|
||||
var ch = stream.next();
|
||||
|
||||
|
||||
if (ch === '\\') {
|
||||
stream.next();
|
||||
return getType(state);
|
||||
|
@ -122,7 +122,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
}
|
||||
return (state.em = !state.em) ? getType(state) : t;
|
||||
}
|
||||
|
||||
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
|
@ -184,11 +184,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
startState: function() {
|
||||
return {
|
||||
f: blockNormal,
|
||||
|
||||
|
||||
block: blockNormal,
|
||||
htmlState: htmlMode.startState(),
|
||||
indentation: 0,
|
||||
|
||||
|
||||
inline: inlineNormal,
|
||||
text: handleText,
|
||||
em: false,
|
||||
|
@ -199,11 +199,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
copyState: function(s) {
|
||||
return {
|
||||
f: s.f,
|
||||
|
||||
|
||||
block: s.block,
|
||||
htmlState: CodeMirror.copyState(htmlMode, s.htmlState),
|
||||
indentation: s.indentation,
|
||||
|
||||
|
||||
inline: s.inline,
|
||||
text: s.text,
|
||||
em: s.em,
|
||||
|
@ -228,7 +228,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
}
|
||||
}
|
||||
state.indentation = currentIndentation;
|
||||
|
||||
|
||||
if (currentIndentation > 0) return null;
|
||||
}
|
||||
return state.f(stream, state);
|
||||
|
@ -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),
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
CodeMirror.defineMode("python", function(conf, parserConf) {
|
||||
var ERRORCLASS = 'error';
|
||||
|
||||
|
||||
function wordRegexp(words) {
|
||||
return new RegExp("^((" + words.join(")|(") + "))\\b");
|
||||
}
|
||||
|
||||
|
||||
var singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!]");
|
||||
var singleDelimiters = new RegExp('^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]');
|
||||
var doubleOperators = new RegExp("^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))");
|
||||
|
@ -72,15 +72,15 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|||
if (stream.eatSpace()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
var ch = stream.peek();
|
||||
|
||||
|
||||
// Handle Comments
|
||||
if (ch === '#') {
|
||||
stream.skipToEnd();
|
||||
return 'comment';
|
||||
}
|
||||
|
||||
|
||||
// Handle Number Literals
|
||||
if (stream.match(/^[0-9\.]/, false)) {
|
||||
var floatLiteral = false;
|
||||
|
@ -116,13 +116,13 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|||
return 'number';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Handle Strings
|
||||
if (stream.match(stringPrefixes)) {
|
||||
state.tokenize = tokenStringFactory(stream.current());
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
|
||||
|
||||
// Handle operators and Delimiters
|
||||
if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters)) {
|
||||
return null;
|
||||
|
@ -135,31 +135,31 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|||
if (stream.match(singleDelimiters)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (stream.match(keywords)) {
|
||||
return 'keyword';
|
||||
}
|
||||
|
||||
|
||||
if (stream.match(builtins)) {
|
||||
return 'builtin';
|
||||
}
|
||||
|
||||
|
||||
if (stream.match(identifiers)) {
|
||||
return 'variable';
|
||||
}
|
||||
|
||||
|
||||
// Handle non-detected items
|
||||
stream.next();
|
||||
return ERRORCLASS;
|
||||
}
|
||||
|
||||
|
||||
function tokenStringFactory(delimiter) {
|
||||
while ('rub'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) {
|
||||
delimiter = delimiter.substr(1);
|
||||
}
|
||||
var singleline = delimiter.length == 1;
|
||||
var OUTCLASS = 'string';
|
||||
|
||||
|
||||
return function tokenString(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
stream.eatWhile(/[^'"\\]/);
|
||||
|
@ -185,7 +185,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|||
return OUTCLASS;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function indent(stream, state, type) {
|
||||
type = type || 'py';
|
||||
var indentUnit = 0;
|
||||
|
@ -208,7 +208,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|||
type: type
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function dedent(stream, state, type) {
|
||||
type = type || 'py';
|
||||
if (state.scopes.length == 1) return;
|
||||
|
@ -257,7 +257,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|||
return ERRORCLASS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Handle decorators
|
||||
if (current === '@') {
|
||||
style = state.tokenize(stream, state);
|
||||
|
@ -270,7 +270,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|||
return ERRORCLASS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Handle scope changes.
|
||||
if (current === 'pass' || current === 'return') {
|
||||
state.dedent += 1;
|
||||
|
@ -298,7 +298,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|||
if (state.scopes.length > 1) state.scopes.shift();
|
||||
state.dedent -= 1;
|
||||
}
|
||||
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
|
@ -312,29 +312,30 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|||
dedent: 0
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
token: function(stream, state) {
|
||||
var style = tokenLexer(stream, state);
|
||||
|
||||
|
||||
state.lastToken = {style:style, content: stream.current()};
|
||||
|
||||
|
||||
if (stream.eol() && stream.lambda) {
|
||||
state.lambda = false;
|
||||
}
|
||||
|
||||
|
||||
return style;
|
||||
},
|
||||
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != tokenBase) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return state.scopes[0].offset;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
return external;
|
||||
});
|
||||
|
||||
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");
|
||||
|
|
|
@ -5,7 +5,7 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|||
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
|
||||
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD="keyword";
|
||||
var INDENT_WORD_SKIP = 2, KEYWORDS_SKIP = 1;
|
||||
|
||||
|
||||
function makeKeywords(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
|
@ -14,7 +14,7 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|||
|
||||
var keywords = makeKeywords("λ case-lambda call/cc class define-class exit-handler field import inherit init-field interface let*-values let-values let/ec mixin opt-lambda override protect provide public rename require require-for-syntax syntax syntax-case syntax-error unit/sig unless when with-syntax and begin call-with-current-continuation call-with-input-file call-with-output-file case cond define define-syntax delay do dynamic-wind else for-each if lambda let let* let-syntax letrec letrec-syntax map or syntax-rules abs acos angle append apply asin assoc assq assv atan boolean? caar cadr call-with-input-file call-with-output-file call-with-values car cdddar cddddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci<? char-ci=? char-ci>=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char<? char=? char>=? char>? char? close-input-port close-output-port complex? cons cos current-input-port current-output-port denominator display eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt #f floor force gcd imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lcm length list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file output-port? pair? peek-char port? positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci<? string-ci=? string-ci>=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string<? string=? string>=? string>? string? substring symbol->string symbol? #t tan transcript-off transcript-on truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! with-input-from-file with-output-to-file write write-char zero?");
|
||||
var indentKeys = makeKeywords("define let letrec let* lambda");
|
||||
|
||||
|
||||
|
||||
function stateStack(indent, type, prev) { // represents a state stack object
|
||||
this.indent = indent;
|
||||
|
@ -29,14 +29,14 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|||
function popStack(state) {
|
||||
state.indentStack = state.indentStack.prev;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scheme numbers are complicated unfortunately.
|
||||
* Checks if we're looking at a number, which might be possibly a fraction.
|
||||
* Also checks that it is not part of a longer identifier. Returns true/false accordingly.
|
||||
*/
|
||||
function isNumber(ch, stream){
|
||||
if(/[0-9]/.exec(ch) != null){
|
||||
function isNumber(ch, stream){
|
||||
if(/[0-9]/.exec(ch) != null){
|
||||
stream.eatWhile(/[0-9]/);
|
||||
stream.eat(/\//);
|
||||
stream.eatWhile(/[0-9]/);
|
||||
|
@ -67,13 +67,13 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|||
return null;
|
||||
}
|
||||
var returnType = null;
|
||||
|
||||
|
||||
switch(state.mode){
|
||||
case "string": // multi-line string parsing mode
|
||||
var next, escaped = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == "\"" && !escaped) {
|
||||
|
||||
|
||||
state.mode = false;
|
||||
break;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|||
var next, maybeEnd = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == "#" && maybeEnd) {
|
||||
|
||||
|
||||
state.mode = false;
|
||||
break;
|
||||
}
|
||||
|
@ -106,11 +106,11 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|||
}
|
||||
default: // default parsing mode
|
||||
var ch = stream.next();
|
||||
|
||||
|
||||
if (ch == "\"") {
|
||||
state.mode = "string";
|
||||
returnType = STRING;
|
||||
|
||||
|
||||
} else if (ch == "'") {
|
||||
returnType = ATOM;
|
||||
} else if (ch == '#') {
|
||||
|
@ -123,16 +123,16 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|||
state.mode = "s-expr-comment";
|
||||
returnType = COMMENT;
|
||||
}
|
||||
|
||||
|
||||
} else if (ch == ";") { // comment
|
||||
stream.skipToEnd(); // rest of the line is a comment
|
||||
returnType = COMMENT;
|
||||
} else if (ch == "-"){
|
||||
|
||||
|
||||
if(!isNaN(parseInt(stream.peek()))){
|
||||
stream.eatWhile(/[\/0-9]/);
|
||||
returnType = NUMBER;
|
||||
}else{
|
||||
}else{
|
||||
returnType = null;
|
||||
}
|
||||
} else if (isNumber(ch,stream)){
|
||||
|
@ -140,18 +140,18 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|||
} else if (ch == "(" || ch == "[") {
|
||||
var keyWord = ''; var indentTemp = stream.column();
|
||||
/**
|
||||
Either
|
||||
Either
|
||||
(indent-word ..
|
||||
(non-indent-word ..
|
||||
(;something else, bracket, etc.
|
||||
*/
|
||||
|
||||
|
||||
while ((letter = stream.eat(/[^\s\(\[\;\)\]]/)) != null) {
|
||||
keyWord += letter;
|
||||
}
|
||||
|
||||
|
||||
if (keyWord.length > 0 && indentKeys.propertyIsEnumerable(keyWord)) { // indent-word
|
||||
|
||||
|
||||
pushStack(state, indentTemp + INDENT_WORD_SKIP, ch);
|
||||
} else { // non-indent word
|
||||
// we continue eating the spaces
|
||||
|
@ -165,15 +165,15 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|||
}
|
||||
}
|
||||
stream.backUp(stream.current().length - 1); // undo all the eating
|
||||
|
||||
|
||||
if(typeof state.sExprComment == "number") state.sExprComment++;
|
||||
|
||||
|
||||
returnType = BRACKET;
|
||||
} else if (ch == ")" || ch == "]") {
|
||||
returnType = BRACKET;
|
||||
if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : "[")) {
|
||||
popStack(state);
|
||||
|
||||
|
||||
if(typeof state.sExprComment == "number"){
|
||||
if(--state.sExprComment == 0){
|
||||
returnType = COMMENT; // final closing bracket
|
||||
|
@ -183,7 +183,7 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|||
}
|
||||
} else {
|
||||
stream.eatWhile(/[\w\$_\-]/);
|
||||
|
||||
|
||||
if (keywords && keywords.propertyIsEnumerable(stream.current())) {
|
||||
returnType = BUILTIN;
|
||||
}else returnType = null;
|
||||
|
@ -199,4 +199,5 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-scheme", "scheme");
|
||||
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');
|
|
@ -136,4 +136,5 @@ CodeMirror.defineMode('smalltalk', function(config, modeConfig) {
|
|||
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME('text/x-stsrc', {name: 'smalltalk'});
|
||||
CodeMirror.defineMIME('text/x-stsrc', {name: 'smalltalk'});
|
||||
CodeMirror.defineMIME('application/x-stsrc', {name: 'smalltalk'});
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* Licence: MIT
|
||||
*/
|
||||
|
||||
CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
|
||||
{
|
||||
CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
|
||||
{
|
||||
function pushCommand(state, command) {
|
||||
state.cmdState.push(command);
|
||||
}
|
||||
|
||||
function peekCommand(state) {
|
||||
function peekCommand(state) {
|
||||
if (state.cmdState.length>0)
|
||||
return state.cmdState[state.cmdState.length-1];
|
||||
else
|
||||
|
@ -20,7 +20,7 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
|
|||
if (state.cmdState.length>0) {
|
||||
var plug = state.cmdState.pop();
|
||||
plug.closeBracket();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function applyMostPowerful(state) {
|
||||
|
@ -58,7 +58,7 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
|
|||
}
|
||||
|
||||
var plugins = new Array();
|
||||
|
||||
|
||||
plugins["importmodule"] = addPluginPattern("importmodule", "tag", "{[", ["string", "builtin"]);
|
||||
plugins["documentclass"] = addPluginPattern("documentclass", "tag", "{[", ["", "atom"]);
|
||||
plugins["usepackage"] = addPluginPattern("documentclass", "tag", "[", ["atom"]);
|
||||
|
@ -99,7 +99,7 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
|
|||
if (ch == "%") {
|
||||
setState(state, inCComment);
|
||||
return "comment";
|
||||
}
|
||||
}
|
||||
else if (ch=='}' || ch==']') {
|
||||
plug = peekCommand(state);
|
||||
if (plug) {
|
||||
|
@ -109,10 +109,10 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
|
|||
return "error";
|
||||
return "bracket";
|
||||
} else if (ch=='{' || ch=='[') {
|
||||
plug = plugins["DEFAULT"];
|
||||
plug = plugins["DEFAULT"];
|
||||
plug = new plug();
|
||||
pushCommand(state, plug);
|
||||
return "bracket";
|
||||
return "bracket";
|
||||
}
|
||||
else if (/\d/.test(ch)) {
|
||||
source.eatWhile(/[\w.%]/);
|
||||
|
@ -154,7 +154,7 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
|
|||
return {
|
||||
startState: function() { return { f:normal, cmdState:[] }; },
|
||||
copyState: function(s) { return { f: s.f, cmdState: s.cmdState.slice(0, s.cmdState.length) }; },
|
||||
|
||||
|
||||
token: function(stream, state) {
|
||||
var t = state.f(stream, state);
|
||||
var w = stream.current();
|
||||
|
@ -165,3 +165,4 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
|
|||
|
||||
|
||||
CodeMirror.defineMIME("text/x-stex", "stex");
|
||||
CodeMirror.defineMIME("application/x-stex", "stex");
|
||||
|
|
|
@ -90,14 +90,14 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|||
}
|
||||
|
||||
function jsTokenBase(stream, state) {
|
||||
var sol = stream.sol(),
|
||||
var sol = stream.sol(),
|
||||
ch, tch;
|
||||
|
||||
|
||||
state.block = false; // indicates the start of a code block.
|
||||
|
||||
ch = stream.peek(); // don't eat, to make match simpler
|
||||
|
||||
// check start of blocks
|
||||
|
||||
// check start of blocks
|
||||
if (sol && /[<\/\*{}\-]/.test(ch)) {
|
||||
if (stream.match(reCodeBlockStart)) {
|
||||
state.block = true;
|
||||
|
@ -180,7 +180,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|||
if (stream.eat("%")) {
|
||||
return chain(stream, state, twTokenComment);
|
||||
}
|
||||
else if (stream.eat("/")) { //
|
||||
else if (stream.eat("/")) { //
|
||||
return chain(stream, state, twTokenEm);
|
||||
}
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|||
// tw code
|
||||
function twTokenCode(stream, state) {
|
||||
var ch, sb = state.block;
|
||||
|
||||
|
||||
if (sb && stream.current()) {
|
||||
return ret("code", "code");
|
||||
}
|
||||
|
@ -301,12 +301,12 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|||
return ret("text", "underlined");
|
||||
}
|
||||
|
||||
// tw strike through text looks ugly
|
||||
// tw strike through text looks ugly
|
||||
// TODO just strike through the first and last 2 chars if possible.
|
||||
function twTokenStrike(stream, state) {
|
||||
var maybeEnd = false,
|
||||
ch, nr;
|
||||
|
||||
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "-" && maybeEnd) {
|
||||
state.tokenize = jsTokenBase;
|
||||
|
@ -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),
|
||||
|
|
|
@ -50,7 +50,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
|||
var ok;
|
||||
if (stream.eat("#")) {
|
||||
if (stream.eat("x")) {
|
||||
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
|
||||
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
|
||||
} else {
|
||||
ok = stream.eatWhile(/[\d]/) && stream.eat(";");
|
||||
}
|
||||
|
@ -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});
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
CodeMirror.defineMode("yaml", function() {
|
||||
|
||||
|
||||
var cons = ['true', 'false', 'on', 'off', 'yes', 'no'];
|
||||
var keywordRegex = new RegExp("\\b(("+cons.join(")|(")+"))$", 'i');
|
||||
|
||||
|
||||
return {
|
||||
token: function(stream, state) {
|
||||
var ch = stream.peek();
|
||||
|
@ -31,7 +31,7 @@ CodeMirror.defineMode("yaml", function() {
|
|||
return "atom";
|
||||
}
|
||||
if (state.pair && stream.match(/^:\s*/)) { state.pairStart = true; return 'meta'; }
|
||||
|
||||
|
||||
/* inline pairs/lists */
|
||||
if (stream.match(/^(\{|\}|\[|\])/)) {
|
||||
if (ch == '{')
|
||||
|
@ -44,7 +44,7 @@ CodeMirror.defineMode("yaml", function() {
|
|||
state.inlineList--;
|
||||
return 'meta';
|
||||
}
|
||||
|
||||
|
||||
/* list seperator */
|
||||
if (state.inlineList > 0 && !esc && ch == ',') {
|
||||
stream.next();
|
||||
|
@ -58,7 +58,7 @@ CodeMirror.defineMode("yaml", function() {
|
|||
stream.next();
|
||||
return 'meta';
|
||||
}
|
||||
|
||||
|
||||
/* start of value of a pair */
|
||||
if (state.pairStart) {
|
||||
/* block literals */
|
||||
|
@ -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