##// END OF EJS Templates
markdown: improved styling, and fixed nl2br extensions to only do br on new elements not inline....
markdown: improved styling, and fixed nl2br extensions to only do br on new elements not inline. - backported the code from latest markdown which we don't support.

File last commit:

r4105:10488616 default
r4533:74d334b4 default
Show More
shell.js
152 lines | 4.8 KiB | application/javascript | JavascriptLexer
project: added all source files and assets
r1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
codemirror: bumped to version 5.49.2
r4105 // Distributed under an MIT license: https://codemirror.net/LICENSE
project: added all source files and assets
r1
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
CodeMirror.defineMode('shell', function() {
var words = {};
codemirror: bumped to version 5.49.2
r4105 function define(style, dict) {
for(var i = 0; i < dict.length; i++) {
words[dict[i]] = style;
project: added all source files and assets
r1 }
};
codemirror: bumped to version 5.49.2
r4105 var commonAtoms = ["true", "false"];
var commonKeywords = ["if", "then", "do", "else", "elif", "while", "until", "for", "in", "esac", "fi",
"fin", "fil", "done", "exit", "set", "unset", "export", "function"];
var commonCommands = ["ab", "awk", "bash", "beep", "cat", "cc", "cd", "chown", "chmod", "chroot", "clear",
"cp", "curl", "cut", "diff", "echo", "find", "gawk", "gcc", "get", "git", "grep", "hg", "kill", "killall",
"ln", "ls", "make", "mkdir", "openssl", "mv", "nc", "nl", "node", "npm", "ping", "ps", "restart", "rm",
"rmdir", "sed", "service", "sh", "shopt", "shred", "source", "sort", "sleep", "ssh", "start", "stop",
"su", "sudo", "svn", "tee", "telnet", "top", "touch", "vi", "vim", "wall", "wc", "wget", "who", "write",
"yes", "zsh"];
project: added all source files and assets
r1
codemirror: bumped to version 5.49.2
r4105 CodeMirror.registerHelper("hintWords", "shell", commonAtoms.concat(commonKeywords, commonCommands));
define('atom', commonAtoms);
define('keyword', commonKeywords);
define('builtin', commonCommands);
project: added all source files and assets
r1
function tokenBase(stream, state) {
if (stream.eatSpace()) return null;
var sol = stream.sol();
var ch = stream.next();
if (ch === '\\') {
stream.next();
return null;
}
if (ch === '\'' || ch === '"' || ch === '`') {
codemirror: bumped to version 5.49.2
r4105 state.tokens.unshift(tokenString(ch, ch === "`" ? "quote" : "string"));
project: added all source files and assets
r1 return tokenize(stream, state);
}
if (ch === '#') {
if (sol && stream.eat('!')) {
stream.skipToEnd();
return 'meta'; // 'comment'?
}
stream.skipToEnd();
return 'comment';
}
if (ch === '$') {
state.tokens.unshift(tokenDollar);
return tokenize(stream, state);
}
if (ch === '+' || ch === '=') {
return 'operator';
}
if (ch === '-') {
stream.eat('-');
stream.eatWhile(/\w/);
return 'attribute';
}
if (/\d/.test(ch)) {
stream.eatWhile(/\d/);
if(stream.eol() || !/\w/.test(stream.peek())) {
return 'number';
}
}
stream.eatWhile(/[\w-]/);
var cur = stream.current();
if (stream.peek() === '=' && /\w+/.test(cur)) return 'def';
return words.hasOwnProperty(cur) ? words[cur] : null;
}
codemirror: bumped to version 5.49.2
r4105 function tokenString(quote, style) {
var close = quote == "(" ? ")" : quote == "{" ? "}" : quote
project: added all source files and assets
r1 return function(stream, state) {
codemirror: bumped to version 5.49.2
r4105 var next, escaped = false;
project: added all source files and assets
r1 while ((next = stream.next()) != null) {
codemirror: bumped to version 5.49.2
r4105 if (next === close && !escaped) {
state.tokens.shift();
project: added all source files and assets
r1 break;
codemirror: bumped to version 5.49.2
r4105 } else if (next === '$' && !escaped && quote !== "'" && stream.peek() != close) {
project: added all source files and assets
r1 escaped = true;
stream.backUp(1);
state.tokens.unshift(tokenDollar);
break;
codemirror: bumped to version 5.49.2
r4105 } 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;
project: added all source files and assets
r1 }
escaped = !escaped && next === '\\';
}
codemirror: bumped to version 5.49.2
r4105 return style;
project: added all source files and assets
r1 };
};
codemirror: bumped to version 5.49.2
r4105 function tokenStringStart(quote, style) {
return function(stream, state) {
state.tokens[0] = tokenString(quote, style)
stream.next()
return tokenize(stream, state)
}
}
project: added all source files and assets
r1 var tokenDollar = function(stream, state) {
if (state.tokens.length > 1) stream.eat('$');
codemirror: bumped to version 5.49.2
r4105 var ch = stream.next()
if (/['"({]/.test(ch)) {
state.tokens[0] = tokenString(ch, ch == "(" ? "quote" : ch == "{" ? "def" : "string");
project: added all source files and assets
r1 return tokenize(stream, state);
}
codemirror: bumped to version 5.49.2
r4105 if (!/\d/.test(ch)) stream.eatWhile(/\w/);
project: added all source files and assets
r1 state.tokens.shift();
return 'def';
};
function tokenize(stream, state) {
return (state.tokens[0] || tokenBase) (stream, state);
};
return {
startState: function() {return {tokens:[]};},
token: function(stream, state) {
return tokenize(stream, state);
},
codemirror: bumped to version 5.49.2
r4105 closeBrackets: "()[]{}''\"\"``",
project: added all source files and assets
r1 lineComment: '#',
fold: "brace"
};
});
CodeMirror.defineMIME('text/x-sh', 'shell');
codemirror: bumped to version 5.49.2
r4105 // 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');
project: added all source files and assets
r1
});