1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-27 00:59:43 +02:00

CodeMirror dependency upgraded to v5.32.0

For handling Markdown and Code section types
This commit is contained in:
Harvey Kandola 2017-12-18 13:10:51 +00:00
parent 3337db6b27
commit 0336f84a83
351 changed files with 3408 additions and 1945 deletions

45
gui/public/codemirror/mode/ruby/ruby.js vendored Executable file → Normal file
View file

@ -46,22 +46,10 @@ CodeMirror.defineMode("ruby", function(config) {
if (ch == "`" || ch == "'" || ch == '"') {
return chain(readQuoted(ch, "string", ch == '"' || ch == "`"), stream, state);
} else if (ch == "/") {
var currentIndex = stream.current().length;
if (stream.skipTo("/")) {
var search_till = stream.current().length;
stream.backUp(stream.current().length - currentIndex);
var balance = 0; // balance brackets
while (stream.current().length < search_till) {
var chchr = stream.next();
if (chchr == "(") balance += 1;
else if (chchr == ")") balance -= 1;
if (balance < 0) break;
}
stream.backUp(stream.current().length - currentIndex);
if (balance == 0)
return chain(readQuoted(ch, "string-2", true), stream, state);
}
return "operator";
if (regexpAhead(stream))
return chain(readQuoted(ch, "string-2", true), stream, state);
else
return "operator";
} else if (ch == "%") {
var style = "string", embed = true;
if (stream.eat("s")) style = "atom";
@ -148,6 +136,28 @@ CodeMirror.defineMode("ruby", function(config) {
}
}
function regexpAhead(stream) {
var start = stream.pos, depth = 0, next, found = false, escaped = false
while ((next = stream.next()) != null) {
if (!escaped) {
if ("[{(".indexOf(next) > -1) {
depth++
} else if ("]})".indexOf(next) > -1) {
depth--
if (depth < 0) break
} else if (next == "/" && depth == 0) {
found = true
break
}
escaped = next == "\\"
} else {
escaped = false
}
}
stream.backUp(stream.pos - start)
return found
}
function tokenBaseUntilBrace(depth) {
if (!depth) depth = 1;
return function(stream, state) {
@ -276,7 +286,8 @@ CodeMirror.defineMode("ruby", function(config) {
},
electricInput: /^\s*(?:end|rescue|elsif|else|\})$/,
lineComment: "#"
lineComment: "#",
fold: "indent"
};
});