mirror of
https://github.com/documize/community.git
synced 2025-08-04 04:55:23 +02:00
upgraded libs and improved Markdown editing experience
This commit is contained in:
parent
2e146cf767
commit
ea1a8000ee
165 changed files with 15930 additions and 19013 deletions
107
app/public/codemirror/mode/dylan/dylan.js
vendored
107
app/public/codemirror/mode/dylan/dylan.js
vendored
|
@ -11,6 +11,14 @@
|
|||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
function forEach(arr, f) {
|
||||
for (var i = 0; i < arr.length; i++) f(arr[i], i)
|
||||
}
|
||||
function some(arr, f) {
|
||||
for (var i = 0; i < arr.length; i++) if (f(arr[i], i)) return true
|
||||
return false
|
||||
}
|
||||
|
||||
CodeMirror.defineMode("dylan", function(_config) {
|
||||
// Words
|
||||
var words = {
|
||||
|
@ -136,13 +144,13 @@ CodeMirror.defineMode("dylan", function(_config) {
|
|||
var wordLookup = {};
|
||||
var styleLookup = {};
|
||||
|
||||
[
|
||||
forEach([
|
||||
"keyword",
|
||||
"definition",
|
||||
"simpleDefinition",
|
||||
"signalingCalls"
|
||||
].forEach(function(type) {
|
||||
words[type].forEach(function(word) {
|
||||
], function(type) {
|
||||
forEach(words[type], function(word) {
|
||||
wordLookup[word] = type;
|
||||
styleLookup[word] = styles[type];
|
||||
});
|
||||
|
@ -169,15 +177,16 @@ CodeMirror.defineMode("dylan", function(_config) {
|
|||
} else if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
} else {
|
||||
stream.skipTo(" ");
|
||||
return "operator";
|
||||
}
|
||||
stream.backUp(1);
|
||||
}
|
||||
// Decimal
|
||||
else if (/\d/.test(ch)) {
|
||||
stream.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/);
|
||||
return "number";
|
||||
else if (/[+\-\d\.]/.test(ch)) {
|
||||
if (stream.match(/^[+-]?[0-9]*\.[0-9]*([esdx][+-]?[0-9]+)?/i) ||
|
||||
stream.match(/^[+-]?[0-9]+([esdx][+-]?[0-9]+)/i) ||
|
||||
stream.match(/^[+-]?\d+/)) {
|
||||
return "number";
|
||||
}
|
||||
}
|
||||
// Hash
|
||||
else if (ch == "#") {
|
||||
|
@ -186,7 +195,7 @@ CodeMirror.defineMode("dylan", function(_config) {
|
|||
ch = stream.peek();
|
||||
if (ch == '"') {
|
||||
stream.next();
|
||||
return chain(stream, state, tokenString('"', "string-2"));
|
||||
return chain(stream, state, tokenString('"', "string"));
|
||||
}
|
||||
// Binary number
|
||||
else if (ch == "b") {
|
||||
|
@ -206,29 +215,73 @@ CodeMirror.defineMode("dylan", function(_config) {
|
|||
stream.eatWhile(/[0-7]/);
|
||||
return "number";
|
||||
}
|
||||
// Hash symbol
|
||||
else {
|
||||
stream.eatWhile(/[-a-zA-Z]/);
|
||||
return "keyword";
|
||||
// Token concatenation in macros
|
||||
else if (ch == '#') {
|
||||
stream.next();
|
||||
return "punctuation";
|
||||
}
|
||||
// Sequence literals
|
||||
else if ((ch == '[') || (ch == '(')) {
|
||||
stream.next();
|
||||
return "bracket";
|
||||
// Hash symbol
|
||||
} else if (stream.match(/f|t|all-keys|include|key|next|rest/i)) {
|
||||
return "atom";
|
||||
} else {
|
||||
stream.eatWhile(/[-a-zA-Z]/);
|
||||
return "error";
|
||||
}
|
||||
} else if (ch == "~") {
|
||||
stream.next();
|
||||
ch = stream.peek();
|
||||
if (ch == "=") {
|
||||
stream.next();
|
||||
ch = stream.peek();
|
||||
if (ch == "=") {
|
||||
stream.next();
|
||||
return "operator";
|
||||
}
|
||||
return "operator";
|
||||
}
|
||||
return "operator";
|
||||
} else if (ch == ":") {
|
||||
stream.next();
|
||||
ch = stream.peek();
|
||||
if (ch == "=") {
|
||||
stream.next();
|
||||
return "operator";
|
||||
} else if (ch == ":") {
|
||||
stream.next();
|
||||
return "punctuation";
|
||||
}
|
||||
} else if ("[](){}".indexOf(ch) != -1) {
|
||||
stream.next();
|
||||
return "bracket";
|
||||
} else if (".,".indexOf(ch) != -1) {
|
||||
stream.next();
|
||||
return "punctuation";
|
||||
} else if (stream.match("end")) {
|
||||
return "keyword";
|
||||
}
|
||||
for (var name in patterns) {
|
||||
if (patterns.hasOwnProperty(name)) {
|
||||
var pattern = patterns[name];
|
||||
if ((pattern instanceof Array && pattern.some(function(p) {
|
||||
if ((pattern instanceof Array && some(pattern, function(p) {
|
||||
return stream.match(p);
|
||||
})) || stream.match(pattern))
|
||||
return patternStyles[name];
|
||||
}
|
||||
}
|
||||
if (/[+\-*\/^=<>&|]/.test(ch)) {
|
||||
stream.next();
|
||||
return "operator";
|
||||
}
|
||||
if (stream.match("define")) {
|
||||
return "def";
|
||||
} else {
|
||||
stream.eatWhile(/[\w\-]/);
|
||||
// Keyword
|
||||
if (wordLookup[stream.current()]) {
|
||||
if (wordLookup.hasOwnProperty(stream.current())) {
|
||||
return styleLookup[stream.current()];
|
||||
} else if (stream.current().match(symbol)) {
|
||||
return "variable";
|
||||
|
@ -240,29 +293,37 @@ CodeMirror.defineMode("dylan", function(_config) {
|
|||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false,
|
||||
ch;
|
||||
var maybeEnd = false, maybeNested = false, nestedCount = 0, ch;
|
||||
while ((ch = stream.next())) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
if (nestedCount > 0) {
|
||||
nestedCount--;
|
||||
} else {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
} else if (ch == "*" && maybeNested) {
|
||||
nestedCount++;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
maybeNested = (ch == "/");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function tokenString(quote, style) {
|
||||
return function(stream, state) {
|
||||
var next, end = false;
|
||||
var escaped = false, next, end = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote) {
|
||||
if (next == quote && !escaped) {
|
||||
end = true;
|
||||
break;
|
||||
}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (end)
|
||||
if (end || !escaped) {
|
||||
state.tokenize = tokenBase;
|
||||
}
|
||||
return style;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue