1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-23 23:29:42 +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

25
gui/public/codemirror/mode/shell/shell.js vendored Executable file → Normal file
View file

@ -30,9 +30,9 @@ CodeMirror.defineMode('shell', 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 ' +
'curl cut diff echo find gawk gcc get git grep hg 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 ' +
'shopt shred source sort sleep ssh start stop su sudo svn tee telnet top ' +
'touch vi vim wall wc wget who write yes zsh');
function tokenBase(stream, state) {
@ -82,7 +82,7 @@ CodeMirror.defineMode('shell', function() {
}
function tokenString(quote, style) {
var close = quote == "(" ? ")" : quote
var close = quote == "(" ? ")" : quote == "{" ? "}" : quote
return function(stream, state) {
var next, end = false, escaped = false;
while ((next = stream.next()) != null) {
@ -96,29 +96,25 @@ CodeMirror.defineMode('shell', function() {
state.tokens.unshift(tokenDollar);
break;
}
if (next === "(" && quote === "(") {
if (!escaped && next === quote && quote !== close) {
state.tokens.unshift(tokenString(quote, style))
return tokenize(stream, state)
}
escaped = !escaped && next === '\\';
}
if (end || !escaped) state.tokens.shift();
if (end) state.tokens.shift();
return style;
};
};
var tokenDollar = function(stream, state) {
if (state.tokens.length > 1) stream.eat('$');
var ch = stream.next(), hungry = /\w/;
if (ch === '{') hungry = /[^}]/;
if (/['"(]/.test(ch)) {
state.tokens[0] = tokenString(ch, ch == "(" ? "quote" : "string");
var ch = stream.next()
if (/['"({]/.test(ch)) {
state.tokens[0] = tokenString(ch, ch == "(" ? "quote" : ch == "{" ? "def" : "string");
return tokenize(stream, state);
}
if (!/\d/.test(ch)) {
stream.eatWhile(hungry);
stream.eat('}');
}
if (!/\d/.test(ch)) stream.eatWhile(/\w/);
state.tokens.shift();
return 'def';
};
@ -139,5 +135,8 @@ CodeMirror.defineMode('shell', function() {
});
CodeMirror.defineMIME('text/x-sh', 'shell');
// Apache uses a slightly different Media Type for Shell scripts
// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
CodeMirror.defineMIME('application/x-sh', 'shell');
});