mirror of
https://github.com/documize/community.git
synced 2025-08-02 20:15:26 +02:00
CodeMirror upgrade to 5.38.0
This commit is contained in:
parent
36be6243ad
commit
cfe30dcde5
52 changed files with 905 additions and 413 deletions
23
gui/public/codemirror/mode/shell/shell.js
vendored
23
gui/public/codemirror/mode/shell/shell.js
vendored
|
@ -84,29 +84,38 @@ CodeMirror.defineMode('shell', function() {
|
|||
function tokenString(quote, style) {
|
||||
var close = quote == "(" ? ")" : quote == "{" ? "}" : quote
|
||||
return function(stream, state) {
|
||||
var next, end = false, escaped = false;
|
||||
var next, escaped = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next === close && !escaped) {
|
||||
end = true;
|
||||
state.tokens.shift();
|
||||
break;
|
||||
}
|
||||
if (next === '$' && !escaped && quote !== "'") {
|
||||
} else if (next === '$' && !escaped && quote !== "'" && stream.peek() != close) {
|
||||
escaped = true;
|
||||
stream.backUp(1);
|
||||
state.tokens.unshift(tokenDollar);
|
||||
break;
|
||||
}
|
||||
if (!escaped && next === quote && quote !== close) {
|
||||
} else if (!escaped && quote !== close && next === quote) {
|
||||
state.tokens.unshift(tokenString(quote, style))
|
||||
return tokenize(stream, state)
|
||||
} else if (!escaped && /['"]/.test(next) && !/['"]/.test(quote)) {
|
||||
state.tokens.unshift(tokenStringStart(next, "string"));
|
||||
stream.backUp(1);
|
||||
break;
|
||||
}
|
||||
escaped = !escaped && next === '\\';
|
||||
}
|
||||
if (end) state.tokens.shift();
|
||||
return style;
|
||||
};
|
||||
};
|
||||
|
||||
function tokenStringStart(quote, style) {
|
||||
return function(stream, state) {
|
||||
state.tokens[0] = tokenString(quote, style)
|
||||
stream.next()
|
||||
return tokenize(stream, state)
|
||||
}
|
||||
}
|
||||
|
||||
var tokenDollar = function(stream, state) {
|
||||
if (state.tokens.length > 1) stream.eat('$');
|
||||
var ch = stream.next()
|
||||
|
|
9
gui/public/codemirror/mode/shell/test.js
vendored
9
gui/public/codemirror/mode/shell/test.js
vendored
|
@ -61,4 +61,13 @@
|
|||
|
||||
MT("nested braces",
|
||||
"[builtin echo] [def ${A[${B}]]}]")
|
||||
|
||||
MT("strings in parens",
|
||||
"[def FOO][operator =]([quote $(<][string \"][def $MYDIR][string \"][quote /myfile grep ][string 'hello$'][quote )])")
|
||||
|
||||
MT ("string ending in dollar",
|
||||
'[def a][operator =][string "xyz$"]; [def b][operator =][string "y"]')
|
||||
|
||||
MT ("quote ending in dollar",
|
||||
"[quote $(echo a$)]")
|
||||
})();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue