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

upgraded libs and improved Markdown editing experience

This commit is contained in:
Harvey Kandola 2017-03-13 15:40:28 +00:00
parent 2e146cf767
commit ea1a8000ee
165 changed files with 15930 additions and 19013 deletions

View file

@ -46,7 +46,7 @@ CodeMirror.defineMode('shell', function() {
return null;
}
if (ch === '\'' || ch === '"' || ch === '`') {
state.tokens.unshift(tokenString(ch));
state.tokens.unshift(tokenString(ch, ch === "`" ? "quote" : "string"));
return tokenize(stream, state);
}
if (ch === '#') {
@ -81,26 +81,29 @@ CodeMirror.defineMode('shell', function() {
return words.hasOwnProperty(cur) ? words[cur] : null;
}
function tokenString(quote) {
function tokenString(quote, style) {
var close = quote == "(" ? ")" : quote
return function(stream, state) {
var next, end = false, escaped = false;
while ((next = stream.next()) != null) {
if (next === quote && !escaped) {
if (next === close && !escaped) {
end = true;
break;
}
if (next === '$' && !escaped && quote !== '\'') {
if (next === '$' && !escaped && quote !== "'") {
escaped = true;
stream.backUp(1);
state.tokens.unshift(tokenDollar);
break;
}
if (next === "(" && quote === "(") {
state.tokens.unshift(tokenString(quote, style))
return tokenize(stream, state)
}
escaped = !escaped && next === '\\';
}
if (end || !escaped) {
state.tokens.shift();
}
return (quote === '`' || quote === ')' ? 'quote' : 'string');
if (end || !escaped) state.tokens.shift();
return style;
};
};
@ -108,8 +111,8 @@ CodeMirror.defineMode('shell', function() {
if (state.tokens.length > 1) stream.eat('$');
var ch = stream.next(), hungry = /\w/;
if (ch === '{') hungry = /[^}]/;
if (ch === '(') {
state.tokens[0] = tokenString(')');
if (/['"(]/.test(ch)) {
state.tokens[0] = tokenString(ch, ch == "(" ? "quote" : "string");
return tokenize(stream, state);
}
if (!/\d/.test(ch)) {
@ -129,6 +132,7 @@ CodeMirror.defineMode('shell', function() {
token: function(stream, state) {
return tokenize(stream, state);
},
closeBrackets: "()[]{}''\"\"``",
lineComment: '#',
fold: "brace"
};