Path: blob/master/web-gui/buildyourownbotnet/assets/js/codemirror/mode/jade/jade.js
1293 views
CodeMirror.defineMode("jade", function () {1var symbol_regex1 = /^(?:~|!|%|\^|\*|\+|=|\\|:|;|,|\/|\?|&|<|>|\|)/;2var open_paren_regex = /^(\(|\[)/;3var close_paren_regex = /^(\)|\])/;4var keyword_regex1 = /^(if|else|return|var|function|include|doctype|each)/;5var keyword_regex2 = /^(#|{|}|\.)/;6var keyword_regex3 = /^(in)/;7var html_regex1 = /^(html|head|title|meta|link|script|body|br|div|input|span|a|img)/;8var html_regex2 = /^(h1|h2|h3|h4|h5|p|strong|em)/;9return {10startState: function () {11return {12inString: false,13stringType: "",14beforeTag: true,15justMatchedKeyword: false,16afterParen: false17};18},19token: function (stream, state) {20//check for state changes21if (!state.inString && ((stream.peek() == '"') || (stream.peek() == "'"))) {22state.stringType = stream.peek();23stream.next(); // Skip quote24state.inString = true; // Update state25}2627//return state28if (state.inString) {29if (stream.skipTo(state.stringType)) { // Quote found on this line30stream.next(); // Skip quote31state.inString = false; // Clear flag32} else {33stream.skipToEnd(); // Rest of line is string34}35state.justMatchedKeyword = false;36return "string"; // Token style37} else if (stream.sol() && stream.eatSpace()) {38if (stream.match(keyword_regex1)) {39state.justMatchedKeyword = true;40stream.eatSpace();41return "keyword";42}43if (stream.match(html_regex1) || stream.match(html_regex2)) {44state.justMatchedKeyword = true;45return "variable";46}47} else if (stream.sol() && stream.match(keyword_regex1)) {48state.justMatchedKeyword = true;49stream.eatSpace();50return "keyword";51} else if (stream.sol() && (stream.match(html_regex1) || stream.match(html_regex2))) {52state.justMatchedKeyword = true;53return "variable";54} else if (stream.eatSpace()) {55state.justMatchedKeyword = false;56if (stream.match(keyword_regex3) && stream.eatSpace()) {57state.justMatchedKeyword = true;58return "keyword";59}60} else if (stream.match(symbol_regex1)) {61state.justMatchedKeyword = false;62return "atom";63} else if (stream.match(open_paren_regex)) {64state.afterParen = true;65state.justMatchedKeyword = true;66return "def";67} else if (stream.match(close_paren_regex)) {68state.afterParen = false;69state.justMatchedKeyword = true;70return "def";71} else if (stream.match(keyword_regex2)) {72state.justMatchedKeyword = true;73return "keyword";74} else if (stream.eatSpace()) {75state.justMatchedKeyword = false;76} else {77stream.next();78if (state.justMatchedKeyword) {79return "property";80} else if (state.afterParen) {81return "property";82}83}84return null;85}86};87});8889CodeMirror.defineMIME('text/x-jade', 'jade');909192