mirror of https://github.com/status-im/codimd.git
Update CodeMirror to 5.19.0 and rename jade to pug
This commit is contained in:
parent
fb5d7e4359
commit
795ea21191
|
@ -144,7 +144,7 @@ var cursorMenuThrottle = 50;
|
|||
var cursorActivityDebounce = 50;
|
||||
var cursorAnimatePeriod = 100;
|
||||
var supportContainers = ['success', 'info', 'warning', 'danger'];
|
||||
var supportCodeModes = ['javascript', 'htmlmixed', 'htmlembedded', 'css', 'xml', 'clike', 'clojure', 'ruby', 'python', 'shell', 'php', 'sql', 'coffeescript', 'yaml', 'jade', 'lua', 'cmake', 'nginx', 'perl', 'sass', 'r', 'dockerfile', 'tiddlywiki', 'mediawiki'];
|
||||
var supportCodeModes = ['javascript', 'htmlmixed', 'htmlembedded', 'css', 'xml', 'clike', 'clojure', 'ruby', 'python', 'shell', 'php', 'sql', 'coffeescript', 'yaml', 'pug', 'lua', 'cmake', 'nginx', 'perl', 'sass', 'r', 'dockerfile', 'tiddlywiki', 'mediawiki'];
|
||||
var supportCharts = ['sequence', 'flow', 'graphviz', 'mermaid'];
|
||||
var supportHeaders = [
|
||||
{
|
||||
|
|
|
@ -103,6 +103,7 @@
|
|||
self.lineComment(from, to, options);
|
||||
return;
|
||||
}
|
||||
if (/\bcomment\b/.test(self.getTokenTypeAt(Pos(from.line, 0)))) return
|
||||
|
||||
var end = Math.min(to.line, self.lastLine());
|
||||
if (end != from.line && to.ch == 0 && nonWS.test(self.getLine(end))) --end;
|
||||
|
@ -140,7 +141,7 @@
|
|||
var line = self.getLine(i);
|
||||
var found = line.indexOf(lineString);
|
||||
if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1;
|
||||
if (found == -1 && (i != end || i == start) && nonWS.test(line)) break lineComment;
|
||||
if (found == -1 && nonWS.test(line)) break lineComment;
|
||||
if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment;
|
||||
lines.push(line);
|
||||
}
|
||||
|
@ -162,13 +163,15 @@
|
|||
var endString = options.blockCommentEnd || mode.blockCommentEnd;
|
||||
if (!startString || !endString) return false;
|
||||
var lead = options.blockCommentLead || mode.blockCommentLead;
|
||||
var startLine = self.getLine(start), endLine = end == start ? startLine : self.getLine(end);
|
||||
var open = startLine.indexOf(startString), close = endLine.lastIndexOf(endString);
|
||||
var startLine = self.getLine(start), open = startLine.indexOf(startString)
|
||||
if (open == -1) return false
|
||||
var endLine = end == start ? startLine : self.getLine(end)
|
||||
var close = endLine.indexOf(endString, end == start ? open + startString.length : 0);
|
||||
if (close == -1 && start != end) {
|
||||
endLine = self.getLine(--end);
|
||||
close = endLine.lastIndexOf(endString);
|
||||
close = endLine.indexOf(endString);
|
||||
}
|
||||
if (open == -1 || close == -1 ||
|
||||
if (close == -1 ||
|
||||
!/comment/.test(self.getTokenTypeAt(Pos(start, open + 1))) ||
|
||||
!/comment/.test(self.getTokenTypeAt(Pos(end, close + 1))))
|
||||
return false;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
function Iter(cm, line, ch, range) {
|
||||
this.line = line; this.ch = ch;
|
||||
this.cm = cm; this.text = cm.getLine(line);
|
||||
this.min = range ? range.from : cm.firstLine();
|
||||
this.max = range ? range.to - 1 : cm.lastLine();
|
||||
this.min = range ? Math.max(range.from, cm.firstLine()) : cm.firstLine();
|
||||
this.max = range ? Math.min(range.to - 1, cm.lastLine()) : cm.lastLine();
|
||||
}
|
||||
|
||||
function tagAt(iter, ch) {
|
||||
|
|
|
@ -97,6 +97,15 @@
|
|||
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
|
||||
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
|
||||
|
||||
function forAllProps(obj, callback) {
|
||||
if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) {
|
||||
for (var name in obj) callback(name)
|
||||
} else {
|
||||
for (var o = obj; o; o = Object.getPrototypeOf(o))
|
||||
Object.getOwnPropertyNames(o).forEach(callback)
|
||||
}
|
||||
}
|
||||
|
||||
function getCompletions(token, context, keywords, options) {
|
||||
var found = [], start = token.string, global = options && options.globalScope || window;
|
||||
function maybeAdd(str) {
|
||||
|
@ -106,7 +115,7 @@
|
|||
if (typeof obj == "string") forEach(stringProps, maybeAdd);
|
||||
else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
|
||||
else if (obj instanceof Function) forEach(funcProps, maybeAdd);
|
||||
for (var name in obj) maybeAdd(name);
|
||||
forAllProps(obj, maybeAdd)
|
||||
}
|
||||
|
||||
if (context && context.length) {
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name]
|
||||
this.overlay = this.timeout = null;
|
||||
this.matchesonscroll = null;
|
||||
this.active = false;
|
||||
}
|
||||
|
||||
CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) {
|
||||
|
@ -53,16 +54,34 @@
|
|||
clearTimeout(cm.state.matchHighlighter.timeout);
|
||||
cm.state.matchHighlighter = null;
|
||||
cm.off("cursorActivity", cursorActivity);
|
||||
cm.off("focus", onFocus)
|
||||
}
|
||||
if (val) {
|
||||
cm.state.matchHighlighter = new State(val);
|
||||
highlightMatches(cm);
|
||||
var state = cm.state.matchHighlighter = new State(val);
|
||||
if (cm.hasFocus()) {
|
||||
state.active = true
|
||||
highlightMatches(cm)
|
||||
} else {
|
||||
cm.on("focus", onFocus)
|
||||
}
|
||||
cm.on("cursorActivity", cursorActivity);
|
||||
}
|
||||
});
|
||||
|
||||
function cursorActivity(cm) {
|
||||
var state = cm.state.matchHighlighter;
|
||||
if (state.active || cm.hasFocus()) scheduleHighlight(cm, state)
|
||||
}
|
||||
|
||||
function onFocus(cm) {
|
||||
var state = cm.state.matchHighlighter
|
||||
if (!state.active) {
|
||||
state.active = true
|
||||
scheduleHighlight(cm, state)
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleHighlight(cm, state) {
|
||||
clearTimeout(state.timeout);
|
||||
state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay);
|
||||
}
|
||||
|
|
|
@ -136,8 +136,11 @@
|
|||
})
|
||||
};
|
||||
persistentDialog(cm, queryDialog, q, searchNext, function(event, query) {
|
||||
var cmd = CodeMirror.keyMap[cm.getOption("keyMap")][CodeMirror.keyName(event)];
|
||||
if (cmd == "findNext" || cmd == "findPrev") {
|
||||
var keyName = CodeMirror.keyName(event)
|
||||
var cmd = CodeMirror.keyMap[cm.getOption("keyMap")][keyName]
|
||||
if (!cmd) cmd = cm.getOption('extraKeys')[keyName]
|
||||
if (cmd == "findNext" || cmd == "findPrev" ||
|
||||
cmd == "findPersistentNext" || cmd == "findPersistentPrev") {
|
||||
CodeMirror.e_stop(event);
|
||||
startSearch(cm, getSearchState(cm), query);
|
||||
cm.execCommand(cmd);
|
||||
|
@ -146,7 +149,7 @@
|
|||
searchNext(query, event);
|
||||
}
|
||||
});
|
||||
if (immediate) {
|
||||
if (immediate && q) {
|
||||
startSearch(cm, state, q);
|
||||
findNext(cm, rev);
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -30,7 +30,7 @@ addon/fold/foldgutter.js \
|
|||
addon/fold/markdown-fold.js \
|
||||
addon/fold/xml-fold.js \
|
||||
mode/xml/xml.js \
|
||||
mode/markdown/markdown.js \
|
||||
mode/markdown/markdown_math.js \
|
||||
mode/gfm/gfm.js \
|
||||
mode/javascript/javascript.js \
|
||||
mode/css/css.js \
|
||||
|
@ -45,7 +45,7 @@ mode/php/php.js \
|
|||
mode/sql/sql.js \
|
||||
mode/coffeescript/coffeescript.js \
|
||||
mode/yaml/yaml.js \
|
||||
mode/jade/jade.js \
|
||||
mode/pug/pug.js \
|
||||
mode/lua/lua.js \
|
||||
mode/cmake/cmake.js \
|
||||
mode/nginx/nginx.js \
|
||||
|
|
|
@ -780,8 +780,12 @@
|
|||
|
||||
if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); }
|
||||
if (keysAreChars) {
|
||||
var here = cm.getCursor();
|
||||
cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
|
||||
var selections = cm.listSelections();
|
||||
for (var i = 0; i < selections.length; i++) {
|
||||
var here = selections[i].head;
|
||||
cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
|
||||
}
|
||||
vimGlobalState.macroModeState.lastInsertModeChanges.changes.pop();
|
||||
}
|
||||
clearInputState(cm);
|
||||
return match.command;
|
||||
|
@ -818,7 +822,7 @@
|
|||
// TODO: Look into using CodeMirror's multi-key handling.
|
||||
// Return no-op since we are caching the key. Counts as handled, but
|
||||
// don't want act on it just yet.
|
||||
return function() {};
|
||||
return function() { return true; };
|
||||
} else {
|
||||
return function() {
|
||||
return cm.operation(function() {
|
||||
|
@ -4874,6 +4878,10 @@
|
|||
if (changeObj.origin == '+input' || changeObj.origin == 'paste'
|
||||
|| changeObj.origin === undefined /* only in testing */) {
|
||||
var text = changeObj.text.join('\n');
|
||||
if (lastChange.maybeReset) {
|
||||
lastChange.changes = [];
|
||||
lastChange.maybeReset = false;
|
||||
}
|
||||
lastChange.changes.push(text);
|
||||
}
|
||||
// Change objects may be chained with next.
|
||||
|
@ -4896,7 +4904,7 @@
|
|||
lastChange.expectCursorActivityForChange = false;
|
||||
} else {
|
||||
// Cursor moved outside the context of an edit. Reset the change.
|
||||
lastChange.changes = [];
|
||||
lastChange.maybeReset = true;
|
||||
}
|
||||
} else if (!cm.curOp.isVimOp) {
|
||||
handleExternalSelection(cm, vim);
|
||||
|
@ -4960,6 +4968,10 @@
|
|||
var keyName = CodeMirror.keyName(e);
|
||||
if (!keyName) { return; }
|
||||
function onKeyFound() {
|
||||
if (lastChange.maybeReset) {
|
||||
lastChange.changes = [];
|
||||
lastChange.maybeReset = false;
|
||||
}
|
||||
lastChange.changes.push(new InsertModeKey(keyName));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -592,8 +592,12 @@
|
|||
var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
|
||||
var gutterW = display.gutters.offsetWidth, left = comp + "px";
|
||||
for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
|
||||
if (cm.options.fixedGutter && view[i].gutter)
|
||||
view[i].gutter.style.left = left;
|
||||
if (cm.options.fixedGutter) {
|
||||
if (view[i].gutter)
|
||||
view[i].gutter.style.left = left;
|
||||
if (view[i].gutterBackground)
|
||||
view[i].gutterBackground.style.left = left;
|
||||
}
|
||||
var align = view[i].alignable;
|
||||
if (align) for (var j = 0; j < align.length; j++)
|
||||
align[j].style.left = left;
|
||||
|
@ -1149,7 +1153,7 @@
|
|||
}
|
||||
|
||||
function handlePaste(e, cm) {
|
||||
var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
|
||||
var pasted = e.clipboardData && e.clipboardData.getData("Text");
|
||||
if (pasted) {
|
||||
e.preventDefault();
|
||||
if (!cm.isReadOnly() && !cm.options.disableInput)
|
||||
|
@ -1193,10 +1197,10 @@
|
|||
return {text: text, ranges: ranges};
|
||||
}
|
||||
|
||||
function disableBrowserMagic(field) {
|
||||
function disableBrowserMagic(field, spellcheck) {
|
||||
field.setAttribute("autocorrect", "off");
|
||||
field.setAttribute("autocapitalize", "off");
|
||||
field.setAttribute("spellcheck", "false");
|
||||
field.setAttribute("spellcheck", !!spellcheck);
|
||||
}
|
||||
|
||||
// TEXTAREA INPUT STYLE
|
||||
|
@ -1576,10 +1580,14 @@
|
|||
init: function(display) {
|
||||
var input = this, cm = input.cm;
|
||||
var div = input.div = display.lineDiv;
|
||||
disableBrowserMagic(div);
|
||||
disableBrowserMagic(div, cm.options.spellcheck);
|
||||
|
||||
on(div, "paste", function(e) {
|
||||
if (!signalDOMEvent(cm, e)) handlePaste(e, cm);
|
||||
if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return
|
||||
// IE doesn't fire input events, so we schedule a read for the pasted content in this way
|
||||
if (ie_version <= 11) setTimeout(operation(cm, function() {
|
||||
if (!input.pollContent()) regChange(cm);
|
||||
}), 20)
|
||||
})
|
||||
|
||||
on(div, "compositionstart", function(e) {
|
||||
|
@ -1639,23 +1647,27 @@
|
|||
});
|
||||
}
|
||||
}
|
||||
// iOS exposes the clipboard API, but seems to discard content inserted into it
|
||||
if (e.clipboardData && !ios) {
|
||||
e.preventDefault();
|
||||
if (e.clipboardData) {
|
||||
e.clipboardData.clearData();
|
||||
e.clipboardData.setData("text/plain", lastCopied.text.join("\n"));
|
||||
} else {
|
||||
// Old-fashioned briefly-focus-a-textarea hack
|
||||
var kludge = hiddenTextarea(), te = kludge.firstChild;
|
||||
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
|
||||
te.value = lastCopied.text.join("\n");
|
||||
var hadFocus = document.activeElement;
|
||||
selectInput(te);
|
||||
setTimeout(function() {
|
||||
cm.display.lineSpace.removeChild(kludge);
|
||||
hadFocus.focus();
|
||||
}, 50);
|
||||
var content = lastCopied.text.join("\n")
|
||||
// iOS exposes the clipboard API, but seems to discard content inserted into it
|
||||
e.clipboardData.setData("Text", content);
|
||||
if (e.clipboardData.getData("Text") == content) {
|
||||
e.preventDefault();
|
||||
return
|
||||
}
|
||||
}
|
||||
// Old-fashioned briefly-focus-a-textarea hack
|
||||
var kludge = hiddenTextarea(), te = kludge.firstChild;
|
||||
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
|
||||
te.value = lastCopied.text.join("\n");
|
||||
var hadFocus = document.activeElement;
|
||||
selectInput(te);
|
||||
setTimeout(function() {
|
||||
cm.display.lineSpace.removeChild(kludge);
|
||||
hadFocus.focus();
|
||||
if (hadFocus == div) input.showPrimarySelection()
|
||||
}, 50);
|
||||
}
|
||||
on(div, "copy", onCopyCut);
|
||||
on(div, "cut", onCopyCut);
|
||||
|
@ -1963,7 +1975,7 @@
|
|||
if (found)
|
||||
return badPos(Pos(found.line, found.ch + dist), bad);
|
||||
else
|
||||
dist += after.textContent.length;
|
||||
dist += before.textContent.length;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3533,8 +3545,8 @@
|
|||
on(inp, "keyup", function(e) { onKeyUp.call(cm, e); });
|
||||
on(inp, "keydown", operation(cm, onKeyDown));
|
||||
on(inp, "keypress", operation(cm, onKeyPress));
|
||||
on(inp, "focus", bind(onFocus, cm));
|
||||
on(inp, "blur", bind(onBlur, cm));
|
||||
on(inp, "focus", function (e) { onFocus(cm, e); });
|
||||
on(inp, "blur", function (e) { onBlur(cm, e); });
|
||||
}
|
||||
|
||||
function dragDropChanged(cm, value, old) {
|
||||
|
@ -4262,12 +4274,12 @@
|
|||
}, 100);
|
||||
}
|
||||
|
||||
function onFocus(cm) {
|
||||
function onFocus(cm, e) {
|
||||
if (cm.state.delayingBlurEvent) cm.state.delayingBlurEvent = false;
|
||||
|
||||
if (cm.options.readOnly == "nocursor") return;
|
||||
if (!cm.state.focused) {
|
||||
signal(cm, "focus", cm);
|
||||
signal(cm, "focus", cm, e);
|
||||
cm.state.focused = true;
|
||||
addClass(cm.display.wrapper, "CodeMirror-focused");
|
||||
// This test prevents this from firing when a context
|
||||
|
@ -4281,11 +4293,11 @@
|
|||
}
|
||||
restartBlink(cm);
|
||||
}
|
||||
function onBlur(cm) {
|
||||
function onBlur(cm, e) {
|
||||
if (cm.state.delayingBlurEvent) return;
|
||||
|
||||
if (cm.state.focused) {
|
||||
signal(cm, "blur", cm);
|
||||
signal(cm, "blur", cm, e);
|
||||
cm.state.focused = false;
|
||||
rmClass(cm.display.wrapper, "CodeMirror-focused");
|
||||
}
|
||||
|
@ -4907,7 +4919,8 @@
|
|||
var doc = cm.doc, x = pos.left, y;
|
||||
if (unit == "page") {
|
||||
var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
|
||||
y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display));
|
||||
var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3);
|
||||
y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount;
|
||||
} else if (unit == "line") {
|
||||
y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
|
||||
}
|
||||
|
@ -4960,7 +4973,10 @@
|
|||
addOverlay: methodOp(function(spec, options) {
|
||||
var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
|
||||
if (mode.startState) throw new Error("Overlays may not be stateful.");
|
||||
this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque});
|
||||
insertSorted(this.state.overlays,
|
||||
{mode: mode, modeSpec: spec, opaque: options && options.opaque,
|
||||
priority: (options && options.priority) || 0},
|
||||
function(overlay) { return overlay.priority })
|
||||
this.state.modeGen++;
|
||||
regChange(this);
|
||||
}),
|
||||
|
@ -5432,6 +5448,9 @@
|
|||
option("inputStyle", mobile ? "contenteditable" : "textarea", function() {
|
||||
throw new Error("inputStyle can not (yet) be changed in a running editor"); // FIXME
|
||||
}, true);
|
||||
option("spellcheck", false, function(cm, val) {
|
||||
cm.getInputField().spellcheck = val
|
||||
}, true);
|
||||
option("rtlMoveVisually", !windows);
|
||||
option("wholeLineUpdateBefore", true);
|
||||
|
||||
|
@ -5541,6 +5560,8 @@
|
|||
spec.name = found.name;
|
||||
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
|
||||
return CodeMirror.resolveMode("application/xml");
|
||||
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) {
|
||||
return CodeMirror.resolveMode("application/json");
|
||||
}
|
||||
if (typeof spec == "string") return {name: spec};
|
||||
else return spec || {name: "null"};
|
||||
|
@ -6852,7 +6873,7 @@
|
|||
}
|
||||
if (!flattenSpans || curStyle != style) {
|
||||
while (curStart < stream.start) {
|
||||
curStart = Math.min(stream.start, curStart + 50000);
|
||||
curStart = Math.min(stream.start, curStart + 5000);
|
||||
f(curStart, curStyle);
|
||||
}
|
||||
curStyle = style;
|
||||
|
@ -6860,8 +6881,10 @@
|
|||
stream.start = stream.pos;
|
||||
}
|
||||
while (curStart < stream.pos) {
|
||||
// Webkit seems to refuse to render text nodes longer than 57444 characters
|
||||
var pos = Math.min(stream.pos, curStart + 50000);
|
||||
// Webkit seems to refuse to render text nodes longer than 57444
|
||||
// characters, and returns inaccurate measurements in nodes
|
||||
// starting around 5000 chars.
|
||||
var pos = Math.min(stream.pos, curStart + 5000);
|
||||
f(pos, curStyle);
|
||||
curStart = pos;
|
||||
}
|
||||
|
@ -7970,7 +7993,7 @@
|
|||
}
|
||||
|
||||
// Register a change in the history. Merges changes that are within
|
||||
// a single operation, ore are close together with an origin that
|
||||
// a single operation, or are close together with an origin that
|
||||
// allows merging (starting with "+") into a single event.
|
||||
function addChangeToHistory(doc, change, selAfter, opId) {
|
||||
if(change.origin == "ignoreHistory") return;
|
||||
|
@ -8374,6 +8397,12 @@
|
|||
return out;
|
||||
}
|
||||
|
||||
function insertSorted(array, value, score) {
|
||||
var pos = 0, priority = score(value)
|
||||
while (pos < array.length && score(array[pos]) <= priority) pos++
|
||||
array.splice(pos, 0, value)
|
||||
}
|
||||
|
||||
function nothing() {}
|
||||
|
||||
function createObj(base, props) {
|
||||
|
@ -8942,7 +8971,7 @@
|
|||
|
||||
// THE END
|
||||
|
||||
CodeMirror.version = "5.17.1";
|
||||
CodeMirror.version = "5.19.0";
|
||||
|
||||
return CodeMirror;
|
||||
});
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
var curPunc;
|
||||
var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "keys", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "reverse", "right", "round", "rtrim", "shortestPath", "sign", "sin", "size", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "toString", "trim", "type", "upper"]);
|
||||
var preds = wordRegexp(["all", "and", "any", "contains", "exists", "has", "in", "none", "not", "or", "single", "xor"]);
|
||||
var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with"]);
|
||||
var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with", "call", "yield"]);
|
||||
var operatorChars = /[*+\-<>=&|~%^]/;
|
||||
|
||||
return {
|
||||
|
|
|
@ -433,15 +433,16 @@ CodeMirror.defineMode("erlang", function(cmCfg) {
|
|||
}
|
||||
|
||||
function maybe_drop_post(s) {
|
||||
if (!s.length) return s
|
||||
var last = s.length-1;
|
||||
|
||||
if (s[last].type === "dot") {
|
||||
return [];
|
||||
}
|
||||
if (s[last].type === "fun" && s[last-1].token === "fun") {
|
||||
if (last > 1 && s[last].type === "fun" && s[last-1].token === "fun") {
|
||||
return s.slice(0,last-1);
|
||||
}
|
||||
switch (s[s.length-1].token) {
|
||||
switch (s[last].token) {
|
||||
case "}": return d(s,{g:["{"]});
|
||||
case "]": return d(s,{i:["["]});
|
||||
case ")": return d(s,{i:["("]});
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
function getAttrValue(text, attr) {
|
||||
var match = text.match(getAttrRegexp(attr))
|
||||
return match ? match[2] : ""
|
||||
return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : ""
|
||||
}
|
||||
|
||||
function getTagRegexp(tagName, anchored) {
|
||||
|
|
|
@ -76,7 +76,6 @@ option.</p>
|
|||
<li><a href="http/index.html">HTTP</a></li>
|
||||
<li><a href="idl/index.html">IDL</a></li>
|
||||
<li><a href="clike/index.html">Java</a></li>
|
||||
<li><a href="jade/index.html">Jade</a></li>
|
||||
<li><a href="javascript/index.html">JavaScript</a> (<a href="jsx/index.html">JSX</a>)</li>
|
||||
<li><a href="jinja2/index.html">Jinja2</a></li>
|
||||
<li><a href="julia/index.html">Julia</a></li>
|
||||
|
@ -107,6 +106,7 @@ option.</p>
|
|||
<li><a href="powershell/index.html">PowerShell</a></li>
|
||||
<li><a href="properties/index.html">Properties files</a></li>
|
||||
<li><a href="protobuf/index.html">ProtoBuf</a></li>
|
||||
<li><a href="pug/index.html">Pug</a></li>
|
||||
<li><a href="puppet/index.html">Puppet</a></li>
|
||||
<li><a href="python/index.html">Python</a></li>
|
||||
<li><a href="q/index.html">Q</a></li>
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
// TODO actually recognize syntax of TypeScript constructs
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
|
@ -56,6 +54,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
"namespace": C,
|
||||
"module": kw("module"),
|
||||
"enum": kw("module"),
|
||||
"type": kw("type"),
|
||||
|
||||
// scope modifiers
|
||||
"public": kw("modifier"),
|
||||
|
@ -345,19 +344,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
|
||||
function statement(type, value) {
|
||||
if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);
|
||||
if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
|
||||
if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
|
||||
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
|
||||
if (type == "{") return cont(pushlex("}"), block, poplex);
|
||||
if (type == ";") return cont();
|
||||
if (type == "if") {
|
||||
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
|
||||
cx.state.cc.pop()();
|
||||
return cont(pushlex("form"), expression, statement, poplex, maybeelse);
|
||||
return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
|
||||
}
|
||||
if (type == "function") return cont(functiondef);
|
||||
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
|
||||
if (type == "variable") return cont(pushlex("stat"), maybelabel);
|
||||
if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
|
||||
if (type == "switch") return cont(pushlex("form"), parenExpr, pushlex("}", "switch"), expect("{"),
|
||||
block, poplex, poplex);
|
||||
if (type == "case") return cont(expression, expect(":"));
|
||||
if (type == "default") return cont(expect(":"));
|
||||
|
@ -367,6 +366,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
|
||||
if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
|
||||
if (type == "module") return cont(pushlex("form"), pattern, pushlex("}"), expect("{"), block, poplex, poplex)
|
||||
if (type == "type") return cont(typeexpr, expect("operator"), typeexpr, expect(";"));
|
||||
if (type == "async") return cont(statement)
|
||||
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
||||
}
|
||||
|
@ -376,6 +376,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
function expressionNoComma(type) {
|
||||
return expressionInner(type, true);
|
||||
}
|
||||
function parenExpr(type) {
|
||||
if (type != "(") return pass()
|
||||
return cont(pushlex(")"), expression, expect(")"), poplex)
|
||||
}
|
||||
function expressionInner(type, noComma) {
|
||||
if (cx.state.fatArrowAt == cx.stream.start) {
|
||||
var body = noComma ? arrowBodyNoComma : arrowBody;
|
||||
|
@ -463,8 +467,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
if (type == "variable") {cx.marked = "property"; return cont();}
|
||||
}
|
||||
function objprop(type, value) {
|
||||
if (type == "async") return cont(objprop);
|
||||
if (type == "variable" || cx.style == "keyword") {
|
||||
if (type == "async") {
|
||||
cx.marked = "property";
|
||||
return cont(objprop);
|
||||
} else if (type == "variable" || cx.style == "keyword") {
|
||||
cx.marked = "property";
|
||||
if (value == "get" || value == "set") return cont(getterSetter);
|
||||
return cont(afterprop);
|
||||
|
@ -479,6 +485,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
return cont(expression, expect("]"), afterprop);
|
||||
} else if (type == "spread") {
|
||||
return cont(expression);
|
||||
} else if (type == ":") {
|
||||
return pass(afterprop)
|
||||
}
|
||||
}
|
||||
function getterSetter(type) {
|
||||
|
@ -517,14 +525,34 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
if (type == "}") return cont();
|
||||
return pass(statement, block);
|
||||
}
|
||||
function maybetype(type) {
|
||||
if (isTS && type == ":") return cont(typeexpr);
|
||||
function maybetype(type, value) {
|
||||
if (isTS) {
|
||||
if (type == ":") return cont(typeexpr);
|
||||
if (value == "?") return cont(maybetype);
|
||||
}
|
||||
}
|
||||
function maybedefault(_, value) {
|
||||
if (value == "=") return cont(expressionNoComma);
|
||||
}
|
||||
function typeexpr(type) {
|
||||
if (type == "variable") {cx.marked = "variable-3"; return cont(afterType);}
|
||||
if (type == "{") return cont(commasep(typeprop, "}"))
|
||||
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
|
||||
}
|
||||
function maybeReturnType(type) {
|
||||
if (type == "=>") return cont(typeexpr)
|
||||
}
|
||||
function typeprop(type) {
|
||||
if (type == "variable" || cx.style == "keyword") {
|
||||
cx.marked = "property"
|
||||
return cont(typeprop)
|
||||
} else if (type == ":") {
|
||||
return cont(typeexpr)
|
||||
}
|
||||
}
|
||||
function typearg(type) {
|
||||
if (type == "variable") return cont(typearg)
|
||||
else if (type == ":") return cont(typeexpr)
|
||||
}
|
||||
function afterType(type, value) {
|
||||
if (value == "<") return cont(commasep(typeexpr, ">"), afterType)
|
||||
|
@ -593,18 +621,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
if (type == "variable") {register(value); return cont(classNameAfter);}
|
||||
}
|
||||
function classNameAfter(type, value) {
|
||||
if (value == "extends") return cont(expression, classNameAfter);
|
||||
if (value == "extends") return cont(isTS ? typeexpr : expression, classNameAfter);
|
||||
if (type == "{") return cont(pushlex("}"), classBody, poplex);
|
||||
}
|
||||
function classBody(type, value) {
|
||||
if (type == "variable" || cx.style == "keyword") {
|
||||
if (value == "static") {
|
||||
if ((value == "static" || value == "get" || value == "set" ||
|
||||
(isTS && (value == "public" || value == "private" || value == "protected"))) &&
|
||||
cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false)) {
|
||||
cx.marked = "keyword";
|
||||
return cont(classBody);
|
||||
}
|
||||
cx.marked = "property";
|
||||
if (value == "get" || value == "set") return cont(classGetterSetter, functiondef, classBody);
|
||||
return cont(functiondef, classBody);
|
||||
return cont(isTS ? classfield : functiondef, classBody);
|
||||
}
|
||||
if (value == "*") {
|
||||
cx.marked = "keyword";
|
||||
|
@ -613,10 +642,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
if (type == ";") return cont(classBody);
|
||||
if (type == "}") return cont();
|
||||
}
|
||||
function classGetterSetter(type) {
|
||||
if (type != "variable") return pass();
|
||||
cx.marked = "property";
|
||||
return cont();
|
||||
function classfield(type) {
|
||||
if (type == ":") return cont(typeexpr)
|
||||
return pass(functiondef)
|
||||
}
|
||||
function afterExport(_type, value) {
|
||||
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
|
||||
|
@ -685,14 +713,18 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
indent: function(state, textAfter) {
|
||||
if (state.tokenize == tokenComment) return CodeMirror.Pass;
|
||||
if (state.tokenize != tokenBase) return 0;
|
||||
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
|
||||
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top
|
||||
// Kludge to prevent 'maybelse' from blocking lexical scope pops
|
||||
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
|
||||
var c = state.cc[i];
|
||||
if (c == poplex) lexical = lexical.prev;
|
||||
else if (c != maybeelse) break;
|
||||
}
|
||||
if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
|
||||
while ((lexical.type == "stat" || lexical.type == "form") &&
|
||||
(firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
|
||||
(top == maybeoperatorComma || top == maybeoperatorNoComma) &&
|
||||
!/^[,\.=+\-*:?[\(]/.test(textAfter))))
|
||||
lexical = lexical.prev;
|
||||
if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
|
||||
lexical = lexical.prev;
|
||||
var type = lexical.type, closing = firstChar == type;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
MT("class",
|
||||
"[keyword class] [def Point] [keyword extends] [variable SuperThing] {",
|
||||
" [property get] [property prop]() { [keyword return] [number 24]; }",
|
||||
" [keyword get] [property prop]() { [keyword return] [number 24]; }",
|
||||
" [property constructor]([def x], [def y]) {",
|
||||
" [keyword super]([string 'something']);",
|
||||
" [keyword this].[property x] [operator =] [variable-2 x];",
|
||||
|
@ -140,6 +140,19 @@
|
|||
" [number 1];",
|
||||
"[number 2];");
|
||||
|
||||
MT("indent_semicolonless_if",
|
||||
"[keyword function] [def foo]() {",
|
||||
" [keyword if] ([variable x])",
|
||||
" [variable foo]()",
|
||||
"}")
|
||||
|
||||
MT("indent_semicolonless_if_with_statement",
|
||||
"[keyword function] [def foo]() {",
|
||||
" [keyword if] ([variable x])",
|
||||
" [variable foo]()",
|
||||
" [variable bar]()",
|
||||
"}")
|
||||
|
||||
MT("multilinestring",
|
||||
"[keyword var] [def x] [operator =] [string 'foo\\]",
|
||||
"[string bar'];");
|
||||
|
@ -167,6 +180,23 @@
|
|||
" }",
|
||||
"}");
|
||||
|
||||
var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript")
|
||||
function TS(name) {
|
||||
test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1))
|
||||
}
|
||||
|
||||
TS("extend_type",
|
||||
"[keyword class] [def Foo] [keyword extends] [variable-3 Some][operator <][variable-3 Type][operator >] {}")
|
||||
|
||||
TS("arrow_type",
|
||||
"[keyword let] [def x]: ([variable arg]: [variable-3 Type]) [operator =>] [variable-3 ReturnType]")
|
||||
|
||||
TS("typescript_class",
|
||||
"[keyword class] [def Foo] {",
|
||||
" [keyword public] [keyword static] [property main]() {}",
|
||||
" [keyword private] [property _foo]: [variable-3 string];",
|
||||
"}")
|
||||
|
||||
var jsonld_mode = CodeMirror.getMode(
|
||||
{indentUnit: 2},
|
||||
{name: "javascript", jsonld: true}
|
||||
|
|
|
@ -84,6 +84,6 @@ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|||
<p>JSX Mode for <a href="http://facebook.github.io/react">React</a>'s
|
||||
JavaScript syntax extension.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/jsx</code>.</p>
|
||||
<p><strong>MIME types defined:</strong> <code>text/jsx</code>, <code>text/typescript-jsx</code>.</p>
|
||||
|
||||
</article>
|
||||
|
|
|
@ -144,4 +144,5 @@
|
|||
}, "xml", "javascript")
|
||||
|
||||
CodeMirror.defineMIME("text/jsx", "jsx")
|
||||
CodeMirror.defineMIME("text/typescript-jsx", {name: "jsx", base: {name: "javascript", typescript: true}})
|
||||
});
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
startState: function(){
|
||||
return {
|
||||
next: 'start',
|
||||
lastToken: null
|
||||
lastToken: {style: null, indent: 0, content: ""}
|
||||
};
|
||||
},
|
||||
token: function(stream, state){
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
{name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
|
||||
{name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i},
|
||||
{name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
|
||||
{name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"]},
|
||||
{name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/},
|
||||
{name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
|
||||
{name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
|
||||
{name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"]},
|
||||
|
@ -66,7 +66,7 @@
|
|||
{name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm"], alias: ["xhtml"]},
|
||||
{name: "HTTP", mime: "message/http", mode: "http"},
|
||||
{name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]},
|
||||
{name: "Jade", mime: "text/x-jade", mode: "jade", ext: ["jade"]},
|
||||
{name: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"]},
|
||||
{name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
|
||||
{name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]},
|
||||
{name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Jade Templating Mode</title>
|
||||
<title>CodeMirror: Pug Templating Mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
|||
<script src="../css/css.js"></script>
|
||||
<script src="../xml/xml.js"></script>
|
||||
<script src="../htmlmixed/htmlmixed.js"></script>
|
||||
<script src="jade.js"></script>
|
||||
<script src="pug.js"></script>
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
@ -22,17 +22,17 @@
|
|||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">Jade Templating Mode</a>
|
||||
<li><a class=active href="#">Pug Templating Mode</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Jade Templating Mode</h2>
|
||||
<h2>Pug Templating Mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
doctype html
|
||||
html
|
||||
head
|
||||
title= "Jade Templating CodeMirror Mode Example"
|
||||
title= "Pug Templating CodeMirror Mode Example"
|
||||
link(rel='stylesheet', href='/css/bootstrap.min.css')
|
||||
link(rel='stylesheet', href='/css/index.css')
|
||||
script(type='text/javascript', src='/js/jquery-1.9.1.min.js')
|
||||
|
@ -60,11 +60,11 @@ doctype html
|
|||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: {name: "jade", alignCDATA: true},
|
||||
mode: {name: "pug", alignCDATA: true},
|
||||
lineNumbers: true
|
||||
});
|
||||
</script>
|
||||
<h3>The Jade Templating Mode</h3>
|
||||
<h3>The Pug Templating Mode</h3>
|
||||
<p> Created by Forbes Lindesay. Managed as part of a Brackets extension at <a href="https://github.com/ForbesLindesay/jade-brackets">https://github.com/ForbesLindesay/jade-brackets</a>.</p>
|
||||
<p><strong>MIME type defined:</strong> <code>text/x-jade</code>.</p>
|
||||
<p><strong>MIME type defined:</strong> <code>text/x-pug</code>, <code>text/x-jade</code>.</p>
|
||||
</article>
|
|
@ -11,7 +11,7 @@
|
|||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode('jade', function (config) {
|
||||
CodeMirror.defineMode("pug", function (config) {
|
||||
// token types
|
||||
var KEYWORD = 'keyword';
|
||||
var DOCTYPE = 'meta';
|
||||
|
@ -585,6 +585,7 @@ CodeMirror.defineMode('jade', function (config) {
|
|||
};
|
||||
}, 'javascript', 'css', 'htmlmixed');
|
||||
|
||||
CodeMirror.defineMIME('text/x-jade', 'jade');
|
||||
CodeMirror.defineMIME('text/x-pug', 'pug');
|
||||
CodeMirror.defineMIME('text/x-jade', 'pug');
|
||||
|
||||
});
|
|
@ -176,7 +176,7 @@ def pairwise_cython(double[:, ::1] X):
|
|||
</script>
|
||||
<h2>Configuration Options for Python mode:</h2>
|
||||
<ul>
|
||||
<li>version - 2/3 - The version of Python to recognize. Default is 2.</li>
|
||||
<li>version - 2/3 - The version of Python to recognize. Default is 3.</li>
|
||||
<li>singleLineStringErrors - true/false - If you have a single-line string that is not terminated at the end of the line, this will show subsequent lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false.</li>
|
||||
<li>hangingIndent - int - If you want to write long arguments to a function starting on a new line, how much that line should be indented. Defaults to one normal indentation unit.</li>
|
||||
</ul>
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
if (parserConf.extra_builtins != undefined)
|
||||
myBuiltins = myBuiltins.concat(parserConf.extra_builtins);
|
||||
|
||||
var py3 = parserConf.version && parseInt(parserConf.version, 10) == 3
|
||||
var py3 = !(parserConf.version && Number(parserConf.version) < 3)
|
||||
if (py3) {
|
||||
// since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator
|
||||
var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!@]/;
|
||||
|
@ -185,7 +185,7 @@
|
|||
}
|
||||
|
||||
function tokenStringFactory(delimiter) {
|
||||
while ("rub".indexOf(delimiter.charAt(0).toLowerCase()) >= 0)
|
||||
while ("rubf".indexOf(delimiter.charAt(0).toLowerCase()) >= 0)
|
||||
delimiter = delimiter.substr(1);
|
||||
|
||||
var singleline = delimiter.length == 1;
|
||||
|
|
|
@ -137,12 +137,13 @@
|
|||
stream.next();
|
||||
return 'comment';
|
||||
}
|
||||
} else if (!state.continueString && (ch === '"' || ch === "'")) {
|
||||
// Have we found a string?
|
||||
state.continueString = ch; //save the matching quote in the state
|
||||
return "string";
|
||||
} else if (state.continueString !== null) {
|
||||
if (stream.skipTo(state.continueString)) {
|
||||
} else if ((ch === '"' || ch === "'") && !state.continueString) {
|
||||
state.continueString = ch
|
||||
return "string"
|
||||
} else if (state.continueString) {
|
||||
if (state.continueString == ch) {
|
||||
state.continueString = null;
|
||||
} else if (stream.skipTo(state.continueString)) {
|
||||
// quote found on this line
|
||||
stream.next();
|
||||
state.continueString = null;
|
||||
|
@ -187,12 +188,12 @@
|
|||
if (stream.peek() === '.') stream.skipTo(' ');
|
||||
state.nextword = false;
|
||||
return 'variable-2';
|
||||
|
||||
}
|
||||
|
||||
word = word.toLowerCase()
|
||||
// Are we in a DATA Step?
|
||||
if (state.inDataStep) {
|
||||
if (word.toLowerCase() === 'run;' || stream.match(/run\s;/)) {
|
||||
if (word === 'run;' || stream.match(/run\s;/)) {
|
||||
state.inDataStep = false;
|
||||
return 'builtin';
|
||||
}
|
||||
|
@ -203,84 +204,84 @@
|
|||
else return 'variable';
|
||||
}
|
||||
// do we have a DATA Step keyword
|
||||
if (word && words.hasOwnProperty(word.toLowerCase()) &&
|
||||
(words[word.toLowerCase()].state.indexOf("inDataStep") !== -1 ||
|
||||
words[word.toLowerCase()].state.indexOf("ALL") !== -1)) {
|
||||
if (word && words.hasOwnProperty(word) &&
|
||||
(words[word].state.indexOf("inDataStep") !== -1 ||
|
||||
words[word].state.indexOf("ALL") !== -1)) {
|
||||
//backup to the start of the word
|
||||
if (stream.start < stream.pos)
|
||||
stream.backUp(stream.pos - stream.start);
|
||||
//advance the length of the word and return
|
||||
for (var i = 0; i < word.length; ++i) stream.next();
|
||||
return words[word.toLowerCase()].style;
|
||||
return words[word].style;
|
||||
}
|
||||
}
|
||||
// Are we in an Proc statement?
|
||||
if (state.inProc) {
|
||||
if (word.toLowerCase() === 'run;' || word.toLowerCase() === 'quit;') {
|
||||
if (word === 'run;' || word === 'quit;') {
|
||||
state.inProc = false;
|
||||
return 'builtin';
|
||||
}
|
||||
// do we have a proc keyword
|
||||
if (word && words.hasOwnProperty(word.toLowerCase()) &&
|
||||
(words[word.toLowerCase()].state.indexOf("inProc") !== -1 ||
|
||||
words[word.toLowerCase()].state.indexOf("ALL") !== -1)) {
|
||||
if (word && words.hasOwnProperty(word) &&
|
||||
(words[word].state.indexOf("inProc") !== -1 ||
|
||||
words[word].state.indexOf("ALL") !== -1)) {
|
||||
stream.match(/[\w]+/);
|
||||
return words[word].style;
|
||||
}
|
||||
}
|
||||
// Are we in a Macro statement?
|
||||
if (state.inMacro) {
|
||||
if (word.toLowerCase() === '%mend') {
|
||||
if (word === '%mend') {
|
||||
if (stream.peek() === ';') stream.next();
|
||||
state.inMacro = false;
|
||||
return 'builtin';
|
||||
}
|
||||
if (word && words.hasOwnProperty(word.toLowerCase()) &&
|
||||
(words[word.toLowerCase()].state.indexOf("inMacro") !== -1 ||
|
||||
words[word.toLowerCase()].state.indexOf("ALL") !== -1)) {
|
||||
if (word && words.hasOwnProperty(word) &&
|
||||
(words[word].state.indexOf("inMacro") !== -1 ||
|
||||
words[word].state.indexOf("ALL") !== -1)) {
|
||||
stream.match(/[\w]+/);
|
||||
return words[word.toLowerCase()].style;
|
||||
return words[word].style;
|
||||
}
|
||||
|
||||
return 'atom';
|
||||
}
|
||||
// Do we have Keywords specific words?
|
||||
if (word && words.hasOwnProperty(word.toLowerCase())) {
|
||||
if (word && words.hasOwnProperty(word)) {
|
||||
// Negates the initial next()
|
||||
stream.backUp(1);
|
||||
// Actually move the stream
|
||||
stream.match(/[\w]+/);
|
||||
if (word.toLowerCase() === 'data' && /=/.test(stream.peek()) === false) {
|
||||
if (word === 'data' && /=/.test(stream.peek()) === false) {
|
||||
state.inDataStep = true;
|
||||
state.nextword = true;
|
||||
return 'builtin';
|
||||
}
|
||||
if (word.toLowerCase() === 'proc') {
|
||||
if (word === 'proc') {
|
||||
state.inProc = true;
|
||||
state.nextword = true;
|
||||
return 'builtin';
|
||||
}
|
||||
if (word.toLowerCase() === '%macro') {
|
||||
if (word === '%macro') {
|
||||
state.inMacro = true;
|
||||
state.nextword = true;
|
||||
return 'builtin';
|
||||
}
|
||||
if (/title[1-9]/i.test(word)) return 'def';
|
||||
if (/title[1-9]/.test(word)) return 'def';
|
||||
|
||||
if (word.toLowerCase() === 'footnote') {
|
||||
if (word === 'footnote') {
|
||||
stream.eat(/[1-9]/);
|
||||
return 'def';
|
||||
}
|
||||
|
||||
// Returns their value as state in the prior define methods
|
||||
if (state.inDataStep === true && words[word.toLowerCase()].state.indexOf("inDataStep") !== -1)
|
||||
return words[word.toLowerCase()].style;
|
||||
if (state.inProc === true && words[word.toLowerCase()].state.indexOf("inProc") !== -1)
|
||||
return words[word.toLowerCase()].style;
|
||||
if (state.inMacro === true && words[word.toLowerCase()].state.indexOf("inMacro") !== -1)
|
||||
return words[word.toLowerCase()].style;
|
||||
if (words[word.toLowerCase()].state.indexOf("ALL") !== -1)
|
||||
return words[word.toLowerCase()].style;
|
||||
if (state.inDataStep === true && words[word].state.indexOf("inDataStep") !== -1)
|
||||
return words[word].style;
|
||||
if (state.inProc === true && words[word].state.indexOf("inProc") !== -1)
|
||||
return words[word].style;
|
||||
if (state.inMacro === true && words[word].state.indexOf("inMacro") !== -1)
|
||||
return words[word].style;
|
||||
if (words[word].state.indexOf("ALL") !== -1)
|
||||
return words[word].style;
|
||||
return null;
|
||||
}
|
||||
// Unrecognized syntax
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<script src="../css/css.js"></script>
|
||||
<script src="../coffeescript/coffeescript.js"></script>
|
||||
<script src="../sass/sass.js"></script>
|
||||
<script src="../jade/jade.js"></script>
|
||||
<script src="../pug/pug.js"></script>
|
||||
|
||||
<script src="../handlebars/handlebars.js"></script>
|
||||
<script src="../htmlmixed/htmlmixed.js"></script>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
require("../css/css"),
|
||||
require("../sass/sass"),
|
||||
require("../stylus/stylus"),
|
||||
require("../jade/jade"),
|
||||
require("../pug/pug"),
|
||||
require("../handlebars/handlebars"));
|
||||
} else if (typeof define === "function" && define.amd) { // AMD
|
||||
define(["../../lib/codemirror",
|
||||
|
@ -23,7 +23,7 @@
|
|||
"../css/css",
|
||||
"../sass/sass",
|
||||
"../stylus/stylus",
|
||||
"../jade/jade",
|
||||
"../pug/pug",
|
||||
"../handlebars/handlebars"], mod);
|
||||
} else { // Plain browser env
|
||||
mod(CodeMirror);
|
||||
|
@ -42,9 +42,9 @@
|
|||
],
|
||||
template: [
|
||||
["lang", /^vue-template$/i, "vue"],
|
||||
["lang", /^jade$/i, "jade"],
|
||||
["lang", /^pug$/i, "pug"],
|
||||
["lang", /^handlebars$/i, "handlebars"],
|
||||
["type", /^(text\/)?(x-)?jade$/i, "jade"],
|
||||
["type", /^(text\/)?(x-)?pug$/i, "pug"],
|
||||
["type", /^text\/x-handlebars-template$/i, "handlebars"],
|
||||
[null, null, "vue-template"]
|
||||
]
|
||||
|
@ -63,7 +63,7 @@
|
|||
|
||||
CodeMirror.defineMode("vue", function (config) {
|
||||
return CodeMirror.getMode(config, {name: "htmlmixed", tags: tagLanguages});
|
||||
}, "htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "jade", "handlebars");
|
||||
}, "htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "pug", "handlebars");
|
||||
|
||||
CodeMirror.defineMIME("script/x-vue", "vue");
|
||||
});
|
||||
|
|
|
@ -1,94 +1,85 @@
|
|||
/*
|
||||
|
||||
Name: Panda Syntax
|
||||
Author: Siamak Mokhtari (http://github.com/siamak/)
|
||||
|
||||
CodeMirror template by Siamak Mokhtari (https://github.com/siamak/atom-panda-syntax)
|
||||
|
||||
*/
|
||||
.cm-s-panda-syntax {
|
||||
/*font-family: 'Operator Mono', 'Source Sans Pro', Helvetica, Arial, sans-serif;*/
|
||||
font-family: 'Operator Mono', 'Source Sans Pro', Menlo, Monaco, Consolas, Courier New, monospace;
|
||||
background: #292A2B;
|
||||
color: #E6E6E6;
|
||||
line-height: 1.5;
|
||||
font-family: 'Operator Mono', 'Source Sans Pro', Menlo, Monaco, Consolas, Courier New, monospace;
|
||||
}
|
||||
.cm-s-panda-syntax .CodeMirror-cursor { border-color: #ff2c6d; }
|
||||
.cm-s-panda-syntax .CodeMirror-activeline-background {
|
||||
background: #404954;
|
||||
background: rgba(99, 123, 156, 0.1);
|
||||
}
|
||||
.cm-s-panda-syntax .CodeMirror-selected {
|
||||
background: #FFF;
|
||||
}
|
||||
|
||||
.cm-s-panda-syntax .cm-comment {
|
||||
font-style: italic;
|
||||
color: #676B79;
|
||||
}
|
||||
.cm-s-panda-syntax .cm-string,
|
||||
.cm-s-panda-syntax .cm-string-2 {
|
||||
.cm-s-panda-syntax .cm-operator {
|
||||
color: #f3f3f3;
|
||||
}
|
||||
.cm-s-panda-syntax .cm-string {
|
||||
color: #19F9D8;
|
||||
}
|
||||
.cm-s-panda-syntax .cm-string-2 {
|
||||
color: #FFB86C;
|
||||
}
|
||||
|
||||
.cm-s-panda-syntax .cm-tag {
|
||||
color: #ff2c6d;
|
||||
}
|
||||
.cm-s-panda-syntax .cm-meta {
|
||||
color: #b084eb;
|
||||
}
|
||||
|
||||
.cm-s-panda-syntax .cm-number {
|
||||
color: #FFB86C;
|
||||
}
|
||||
.cm-s-panda-syntax .cm-atom {
|
||||
color: #FFB86C;
|
||||
color: #ff2c6d;
|
||||
}
|
||||
|
||||
.cm-s-panda-syntax .cm-keyword {
|
||||
color: #FF75B5;
|
||||
}
|
||||
.cm-s-panda-syntax .cm-keyword-2 {
|
||||
color: #FF75B5;
|
||||
}
|
||||
.cm-s-panda-syntax .cm-keyword-3 {
|
||||
color: #B084EB;
|
||||
}
|
||||
|
||||
.cm-s-panda-syntax .cm-variable {
|
||||
color: #FF9AC1;
|
||||
color: #ffb86c;
|
||||
}
|
||||
.cm-s-panda-syntax .cm-variable-2 {
|
||||
color: #e6e6e6;
|
||||
color: #ff9ac1;
|
||||
}
|
||||
.cm-s-panda-syntax .cm-variable-3 {
|
||||
color: #82B1FF;
|
||||
color: #ff9ac1;
|
||||
}
|
||||
|
||||
.cm-s-panda-syntax .cm-def {
|
||||
/*font-style: italic;*/
|
||||
color: #e6e6e6;
|
||||
}
|
||||
.cm-s-panda-syntax .cm-def-2 {
|
||||
font-style: italic;
|
||||
color: #ffcc95;
|
||||
}
|
||||
|
||||
|
||||
.cm-s-panda-syntax .cm-property {
|
||||
color: #6FC1FF;
|
||||
color: #f3f3f3;
|
||||
}
|
||||
.cm-s-panda-syntax .cm-unit {
|
||||
color: #ffb86c;
|
||||
}
|
||||
|
||||
.cm-s-panda-syntax .cm-matchingbracket,
|
||||
.CodeMirror .CodeMirror-matchingbracket {
|
||||
color: #E6E6E6 !important;
|
||||
border-bottom: 1px dotted #19f9d8;
|
||||
padding-bottom: 2px;
|
||||
.cm-s-panda-syntax .cm-attribute {
|
||||
color: #ffb86c;
|
||||
}
|
||||
|
||||
.cm-s-panda-syntax .CodeMirror-gutters {
|
||||
background: #292A2B;
|
||||
color: #757575;
|
||||
border: none;
|
||||
.cm-s-panda-syntax .CodeMirror-matchingbracket {
|
||||
border-bottom: 1px dotted #19F9D8;
|
||||
padding-bottom: 2px;
|
||||
color: #e6e6e6;
|
||||
}
|
||||
.cm-s-panda-syntax .CodeMirror-guttermarker, .cm-s-panda-syntax .CodeMirror-guttermarker-subtle, .cm-s-panda-syntax .CodeMirror-linenumber {
|
||||
color: #757575;
|
||||
.CodeMirror-gutters {
|
||||
background: #292a2b;
|
||||
border-right-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
.cm-s-panda-syntax .CodeMirror-linenumber {
|
||||
padding-right: 10px;
|
||||
.CodeMirror-linenumber {
|
||||
color: #e6e6e6;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.cm-s-panda-syntax .CodeMirror-cursor {
|
||||
border-left: 1px solid #757575;
|
||||
}
|
||||
/*.cm-s-panda-syntax div.CodeMirror-selected { background: rgba(255, 255, 255, 0.5); }*/
|
||||
.cm-s-panda-syntax.CodeMirror-focused div.CodeMirror-selected { background: rgba(255, 255, 255, 0.25); }
|
||||
.cm-s-panda-syntax .CodeMirror-line::selection, .cm-s-panda-syntax .CodeMirror-line > span::selection, .cm-s-panda-syntax .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }
|
||||
.cm-s-panda-syntax .CodeMirror-line::-moz-selection, .cm-s-panda-syntax .CodeMirror-line > span::-moz-selection, .cm-s-panda-syntax .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }
|
||||
|
||||
.cm-s-panda-syntax .CodeMirror-activeline-background { background: rgba(99, 123, 156, 0.125); }
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
background: #2c2827;
|
||||
color: #8F938F;
|
||||
line-height: 1.5;
|
||||
font-size: 14px;
|
||||
}
|
||||
.cm-s-pastel-on-dark div.CodeMirror-selected { background: rgba(221,240,255,0.2); }
|
||||
.cm-s-pastel-on-dark .CodeMirror-line::selection, .cm-s-pastel-on-dark .CodeMirror-line > span::selection, .cm-s-pastel-on-dark .CodeMirror-line > span > span::selection { background: rgba(221,240,255,0.2); }
|
||||
|
|
|
@ -155,8 +155,8 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png
|
|||
.cm-s-solarized .CodeMirror-cursor { border-left: 1px solid #819090; }
|
||||
|
||||
/* Fat cursor */
|
||||
.cm-s-solarized.cm-s-light.cm-fat-cursor .CodeMirror-cursor { background: #fdf6e3; }
|
||||
.cm-s-solarized.cm-s-light .cm-animate-fat-cursor { background-color: #fdf6e3; }
|
||||
.cm-s-solarized.cm-s-light.cm-fat-cursor .CodeMirror-cursor { background: #77ee77; }
|
||||
.cm-s-solarized.cm-s-light .cm-animate-fat-cursor { background-color: #77ee77; }
|
||||
.cm-s-solarized.cm-s-dark.cm-fat-cursor .CodeMirror-cursor { background: #586e75; }
|
||||
.cm-s-solarized.cm-s-dark .cm-animate-fat-cursor { background-color: #586e75; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue