mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-29 14:25:38 -04:00
Update CodeMirror to version 5.15.3
This commit is contained in:
parent
16d5e3ea80
commit
fb70833bc5
41 changed files with 834 additions and 310 deletions
61
public/vendor/codemirror/mode/clike/clike.js
vendored
61
public/vendor/codemirror/mode/clike/clike.js
vendored
|
@ -11,21 +11,19 @@
|
|||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
function Context(indented, column, type, align, prev) {
|
||||
function Context(indented, column, type, info, align, prev) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.info = info;
|
||||
this.align = align;
|
||||
this.prev = prev;
|
||||
}
|
||||
function isStatement(type) {
|
||||
return type == "statement" || type == "switchstatement" || type == "namespace";
|
||||
}
|
||||
function pushContext(state, col, type) {
|
||||
function pushContext(state, col, type, info) {
|
||||
var indent = state.indented;
|
||||
if (state.context && isStatement(state.context.type) && !isStatement(type))
|
||||
if (state.context && state.context.type != "statement" && type != "statement")
|
||||
indent = state.context.indented;
|
||||
return state.context = new Context(indent, col, type, null, state.context);
|
||||
return state.context = new Context(indent, col, type, info, null, state.context);
|
||||
}
|
||||
function popContext(state) {
|
||||
var t = state.context.type;
|
||||
|
@ -34,15 +32,16 @@ function popContext(state) {
|
|||
return state.context = state.context.prev;
|
||||
}
|
||||
|
||||
function typeBefore(stream, state) {
|
||||
function typeBefore(stream, state, pos) {
|
||||
if (state.prevToken == "variable" || state.prevToken == "variable-3") return true;
|
||||
if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, stream.start))) return true;
|
||||
if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, pos))) return true;
|
||||
if (state.typeAtEndOfLine && stream.column() == stream.indentation()) return true;
|
||||
}
|
||||
|
||||
function isTopScope(context) {
|
||||
for (;;) {
|
||||
if (!context || context.type == "top") return true;
|
||||
if (context.type == "}" && context.prev.type != "namespace") return false;
|
||||
if (context.type == "}" && context.prev.info != "namespace") return false;
|
||||
context = context.prev;
|
||||
}
|
||||
}
|
||||
|
@ -147,13 +146,18 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
return "comment";
|
||||
}
|
||||
|
||||
function maybeEOL(stream, state) {
|
||||
if (parserConfig.typeFirstDefinitions && stream.eol() && isTopScope(state.context))
|
||||
state.typeAtEndOfLine = typeBefore(stream, state, stream.pos)
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: null,
|
||||
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
||||
context: new Context((basecolumn || 0) - indentUnit, 0, "top", null, false),
|
||||
indented: 0,
|
||||
startOfLine: true,
|
||||
prevToken: null
|
||||
|
@ -167,36 +171,31 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
state.indented = stream.indentation();
|
||||
state.startOfLine = true;
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
if (stream.eatSpace()) { maybeEOL(stream, state); return null; }
|
||||
curPunc = isDefKeyword = null;
|
||||
var style = (state.tokenize || tokenBase)(stream, state);
|
||||
if (style == "comment" || style == "meta") return style;
|
||||
if (ctx.align == null) ctx.align = true;
|
||||
|
||||
if (endStatement.test(curPunc)) while (isStatement(state.context.type)) popContext(state);
|
||||
if (endStatement.test(curPunc)) while (state.context.type == "statement") popContext(state);
|
||||
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
||||
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
||||
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
||||
else if (curPunc == "}") {
|
||||
while (isStatement(ctx.type)) ctx = popContext(state);
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
if (ctx.type == "}") ctx = popContext(state);
|
||||
while (isStatement(ctx.type)) ctx = popContext(state);
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
}
|
||||
else if (curPunc == ctx.type) popContext(state);
|
||||
else if (indentStatements &&
|
||||
(((ctx.type == "}" || ctx.type == "top") && curPunc != ";") ||
|
||||
(isStatement(ctx.type) && curPunc == "newstatement"))) {
|
||||
var type = "statement";
|
||||
if (curPunc == "newstatement" && indentSwitch && stream.current() == "switch")
|
||||
type = "switchstatement";
|
||||
else if (style == "keyword" && stream.current() == "namespace")
|
||||
type = "namespace";
|
||||
pushContext(state, stream.column(), type);
|
||||
(ctx.type == "statement" && curPunc == "newstatement"))) {
|
||||
pushContext(state, stream.column(), "statement", stream.current());
|
||||
}
|
||||
|
||||
if (style == "variable" &&
|
||||
((state.prevToken == "def" ||
|
||||
(parserConfig.typeFirstDefinitions && typeBefore(stream, state) &&
|
||||
(parserConfig.typeFirstDefinitions && typeBefore(stream, state, stream.start) &&
|
||||
isTopScope(state.context) && stream.match(/^\s*\(/, false)))))
|
||||
style = "def";
|
||||
|
||||
|
@ -209,24 +208,28 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
|
||||
state.startOfLine = false;
|
||||
state.prevToken = isDefKeyword ? "def" : style || curPunc;
|
||||
maybeEOL(stream, state);
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
|
||||
if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine) return CodeMirror.Pass;
|
||||
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
||||
if (isStatement(ctx.type) && firstChar == "}") ctx = ctx.prev;
|
||||
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
||||
if (parserConfig.dontIndentStatements)
|
||||
while (ctx.type == "statement" && parserConfig.dontIndentStatements.test(ctx.info))
|
||||
ctx = ctx.prev
|
||||
if (hooks.indent) {
|
||||
var hook = hooks.indent(state, ctx, textAfter);
|
||||
if (typeof hook == "number") return hook
|
||||
}
|
||||
var closing = firstChar == ctx.type;
|
||||
var switchBlock = ctx.prev && ctx.prev.type == "switchstatement";
|
||||
var switchBlock = ctx.prev && ctx.prev.info == "switch";
|
||||
if (parserConfig.allmanIndentation && /[{(]/.test(firstChar)) {
|
||||
while (ctx.type != "top" && ctx.type != "}") ctx = ctx.prev
|
||||
return ctx.indented
|
||||
}
|
||||
if (isStatement(ctx.type))
|
||||
if (ctx.type == "statement")
|
||||
return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
|
||||
if (ctx.align && (!dontAlignCalls || ctx.type != ")"))
|
||||
return ctx.column + (closing ? 0 : 1);
|
||||
|
@ -386,6 +389,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
defKeywords: words("class namespace struct enum union"),
|
||||
typeFirstDefinitions: true,
|
||||
atoms: words("true false null"),
|
||||
dontIndentStatements: /^template$/,
|
||||
hooks: {
|
||||
"#": cppHook,
|
||||
"*": pointerHook,
|
||||
|
@ -429,6 +433,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
typeFirstDefinitions: true,
|
||||
atoms: words("true false null"),
|
||||
endStatement: /^[;:]$/,
|
||||
number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i,
|
||||
hooks: {
|
||||
"@": function(stream) {
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
|
@ -531,7 +536,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
"=": function(stream, state) {
|
||||
var cx = state.context
|
||||
if (cx.type == "}" && cx.align && stream.eat(">")) {
|
||||
state.context = new Context(cx.indented, cx.column, cx.type, null, cx.prev)
|
||||
state.context = new Context(cx.indented, cx.column, cx.type, cx.info, null, cx.prev)
|
||||
return "operator"
|
||||
} else {
|
||||
return false
|
||||
|
|
4
public/vendor/codemirror/mode/clike/test.js
vendored
4
public/vendor/codemirror/mode/clike/test.js
vendored
|
@ -25,6 +25,10 @@
|
|||
"[keyword struct] [def bar]{}",
|
||||
"[variable-3 int] [variable-3 *][def baz]() {}");
|
||||
|
||||
MT("def_new_line",
|
||||
"::[variable std]::[variable SomeTerribleType][operator <][variable T][operator >]",
|
||||
"[def SomeLongMethodNameThatDoesntFitIntoOneLine]([keyword const] [variable MyType][operator &] [variable param]) {}")
|
||||
|
||||
MT("double_block",
|
||||
"[keyword for] (;;)",
|
||||
" [keyword for] (;;)",
|
||||
|
|
62
public/vendor/codemirror/mode/clojure/clojure.js
vendored
62
public/vendor/codemirror/mode/clojure/clojure.js
vendored
File diff suppressed because one or more lines are too long
12
public/vendor/codemirror/mode/css/css.js
vendored
12
public/vendor/codemirror/mode/css/css.js
vendored
|
@ -484,9 +484,9 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
|
||||
"font-variant-ligatures", "font-variant-numeric", "font-variant-position",
|
||||
"font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
|
||||
"grid-auto-position", "grid-auto-rows", "grid-column", "grid-column-end",
|
||||
"grid-column-start", "grid-row", "grid-row-end", "grid-row-start",
|
||||
"grid-template", "grid-template-areas", "grid-template-columns",
|
||||
"grid-auto-rows", "grid-column", "grid-column-end", "grid-column-gap",
|
||||
"grid-column-start", "grid-gap", "grid-row", "grid-row-end", "grid-row-gap",
|
||||
"grid-row-start", "grid-template", "grid-template-areas", "grid-template-columns",
|
||||
"grid-template-rows", "hanging-punctuation", "height", "hyphens",
|
||||
"icon", "image-orientation", "image-rendering", "image-resolution",
|
||||
"inline-box-align", "justify-content", "left", "letter-spacing",
|
||||
|
@ -601,7 +601,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"compact", "condensed", "contain", "content",
|
||||
"content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
|
||||
"cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
|
||||
"decimal-leading-zero", "default", "default-button", "destination-atop",
|
||||
"decimal-leading-zero", "default", "default-button", "dense", "destination-atop",
|
||||
"destination-in", "destination-out", "destination-over", "devanagari", "difference",
|
||||
"disc", "discard", "disclosure-closed", "disclosure-open", "document",
|
||||
"dot-dash", "dot-dot-dash",
|
||||
|
@ -615,13 +615,13 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
|
||||
"ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed",
|
||||
"extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes",
|
||||
"forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",
|
||||
"forwards", "from", "geometricPrecision", "georgian", "graytext", "grid", "groove",
|
||||
"gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew",
|
||||
"help", "hidden", "hide", "higher", "highlight", "highlighttext",
|
||||
"hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "icon", "ignore",
|
||||
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
|
||||
"infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
|
||||
"inline-block", "inline-flex", "inline-table", "inset", "inside", "intrinsic", "invert",
|
||||
"inline-block", "inline-flex", "inline-grid", "inline-table", "inset", "inside", "intrinsic", "invert",
|
||||
"italic", "japanese-formal", "japanese-informal", "justify", "kannada",
|
||||
"katakana", "katakana-iroha", "keep-all", "khmer",
|
||||
"korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal",
|
||||
|
|
2
public/vendor/codemirror/mode/ebnf/ebnf.js
vendored
2
public/vendor/codemirror/mode/ebnf/ebnf.js
vendored
|
@ -94,7 +94,7 @@
|
|||
|
||||
if (bracesMode !== null && (state.braced || peek === "{")) {
|
||||
if (state.localState === null)
|
||||
state.localState = bracesMode.startState();
|
||||
state.localState = CodeMirror.startState(bracesMode);
|
||||
|
||||
var token = bracesMode.token(stream, state.localState),
|
||||
text = stream.current();
|
||||
|
|
|
@ -77,5 +77,5 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-Fortran</code>.</p>
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-fortran</code>.</p>
|
||||
</article>
|
||||
|
|
4
public/vendor/codemirror/mode/haml/haml.js
vendored
4
public/vendor/codemirror/mode/haml/haml.js
vendored
|
@ -98,8 +98,8 @@
|
|||
return {
|
||||
// default to html mode
|
||||
startState: function() {
|
||||
var htmlState = htmlMode.startState();
|
||||
var rubyState = rubyMode.startState();
|
||||
var htmlState = CodeMirror.startState(htmlMode);
|
||||
var rubyState = CodeMirror.startState(rubyMode);
|
||||
return {
|
||||
htmlState: htmlState,
|
||||
rubyState: rubyState,
|
||||
|
|
|
@ -51,9 +51,10 @@ This is an example of EJS (embedded javascript)
|
|||
});
|
||||
</script>
|
||||
|
||||
<p>Mode for html embedded scripts like JSP and ASP.NET. Depends on HtmlMixed which in turn depends on
|
||||
<p>Mode for html embedded scripts like JSP and ASP.NET. Depends on multiplex and HtmlMixed which in turn depends on
|
||||
JavaScript, CSS and XML.<br />Other dependencies include those of the scripting language chosen.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>application/x-aspx</code> (ASP.NET),
|
||||
<code>application/x-ejs</code> (Embedded Javascript), <code>application/x-jsp</code> (JavaServer Pages)</p>
|
||||
<p><strong>MIME types defined:</strong> <code>application/x-aspx</code> (ASP.NET),
|
||||
<code>application/x-ejs</code> (Embedded Javascript), <code>application/x-jsp</code> (JavaServer Pages)
|
||||
and <code>application/x-erb</code></p>
|
||||
</article>
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
|
||||
return {
|
||||
startState: function () {
|
||||
var state = htmlMode.startState();
|
||||
var state = CodeMirror.startState(htmlMode);
|
||||
return {token: html, inTag: null, localMode: null, localState: null, htmlState: state};
|
||||
},
|
||||
|
||||
|
|
1
public/vendor/codemirror/mode/index.html
vendored
1
public/vendor/codemirror/mode/index.html
vendored
|
@ -86,6 +86,7 @@ option.</p>
|
|||
<li><a href="lua/index.html">Lua</a></li>
|
||||
<li><a href="markdown/index.html">Markdown</a> (<a href="gfm/index.html">GitHub-flavour</a>)</li>
|
||||
<li><a href="mathematica/index.html">Mathematica</a></li>
|
||||
<li><a href="mbox/index.html">mbox</a></li>
|
||||
<li><a href="mirc/index.html">mIRC</a></li>
|
||||
<li><a href="modelica/index.html">Modelica</a></li>
|
||||
<li><a href="mscgen/index.html">MscGen</a></li>
|
||||
|
|
6
public/vendor/codemirror/mode/jade/jade.js
vendored
6
public/vendor/codemirror/mode/jade/jade.js
vendored
|
@ -36,7 +36,7 @@ CodeMirror.defineMode('jade', function (config) {
|
|||
this.isInterpolating = false;
|
||||
this.interpolationNesting = 0;
|
||||
|
||||
this.jsState = jsMode.startState();
|
||||
this.jsState = CodeMirror.startState(jsMode);
|
||||
|
||||
this.restOfLine = '';
|
||||
|
||||
|
@ -386,7 +386,7 @@ CodeMirror.defineMode('jade', function (config) {
|
|||
if (state.inAttributeName && stream.match(/^[^=,\)!]+/)) {
|
||||
if (stream.peek() === '=' || stream.peek() === '!') {
|
||||
state.inAttributeName = false;
|
||||
state.jsState = jsMode.startState();
|
||||
state.jsState = CodeMirror.startState(jsMode);
|
||||
if (state.lastTag === 'script' && stream.current().trim().toLowerCase() === 'type') {
|
||||
state.attributeIsType = true;
|
||||
} else {
|
||||
|
@ -492,7 +492,7 @@ CodeMirror.defineMode('jade', function (config) {
|
|||
if (stream.indentation() > state.indentOf || (state.innerModeForLine && !stream.sol()) || force) {
|
||||
if (state.innerMode) {
|
||||
if (!state.innerState) {
|
||||
state.innerState = state.innerMode.startState ? state.innerMode.startState(stream.indentation()) : {};
|
||||
state.innerState = state.innerMode.startState ? CodeMirror.startState(state.innerMode, stream.indentation()) : {};
|
||||
}
|
||||
return stream.hideFirstChars(state.indentOf + 2, function () {
|
||||
return state.innerMode.token(stream, state.innerState) || true;
|
||||
|
|
|
@ -42,7 +42,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
"in": operator, "typeof": operator, "instanceof": operator,
|
||||
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
|
||||
"this": kw("this"), "class": kw("class"), "super": kw("atom"),
|
||||
"yield": C, "export": kw("export"), "import": kw("import"), "extends": C
|
||||
"yield": C, "export": kw("export"), "import": kw("import"), "extends": C,
|
||||
"await": C, "async": kw("async")
|
||||
};
|
||||
|
||||
// Extend the 'normal' keywords with the TypeScript language extensions
|
||||
|
@ -366,6 +367,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 == "async") return cont(statement)
|
||||
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
||||
}
|
||||
function expression(type) {
|
||||
|
@ -488,17 +490,17 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
if (type == "(") return pass(functiondef);
|
||||
}
|
||||
function commasep(what, end) {
|
||||
function proceed(type) {
|
||||
function proceed(type, value) {
|
||||
if (type == ",") {
|
||||
var lex = cx.state.lexical;
|
||||
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
|
||||
return cont(what, proceed);
|
||||
}
|
||||
if (type == end) return cont();
|
||||
if (type == end || value == end) return cont();
|
||||
return cont(expect(end));
|
||||
}
|
||||
return function(type) {
|
||||
if (type == end) return cont();
|
||||
return function(type, value) {
|
||||
if (type == end || value == end) return cont();
|
||||
return pass(what, proceed);
|
||||
};
|
||||
}
|
||||
|
@ -512,13 +514,17 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
return pass(statement, block);
|
||||
}
|
||||
function maybetype(type) {
|
||||
if (isTS && type == ":") return cont(typedef);
|
||||
if (isTS && type == ":") return cont(typeexpr);
|
||||
}
|
||||
function maybedefault(_, value) {
|
||||
if (value == "=") return cont(expressionNoComma);
|
||||
}
|
||||
function typedef(type) {
|
||||
if (type == "variable") {cx.marked = "variable-3"; return cont();}
|
||||
function typeexpr(type) {
|
||||
if (type == "variable") {cx.marked = "variable-3"; return cont(afterType);}
|
||||
}
|
||||
function afterType(type, value) {
|
||||
if (value == "<") return cont(commasep(typeexpr, ">"), afterType)
|
||||
if (type == "[") return cont(expect("]"), afterType)
|
||||
}
|
||||
function vardef() {
|
||||
return pass(pattern, maybetype, maybeAssign, vardefCont);
|
||||
|
@ -573,7 +579,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
function functiondef(type, value) {
|
||||
if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
|
||||
if (type == "variable") {register(value); return cont(functiondef);}
|
||||
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, statement, popcontext);
|
||||
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, maybetype, statement, popcontext);
|
||||
}
|
||||
function funarg(type) {
|
||||
if (type == "spread") return cont(funarg);
|
||||
|
|
|
@ -218,7 +218,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
state.fencedChars = match[1]
|
||||
// try switching mode
|
||||
state.localMode = getMode(match[2]);
|
||||
if (state.localMode) state.localState = state.localMode.startState();
|
||||
if (state.localMode) state.localState = CodeMirror.startState(state.localMode);
|
||||
state.f = state.block = local;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
||||
state.code = -1
|
||||
|
@ -437,13 +437,13 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
return tokenTypes.image;
|
||||
}
|
||||
|
||||
if (ch === '[' && stream.match(/.*\](\(.*\)| ?\[.*\])/, false)) {
|
||||
if (ch === '[' && stream.match(/[^\]]*\](\(.*\)| ?\[.*?\])/, false)) {
|
||||
state.linkText = true;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
if (ch === ']' && state.linkText && stream.match(/\(.*\)| ?\[.*\]/, false)) {
|
||||
if (ch === ']' && state.linkText && stream.match(/\(.*?\)| ?\[.*?\]/, false)) {
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
var type = getType(state);
|
||||
state.linkText = false;
|
||||
|
@ -596,7 +596,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
}
|
||||
var ch = stream.next();
|
||||
if (ch === '(' || ch === '[') {
|
||||
state.f = state.inline = getLinkHrefInside(ch === "(" ? ")" : "]");
|
||||
state.f = state.inline = getLinkHrefInside(ch === "(" ? ")" : "]", 0);
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link-string";
|
||||
state.linkHref = true;
|
||||
return getType(state);
|
||||
|
@ -604,6 +604,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
return 'error';
|
||||
}
|
||||
|
||||
var linkRE = {
|
||||
")": /^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,
|
||||
"]": /^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\\]]|\\.)*\])*?(?=\])/
|
||||
}
|
||||
|
||||
function getLinkHrefInside(endChar) {
|
||||
return function(stream, state) {
|
||||
var ch = stream.next();
|
||||
|
@ -616,10 +621,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
return returnState;
|
||||
}
|
||||
|
||||
if (stream.match(inlineRE(endChar), true)) {
|
||||
stream.backUp(1);
|
||||
}
|
||||
|
||||
stream.match(linkRE[endChar])
|
||||
state.linkHref = true;
|
||||
return getType(state);
|
||||
};
|
||||
|
@ -667,18 +669,6 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
return tokenTypes.linkHref + " url";
|
||||
}
|
||||
|
||||
var savedInlineRE = [];
|
||||
function inlineRE(endChar) {
|
||||
if (!savedInlineRE[endChar]) {
|
||||
// Escape endChar for RegExp (taken from http://stackoverflow.com/a/494122/526741)
|
||||
endChar = (endChar+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
|
||||
// Match any non-endChar, escaped character, as well as the closing
|
||||
// endChar.
|
||||
savedInlineRE[endChar] = new RegExp('^(?:[^\\\\]|\\\\.)*?(' + endChar + ')');
|
||||
}
|
||||
return savedInlineRE[endChar];
|
||||
}
|
||||
|
||||
var mode = {
|
||||
startState: function() {
|
||||
return {
|
||||
|
|
|
@ -782,6 +782,9 @@
|
|||
MT("emStrongMixed",
|
||||
"[em *foo][em&strong __bar_hello** world]");
|
||||
|
||||
MT("linkWithNestedParens",
|
||||
"[link [[foo]]][string&url (bar(baz))]")
|
||||
|
||||
// These characters should be escaped:
|
||||
// \ backslash
|
||||
// ` backtick
|
||||
|
|
44
public/vendor/codemirror/mode/mbox/index.html
vendored
Normal file
44
public/vendor/codemirror/mode/mbox/index.html
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: mbox mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="mbox.js"></script>
|
||||
<style>.CodeMirror { border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; }</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">mbox</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>mbox mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
From timothygu99@gmail.com Sun Apr 17 01:40:43 2016
|
||||
From: Timothy Gu <timothygu99@gmail.com>
|
||||
Date: Sat, 16 Apr 2016 18:40:43 -0700
|
||||
Subject: mbox mode
|
||||
Message-ID: <Z8d+bTT50U/az94FZnyPkDjZmW0=@gmail.com>
|
||||
|
||||
mbox mode is working!
|
||||
|
||||
Timothy
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>application/mbox</code>.</p>
|
||||
|
||||
</article>
|
129
public/vendor/codemirror/mode/mbox/mbox.js
vendored
Normal file
129
public/vendor/codemirror/mode/mbox/mbox.js
vendored
Normal file
|
@ -0,0 +1,129 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(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";
|
||||
|
||||
var rfc2822 = [
|
||||
"From", "Sender", "Reply-To", "To", "Cc", "Bcc", "Message-ID",
|
||||
"In-Reply-To", "References", "Resent-From", "Resent-Sender", "Resent-To",
|
||||
"Resent-Cc", "Resent-Bcc", "Resent-Message-ID", "Return-Path", "Received"
|
||||
];
|
||||
var rfc2822NoEmail = [
|
||||
"Date", "Subject", "Comments", "Keywords", "Resent-Date"
|
||||
];
|
||||
|
||||
CodeMirror.registerHelper("hintWords", "mbox", rfc2822.concat(rfc2822NoEmail));
|
||||
|
||||
var whitespace = /^[ \t]/;
|
||||
var separator = /^From /; // See RFC 4155
|
||||
var rfc2822Header = new RegExp("^(" + rfc2822.join("|") + "): ");
|
||||
var rfc2822HeaderNoEmail = new RegExp("^(" + rfc2822NoEmail.join("|") + "): ");
|
||||
var header = /^[^:]+:/; // Optional fields defined in RFC 2822
|
||||
var email = /^[^ ]+@[^ ]+/;
|
||||
var untilEmail = /^.*?(?=[^ ]+?@[^ ]+)/;
|
||||
var bracketedEmail = /^<.*?>/;
|
||||
var untilBracketedEmail = /^.*?(?=<.*>)/;
|
||||
|
||||
function styleForHeader(header) {
|
||||
if (header === "Subject") return "header";
|
||||
return "string";
|
||||
}
|
||||
|
||||
function readToken(stream, state) {
|
||||
if (stream.sol()) {
|
||||
// From last line
|
||||
state.inSeparator = false;
|
||||
if (state.inHeader && stream.match(whitespace)) {
|
||||
// Header folding
|
||||
return null;
|
||||
} else {
|
||||
state.inHeader = false;
|
||||
state.header = null;
|
||||
}
|
||||
|
||||
if (stream.match(separator)) {
|
||||
state.inHeaders = true;
|
||||
state.inSeparator = true;
|
||||
return "atom";
|
||||
}
|
||||
|
||||
var match;
|
||||
var emailPermitted = false;
|
||||
if ((match = stream.match(rfc2822HeaderNoEmail)) ||
|
||||
(emailPermitted = true) && (match = stream.match(rfc2822Header))) {
|
||||
state.inHeaders = true;
|
||||
state.inHeader = true;
|
||||
state.emailPermitted = emailPermitted;
|
||||
state.header = match[1];
|
||||
return "atom";
|
||||
}
|
||||
|
||||
// Use vim's heuristics: recognize custom headers only if the line is in a
|
||||
// block of legitimate headers.
|
||||
if (state.inHeaders && (match = stream.match(header))) {
|
||||
state.inHeader = true;
|
||||
state.emailPermitted = true;
|
||||
state.header = match[1];
|
||||
return "atom";
|
||||
}
|
||||
|
||||
state.inHeaders = false;
|
||||
stream.skipToEnd();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (state.inSeparator) {
|
||||
if (stream.match(email)) return "link";
|
||||
if (stream.match(untilEmail)) return "atom";
|
||||
stream.skipToEnd();
|
||||
return "atom";
|
||||
}
|
||||
|
||||
if (state.inHeader) {
|
||||
var style = styleForHeader(state.header);
|
||||
|
||||
if (state.emailPermitted) {
|
||||
if (stream.match(bracketedEmail)) return style + " link";
|
||||
if (stream.match(untilBracketedEmail)) return style;
|
||||
}
|
||||
stream.skipToEnd();
|
||||
return style;
|
||||
}
|
||||
|
||||
stream.skipToEnd();
|
||||
return null;
|
||||
};
|
||||
|
||||
CodeMirror.defineMode("mbox", function() {
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
// Is in a mbox separator
|
||||
inSeparator: false,
|
||||
// Is in a mail header
|
||||
inHeader: false,
|
||||
// If bracketed email is permitted. Only applicable when inHeader
|
||||
emailPermitted: false,
|
||||
// Name of current header
|
||||
header: null,
|
||||
// Is in a region of mail headers
|
||||
inHeaders: false
|
||||
};
|
||||
},
|
||||
token: readToken,
|
||||
blankLine: function(state) {
|
||||
state.inHeaders = state.inSeparator = state.inHeader = false;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("application/mbox", "mbox");
|
||||
});
|
1
public/vendor/codemirror/mode/meta.js
vendored
1
public/vendor/codemirror/mode/meta.js
vendored
|
@ -87,6 +87,7 @@
|
|||
{name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"]},
|
||||
{name: "MUMPS", mime: "text/x-mumps", mode: "mumps", ext: ["mps"]},
|
||||
{name: "MS SQL", mime: "text/x-mssql", mode: "sql"},
|
||||
{name: "mbox", mime: "application/mbox", mode: "mbox", ext: ["mbox"]},
|
||||
{name: "MySQL", mime: "text/x-mysql", mode: "sql"},
|
||||
{name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx", file: /nginx.*\.conf$/i},
|
||||
{name: "NSIS", mime: "text/x-nsis", mode: "nsis", ext: ["nsh", "nsi"]},
|
||||
|
|
2
public/vendor/codemirror/mode/pegjs/pegjs.js
vendored
2
public/vendor/codemirror/mode/pegjs/pegjs.js
vendored
|
@ -81,7 +81,7 @@ CodeMirror.defineMode("pegjs", function (config) {
|
|||
return "comment";
|
||||
} else if (state.braced || stream.peek() === '{') {
|
||||
if (state.localState === null) {
|
||||
state.localState = jsMode.startState();
|
||||
state.localState = CodeMirror.startState(jsMode);
|
||||
}
|
||||
var token = jsMode.token(stream, state.localState);
|
||||
var text = stream.current();
|
||||
|
|
2
public/vendor/codemirror/mode/php/php.js
vendored
2
public/vendor/codemirror/mode/php/php.js
vendored
File diff suppressed because one or more lines are too long
48
public/vendor/codemirror/mode/python/python.js
vendored
48
public/vendor/codemirror/mode/python/python.js
vendored
|
@ -32,13 +32,6 @@
|
|||
"sorted", "staticmethod", "str", "sum", "super", "tuple",
|
||||
"type", "vars", "zip", "__import__", "NotImplemented",
|
||||
"Ellipsis", "__debug__"];
|
||||
var py2 = {builtins: ["apply", "basestring", "buffer", "cmp", "coerce", "execfile",
|
||||
"file", "intern", "long", "raw_input", "reduce", "reload",
|
||||
"unichr", "unicode", "xrange", "False", "True", "None"],
|
||||
keywords: ["exec", "print"]};
|
||||
var py3 = {builtins: ["ascii", "bytes", "exec", "print"],
|
||||
keywords: ["nonlocal", "False", "True", "None", "async", "await"]};
|
||||
|
||||
CodeMirror.registerHelper("hintWords", "python", commonKeywords.concat(commonBuiltins));
|
||||
|
||||
function top(state) {
|
||||
|
@ -53,15 +46,6 @@
|
|||
var doubleDelimiters = parserConf.doubleDelimiters || /^(\+=|\-=|\*=|%=|\/=|&=|\|=|\^=)/;
|
||||
var tripleDelimiters = parserConf.tripleDelimiters || /^(\/\/=|>>=|<<=|\*\*=)/;
|
||||
|
||||
if (parserConf.version && parseInt(parserConf.version, 10) == 3) {
|
||||
// since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator
|
||||
var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!@]/;
|
||||
var identifiers = parserConf.identifiers|| /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/;
|
||||
} else {
|
||||
var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!]/;
|
||||
var identifiers = parserConf.identifiers|| /^[_A-Za-z][_A-Za-z0-9]*/;
|
||||
}
|
||||
|
||||
var hangingIndent = parserConf.hangingIndent || conf.indentUnit;
|
||||
|
||||
var myKeywords = commonKeywords, myBuiltins = commonBuiltins;
|
||||
|
@ -71,13 +55,21 @@
|
|||
if (parserConf.extra_builtins != undefined)
|
||||
myBuiltins = myBuiltins.concat(parserConf.extra_builtins);
|
||||
|
||||
if (parserConf.version && parseInt(parserConf.version, 10) == 3) {
|
||||
myKeywords = myKeywords.concat(py3.keywords);
|
||||
myBuiltins = myBuiltins.concat(py3.builtins);
|
||||
var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i");
|
||||
var py3 = parserConf.version && parseInt(parserConf.version, 10) == 3
|
||||
if (py3) {
|
||||
// since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator
|
||||
var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!@]/;
|
||||
var identifiers = parserConf.identifiers|| /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/;
|
||||
myKeywords = myKeywords.concat(["nonlocal", "False", "True", "None", "async", "await"]);
|
||||
myBuiltins = myBuiltins.concat(["ascii", "bytes", "exec", "print"]);
|
||||
var stringPrefixes = new RegExp("^(([rbuf]|(br))?('{3}|\"{3}|['\"]))", "i");
|
||||
} else {
|
||||
myKeywords = myKeywords.concat(py2.keywords);
|
||||
myBuiltins = myBuiltins.concat(py2.builtins);
|
||||
var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!]/;
|
||||
var identifiers = parserConf.identifiers|| /^[_A-Za-z][_A-Za-z0-9]*/;
|
||||
myKeywords = myKeywords.concat(["exec", "print"]);
|
||||
myBuiltins = myBuiltins.concat(["apply", "basestring", "buffer", "cmp", "coerce", "execfile",
|
||||
"file", "intern", "long", "raw_input", "reduce", "reload",
|
||||
"unichr", "unicode", "xrange", "False", "True", "None"]);
|
||||
var stringPrefixes = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i");
|
||||
}
|
||||
var keywords = wordRegexp(myKeywords);
|
||||
|
@ -249,16 +241,16 @@
|
|||
}
|
||||
|
||||
function tokenLexer(stream, state) {
|
||||
if (stream.sol()) state.beginningOfLine = true;
|
||||
|
||||
var style = state.tokenize(stream, state);
|
||||
var current = stream.current();
|
||||
|
||||
// Handle decorators
|
||||
if (current == "@") {
|
||||
if (parserConf.version && parseInt(parserConf.version, 10) == 3)
|
||||
return stream.match(identifiers, false) ? "meta" : "operator";
|
||||
else
|
||||
return stream.match(identifiers, false) ? "meta" : ERRORCLASS;
|
||||
}
|
||||
if (state.beginningOfLine && current == "@")
|
||||
return stream.match(identifiers, false) ? "meta" : py3 ? "operator" : ERRORCLASS;
|
||||
|
||||
if (/\S/.test(current)) state.beginningOfLine = false;
|
||||
|
||||
if ((style == "variable" || style == "builtin")
|
||||
&& state.lastToken == "meta")
|
||||
|
|
30
public/vendor/codemirror/mode/python/test.js
vendored
Normal file
30
public/vendor/codemirror/mode/python/test.js
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({indentUnit: 4},
|
||||
{name: "python",
|
||||
version: 3,
|
||||
singleLineStringErrors: false});
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
// Error, because "foobarhello" is neither a known type or property, but
|
||||
// property was expected (after "and"), and it should be in parentheses.
|
||||
MT("decoratorStartOfLine",
|
||||
"[meta @dec]",
|
||||
"[keyword def] [def function]():",
|
||||
" [keyword pass]");
|
||||
|
||||
MT("decoratorIndented",
|
||||
"[keyword class] [def Foo]:",
|
||||
" [meta @dec]",
|
||||
" [keyword def] [def function]():",
|
||||
" [keyword pass]");
|
||||
|
||||
MT("matmulWithSpace:", "[variable a] [operator @] [variable b]");
|
||||
MT("matmulWithoutSpace:", "[variable a][operator @][variable b]");
|
||||
MT("matmulSpaceBefore:", "[variable a] [operator @][variable b]");
|
||||
|
||||
MT("fValidStringPrefix", "[string f'this is a {formatted} string']");
|
||||
MT("uValidStringPrefix", "[string u'this is an unicode string']");
|
||||
})();
|
8
public/vendor/codemirror/mode/slim/slim.js
vendored
8
public/vendor/codemirror/mode/slim/slim.js
vendored
|
@ -165,7 +165,7 @@
|
|||
};
|
||||
return function(stream, state) {
|
||||
rubyState = state.rubyState;
|
||||
state.rubyState = rubyMode.startState();
|
||||
state.rubyState = CodeMirror.startState(rubyMode);
|
||||
state.tokenize = runSplat;
|
||||
return ruby(stream, state);
|
||||
};
|
||||
|
@ -317,7 +317,7 @@
|
|||
|
||||
function startSubMode(mode, state) {
|
||||
var subMode = getMode(mode);
|
||||
var subState = subMode.startState && subMode.startState();
|
||||
var subState = CodeMirror.startState(subMode);
|
||||
|
||||
state.subMode = subMode;
|
||||
state.subState = subState;
|
||||
|
@ -507,8 +507,8 @@
|
|||
var mode = {
|
||||
// default to html mode
|
||||
startState: function() {
|
||||
var htmlState = htmlMode.startState();
|
||||
var rubyState = rubyMode.startState();
|
||||
var htmlState = CodeMirror.startState(htmlMode);
|
||||
var rubyState = CodeMirror.startState(rubyMode);
|
||||
return {
|
||||
htmlState: htmlState,
|
||||
rubyState: rubyState,
|
||||
|
|
12
public/vendor/codemirror/mode/webidl/webidl.js
vendored
12
public/vendor/codemirror/mode/webidl/webidl.js
vendored
|
@ -85,6 +85,7 @@ var singleOperators = /^[:<=>?]/;
|
|||
var integers = /^-?([1-9][0-9]*|0[Xx][0-9A-Fa-f]+|0[0-7]*)/;
|
||||
var floats = /^-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)/;
|
||||
var identifiers = /^_?[A-Za-z][0-9A-Z_a-z-]*/;
|
||||
var identifiersEnd = /^_?[A-Za-z][0-9A-Z_a-z-]*(?=\s*;)/;
|
||||
var strings = /^"[^"]*"/;
|
||||
var multilineComments = /^\/\*.*?\*\//;
|
||||
var multilineCommentsStart = /^\/\*.*/;
|
||||
|
@ -122,12 +123,11 @@ function readToken(stream, state) {
|
|||
if (stream.match(strings)) return "string";
|
||||
|
||||
// identifier
|
||||
if (stream.match(identifiers)) {
|
||||
if (state.startDef) return "def";
|
||||
if (state.endDef && stream.match(/^\s*;/, false)) {
|
||||
state.endDef = false;
|
||||
return "def";
|
||||
}
|
||||
if (state.startDef && stream.match(identifiers)) return "def";
|
||||
|
||||
if (state.endDef && stream.match(identifiersEnd)) {
|
||||
state.endDef = false;
|
||||
return "def";
|
||||
}
|
||||
|
||||
if (stream.match(keywords)) return "keyword";
|
||||
|
|
72
public/vendor/codemirror/mode/yacas/yacas.js
vendored
72
public/vendor/codemirror/mode/yacas/yacas.js
vendored
|
@ -16,6 +16,19 @@
|
|||
|
||||
CodeMirror.defineMode('yacas', function(_config, _parserConfig) {
|
||||
|
||||
function words(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
var bodiedOps = words("Assert BackQuote D Defun Deriv For ForEach FromFile " +
|
||||
"FromString Function Integrate InverseTaylor Limit " +
|
||||
"LocalSymbols Macro MacroRule MacroRulePattern " +
|
||||
"NIntegrate Rule RulePattern Subst TD TExplicitSum " +
|
||||
"TSum Taylor Taylor1 Taylor2 Taylor3 ToFile " +
|
||||
"ToStdout ToString TraceRule Until While");
|
||||
|
||||
// patterns
|
||||
var pFloatForm = "(?:(?:\\.\\d+|\\d+\\.\\d*|\\d+)(?:[eE][+-]?\\d+)?)";
|
||||
var pIdentifier = "(?:[a-zA-Z\\$'][a-zA-Z0-9\\$']*)";
|
||||
|
@ -53,6 +66,33 @@ CodeMirror.defineMode('yacas', function(_config, _parserConfig) {
|
|||
// go back one character
|
||||
stream.backUp(1);
|
||||
|
||||
// update scope info
|
||||
var m = stream.match(/^(\w+)\s*\(/, false);
|
||||
if (m !== null && bodiedOps.hasOwnProperty(m[1]))
|
||||
state.scopes.push('bodied');
|
||||
|
||||
var scope = currentScope(state);
|
||||
|
||||
if (scope === 'bodied' && ch === '[')
|
||||
state.scopes.pop();
|
||||
|
||||
if (ch === '[' || ch === '{' || ch === '(')
|
||||
state.scopes.push(ch);
|
||||
|
||||
scope = currentScope(state);
|
||||
|
||||
if (scope === '[' && ch === ']' ||
|
||||
scope === '{' && ch === '}' ||
|
||||
scope === '(' && ch === ')')
|
||||
state.scopes.pop();
|
||||
|
||||
if (ch === ';') {
|
||||
while (scope === 'bodied') {
|
||||
state.scopes.pop();
|
||||
scope = currentScope(state);
|
||||
}
|
||||
}
|
||||
|
||||
// look for ordered rules
|
||||
if (stream.match(/\d+ *#/, true, false)) {
|
||||
return 'qualifier';
|
||||
|
@ -111,20 +151,46 @@ CodeMirror.defineMode('yacas', function(_config, _parserConfig) {
|
|||
function tokenComment(stream, state) {
|
||||
var prev, next;
|
||||
while((next = stream.next()) != null) {
|
||||
if (prev === '*' && next === '/')
|
||||
if (prev === '*' && next === '/') {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
prev = next;
|
||||
}
|
||||
state.tokenize = tokenBase;
|
||||
return 'comment';
|
||||
}
|
||||
|
||||
function currentScope(state) {
|
||||
var scope = null;
|
||||
if (state.scopes.length > 0)
|
||||
scope = state.scopes[state.scopes.length - 1];
|
||||
return scope;
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {return {tokenize: tokenBase, commentLevel: 0};},
|
||||
startState: function() {
|
||||
return {
|
||||
tokenize: tokenBase,
|
||||
scopes: []
|
||||
};
|
||||
},
|
||||
token: function(stream, state) {
|
||||
if (stream.eatSpace()) return null;
|
||||
return state.tokenize(stream, state);
|
||||
},
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize !== tokenBase && state.tokenize !== null)
|
||||
return CodeMirror.Pass;
|
||||
|
||||
var delta = 0;
|
||||
if (textAfter === ']' || textAfter === '];' ||
|
||||
textAfter === '}' || textAfter === '};' ||
|
||||
textAfter === ');')
|
||||
delta = -1;
|
||||
|
||||
return (state.scopes.length + delta) * _config.indentUnit;
|
||||
},
|
||||
electricChars: "{}[]();",
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/",
|
||||
lineComment: "//"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue