mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Update CodeMirror to version 5.49.0 (#8381)
* Update CodeMirror to version 5.49.0 * Update CodeMirror versions in librejs and VERSIONS
This commit is contained in:
committed by
Lauris BH
parent
6fa14ac3c8
commit
1e9b330525
@@ -12,9 +12,9 @@
|
||||
<script src="../javascript/javascript.js"></script>
|
||||
<script src="../css/css.js"></script>
|
||||
<script src="soy.js"></script>
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<style>.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>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
|
356
public/vendor/plugins/codemirror/mode/soy/soy.js
vendored
356
public/vendor/plugins/codemirror/mode/soy/soy.js
vendored
@@ -1,5 +1,5 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
@@ -11,9 +11,45 @@
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var indentingTags = ["template", "literal", "msg", "fallbackmsg", "let", "if", "elseif",
|
||||
"else", "switch", "case", "default", "foreach", "ifempty", "for",
|
||||
"call", "param", "deltemplate", "delcall", "log"];
|
||||
var paramData = { noEndTag: true, soyState: "param-def" };
|
||||
var tags = {
|
||||
"alias": { noEndTag: true },
|
||||
"delpackage": { noEndTag: true },
|
||||
"namespace": { noEndTag: true, soyState: "namespace-def" },
|
||||
"@param": paramData,
|
||||
"@param?": paramData,
|
||||
"@inject": paramData,
|
||||
"@inject?": paramData,
|
||||
"@state": paramData,
|
||||
"@state?": paramData,
|
||||
"template": { soyState: "templ-def", variableScope: true},
|
||||
"literal": { },
|
||||
"msg": {},
|
||||
"fallbackmsg": { noEndTag: true, reduceIndent: true},
|
||||
"select": {},
|
||||
"plural": {},
|
||||
"let": { soyState: "var-def" },
|
||||
"if": {},
|
||||
"elseif": { noEndTag: true, reduceIndent: true},
|
||||
"else": { noEndTag: true, reduceIndent: true},
|
||||
"switch": {},
|
||||
"case": { noEndTag: true, reduceIndent: true},
|
||||
"default": { noEndTag: true, reduceIndent: true},
|
||||
"foreach": { variableScope: true, soyState: "var-def" },
|
||||
"ifempty": { noEndTag: true, reduceIndent: true},
|
||||
"for": { variableScope: true, soyState: "var-def" },
|
||||
"call": { soyState: "templ-ref" },
|
||||
"param": { soyState: "param-ref"},
|
||||
"print": { noEndTag: true },
|
||||
"deltemplate": { soyState: "templ-def", variableScope: true},
|
||||
"delcall": { soyState: "templ-ref" },
|
||||
"log": {},
|
||||
"element": { variableScope: true },
|
||||
};
|
||||
|
||||
var indentingTags = Object.keys(tags).filter(function(tag) {
|
||||
return !tags[tag].noEndTag || tags[tag].reduceIndent;
|
||||
});
|
||||
|
||||
CodeMirror.defineMode("soy", function(config) {
|
||||
var textMode = CodeMirror.getMode(config, "text/plain");
|
||||
@@ -22,6 +58,7 @@
|
||||
attributes: textMode,
|
||||
text: textMode,
|
||||
uri: textMode,
|
||||
trusted_resource_uri: textMode,
|
||||
css: CodeMirror.getMode(config, "text/css"),
|
||||
js: CodeMirror.getMode(config, {name: "text/javascript", statementIndent: 2 * config.indentUnit})
|
||||
};
|
||||
@@ -31,6 +68,12 @@
|
||||
}
|
||||
|
||||
function tokenUntil(stream, state, untilRegExp) {
|
||||
if (stream.sol()) {
|
||||
for (var indent = 0; indent < state.indent; indent++) {
|
||||
if (!stream.eat(/\s/)) break;
|
||||
}
|
||||
if (indent) return null;
|
||||
}
|
||||
var oldString = stream.string;
|
||||
var match = untilRegExp.exec(oldString.substr(stream.pos));
|
||||
if (match) {
|
||||
@@ -39,33 +82,82 @@
|
||||
stream.string = oldString.substr(0, stream.pos + match.index);
|
||||
}
|
||||
var result = stream.hideFirstChars(state.indent, function() {
|
||||
return state.localMode.token(stream, state.localState);
|
||||
var localState = last(state.localStates);
|
||||
return localState.mode.token(stream, localState.state);
|
||||
});
|
||||
stream.string = oldString;
|
||||
return result;
|
||||
}
|
||||
|
||||
function contains(list, element) {
|
||||
while (list) {
|
||||
if (list.element === element) return true;
|
||||
list = list.next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function prepend(list, element) {
|
||||
return {
|
||||
element: element,
|
||||
next: list
|
||||
};
|
||||
}
|
||||
|
||||
function popcontext(state) {
|
||||
if (!state.context) return;
|
||||
if (state.context.scope) {
|
||||
state.variables = state.context.scope;
|
||||
}
|
||||
state.context = state.context.previousContext;
|
||||
}
|
||||
|
||||
// Reference a variable `name` in `list`.
|
||||
// Let `loose` be truthy to ignore missing identifiers.
|
||||
function ref(list, name, loose) {
|
||||
return contains(list, name) ? "variable-2" : (loose ? "variable" : "variable-2 error");
|
||||
}
|
||||
|
||||
// Data for an open soy tag.
|
||||
function Context(previousContext, tag, scope) {
|
||||
this.previousContext = previousContext;
|
||||
this.tag = tag;
|
||||
this.kind = null;
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
kind: [],
|
||||
kindTag: [],
|
||||
soyState: [],
|
||||
templates: null,
|
||||
variables: prepend(null, 'ij'),
|
||||
scopes: null,
|
||||
indent: 0,
|
||||
localMode: modes.html,
|
||||
localState: CodeMirror.startState(modes.html)
|
||||
quoteKind: null,
|
||||
context: null,
|
||||
localStates: [{
|
||||
mode: modes.html,
|
||||
state: CodeMirror.startState(modes.html)
|
||||
}]
|
||||
};
|
||||
},
|
||||
|
||||
copyState: function(state) {
|
||||
return {
|
||||
tag: state.tag, // Last seen Soy tag.
|
||||
kind: state.kind.concat([]), // Values of kind="" attributes.
|
||||
kindTag: state.kindTag.concat([]), // Opened tags with kind="" attributes.
|
||||
soyState: state.soyState.concat([]),
|
||||
templates: state.templates,
|
||||
variables: state.variables,
|
||||
context: state.context,
|
||||
indent: state.indent, // Indentation of the following line.
|
||||
localMode: state.localMode,
|
||||
localState: CodeMirror.copyState(state.localMode, state.localState)
|
||||
quoteKind: state.quoteKind,
|
||||
localStates: state.localStates.map(function(localState) {
|
||||
return {
|
||||
mode: localState.mode,
|
||||
state: CodeMirror.copyState(localState.mode, localState.state)
|
||||
};
|
||||
})
|
||||
};
|
||||
},
|
||||
|
||||
@@ -79,36 +171,159 @@
|
||||
} else {
|
||||
stream.skipToEnd();
|
||||
}
|
||||
if (!state.context || !state.context.scope) {
|
||||
var paramRe = /@param\??\s+(\S+)/g;
|
||||
var current = stream.current();
|
||||
for (var match; (match = paramRe.exec(current)); ) {
|
||||
state.variables = prepend(state.variables, match[1]);
|
||||
}
|
||||
}
|
||||
return "comment";
|
||||
|
||||
case "variable":
|
||||
if (stream.match(/^}/)) {
|
||||
state.indent -= 2 * config.indentUnit;
|
||||
case "string":
|
||||
var match = stream.match(/^.*?(["']|\\[\s\S])/);
|
||||
if (!match) {
|
||||
stream.skipToEnd();
|
||||
} else if (match[1] == state.quoteKind) {
|
||||
state.quoteKind = null;
|
||||
state.soyState.pop();
|
||||
return "variable-2";
|
||||
}
|
||||
return "string";
|
||||
}
|
||||
|
||||
if (!state.soyState.length || last(state.soyState) != "literal") {
|
||||
if (stream.match(/^\/\*/)) {
|
||||
state.soyState.push("comment");
|
||||
return "comment";
|
||||
} else if (stream.match(stream.sol() ? /^\s*\/\/.*/ : /^\s+\/\/.*/)) {
|
||||
return "comment";
|
||||
}
|
||||
}
|
||||
|
||||
switch (last(state.soyState)) {
|
||||
case "templ-def":
|
||||
if (match = stream.match(/^\.?([\w]+(?!\.[\w]+)*)/)) {
|
||||
state.templates = prepend(state.templates, match[1]);
|
||||
state.soyState.pop();
|
||||
return "def";
|
||||
}
|
||||
stream.next();
|
||||
return null;
|
||||
|
||||
case "templ-ref":
|
||||
if (match = stream.match(/(\.?[a-zA-Z_][a-zA-Z_0-9]+)+/)) {
|
||||
state.soyState.pop();
|
||||
// If the first character is '.', it can only be a local template.
|
||||
if (match[0][0] == '.') {
|
||||
return "variable-2"
|
||||
}
|
||||
// Otherwise
|
||||
return "variable";
|
||||
}
|
||||
stream.next();
|
||||
return null;
|
||||
|
||||
case "namespace-def":
|
||||
if (match = stream.match(/^\.?([\w\.]+)/)) {
|
||||
state.soyState.pop();
|
||||
return "variable";
|
||||
}
|
||||
stream.next();
|
||||
return null;
|
||||
|
||||
case "param-def":
|
||||
if (match = stream.match(/^\w+/)) {
|
||||
state.variables = prepend(state.variables, match[0]);
|
||||
state.soyState.pop();
|
||||
state.soyState.push("param-type");
|
||||
return "def";
|
||||
}
|
||||
stream.next();
|
||||
return null;
|
||||
|
||||
case "param-ref":
|
||||
if (match = stream.match(/^\w+/)) {
|
||||
state.soyState.pop();
|
||||
return "property";
|
||||
}
|
||||
stream.next();
|
||||
return null;
|
||||
|
||||
case "param-type":
|
||||
if (stream.peek() == "}") {
|
||||
state.soyState.pop();
|
||||
return null;
|
||||
}
|
||||
if (stream.eatWhile(/^([\w]+|[?])/)) {
|
||||
return "type";
|
||||
}
|
||||
stream.next();
|
||||
return null;
|
||||
|
||||
case "var-def":
|
||||
if (match = stream.match(/^\$([\w]+)/)) {
|
||||
state.variables = prepend(state.variables, match[1]);
|
||||
state.soyState.pop();
|
||||
return "def";
|
||||
}
|
||||
stream.next();
|
||||
return null;
|
||||
|
||||
case "tag":
|
||||
var endTag = state.tag[0] == "/";
|
||||
var tagName = endTag ? state.tag.substring(1) : state.tag;
|
||||
var tag = tags[tagName];
|
||||
if (stream.match(/^\/?}/)) {
|
||||
if (state.tag == "/template" || state.tag == "/deltemplate") state.indent = 0;
|
||||
else state.indent -= (stream.current() == "/}" || indentingTags.indexOf(state.tag) == -1 ? 2 : 1) * config.indentUnit;
|
||||
var selfClosed = stream.current() == "/}";
|
||||
if (selfClosed && !endTag) {
|
||||
popcontext(state);
|
||||
}
|
||||
if (state.tag == "/template" || state.tag == "/deltemplate") {
|
||||
state.variables = prepend(null, 'ij');
|
||||
state.indent = 0;
|
||||
} else {
|
||||
state.indent -= config.indentUnit *
|
||||
(selfClosed || indentingTags.indexOf(state.tag) == -1 ? 2 : 1);
|
||||
}
|
||||
state.soyState.pop();
|
||||
return "keyword";
|
||||
} else if (stream.match(/^([\w?]+)(?==)/)) {
|
||||
if (stream.current() == "kind" && (match = stream.match(/^="([^"]+)/, false))) {
|
||||
if (state.context && state.context.tag == tagName && stream.current() == "kind" && (match = stream.match(/^="([^"]+)/, false))) {
|
||||
var kind = match[1];
|
||||
state.kind.push(kind);
|
||||
state.kindTag.push(state.tag);
|
||||
state.localMode = modes[kind] || modes.html;
|
||||
state.localState = CodeMirror.startState(state.localMode);
|
||||
state.context.kind = kind;
|
||||
var mode = modes[kind] || modes.html;
|
||||
var localState = last(state.localStates);
|
||||
if (localState.mode.indent) {
|
||||
state.indent += localState.mode.indent(localState.state, "", "");
|
||||
}
|
||||
state.localStates.push({
|
||||
mode: mode,
|
||||
state: CodeMirror.startState(mode)
|
||||
});
|
||||
}
|
||||
return "attribute";
|
||||
} else if (stream.match(/^"/)) {
|
||||
} else if (match = stream.match(/([\w]+)(?=\()/)) {
|
||||
return "variable callee";
|
||||
} else if (match = stream.match(/^["']/)) {
|
||||
state.soyState.push("string");
|
||||
state.quoteKind = match;
|
||||
return "string";
|
||||
}
|
||||
if (stream.match(/(null|true|false)(?!\w)/) ||
|
||||
stream.match(/0x([0-9a-fA-F]{2,})/) ||
|
||||
stream.match(/-?([0-9]*[.])?[0-9]+(e[0-9]*)?/)) {
|
||||
return "atom";
|
||||
}
|
||||
if (stream.match(/(\||[+\-*\/%]|[=!]=|\?:|[<>]=?)/)) {
|
||||
// Tokenize filter, binary, null propagator, and equality operators.
|
||||
return "operator";
|
||||
}
|
||||
if (match = stream.match(/^\$([\w]+)/)) {
|
||||
return ref(state.variables, match[1]);
|
||||
}
|
||||
if (match = stream.match(/^\w+/)) {
|
||||
return /^(?:as|and|or|not|in)$/.test(match[0]) ? "keyword" : null;
|
||||
}
|
||||
stream.next();
|
||||
return null;
|
||||
|
||||
@@ -119,41 +334,59 @@
|
||||
return this.token(stream, state);
|
||||
}
|
||||
return tokenUntil(stream, state, /\{\/literal}/);
|
||||
|
||||
case "string":
|
||||
var match = stream.match(/^.*?("|\\[\s\S])/);
|
||||
if (!match) {
|
||||
stream.skipToEnd();
|
||||
} else if (match[1] == "\"") {
|
||||
state.soyState.pop();
|
||||
}
|
||||
return "string";
|
||||
}
|
||||
|
||||
if (stream.match(/^\/\*/)) {
|
||||
state.soyState.push("comment");
|
||||
return "comment";
|
||||
} else if (stream.match(stream.sol() ? /^\s*\/\/.*/ : /^\s+\/\/.*/)) {
|
||||
return "comment";
|
||||
} else if (stream.match(/^\{\$[\w?]*/)) {
|
||||
state.indent += 2 * config.indentUnit;
|
||||
state.soyState.push("variable");
|
||||
return "variable-2";
|
||||
} else if (stream.match(/^\{literal}/)) {
|
||||
if (stream.match(/^\{literal}/)) {
|
||||
state.indent += config.indentUnit;
|
||||
state.soyState.push("literal");
|
||||
state.context = new Context(state.context, "literal", state.variables);
|
||||
return "keyword";
|
||||
} else if (match = stream.match(/^\{([\/@\\]?[\w?]*)/)) {
|
||||
if (match[1] != "/switch")
|
||||
state.indent += (/^(\/|(else|elseif|case|default)$)/.test(match[1]) && state.tag != "switch" ? 1 : 2) * config.indentUnit;
|
||||
|
||||
// A tag-keyword must be followed by whitespace, comment or a closing tag.
|
||||
} else if (match = stream.match(/^\{([/@\\]?\w+\??)(?=$|[\s}]|\/[/*])/)) {
|
||||
var prevTag = state.tag;
|
||||
state.tag = match[1];
|
||||
if (state.tag == "/" + last(state.kindTag)) {
|
||||
// We found the tag that opened the current kind="".
|
||||
state.kind.pop();
|
||||
state.kindTag.pop();
|
||||
state.localMode = modes[last(state.kind)] || modes.html;
|
||||
state.localState = CodeMirror.startState(state.localMode);
|
||||
var endTag = state.tag[0] == "/";
|
||||
var indentingTag = !!tags[state.tag];
|
||||
var tagName = endTag ? state.tag.substring(1) : state.tag;
|
||||
var tag = tags[tagName];
|
||||
if (state.tag != "/switch")
|
||||
state.indent += ((endTag || tag && tag.reduceIndent) && prevTag != "switch" ? 1 : 2) * config.indentUnit;
|
||||
|
||||
state.soyState.push("tag");
|
||||
var tagError = false;
|
||||
if (tag) {
|
||||
if (!endTag) {
|
||||
if (tag.soyState) state.soyState.push(tag.soyState);
|
||||
}
|
||||
// If a new tag, open a new context.
|
||||
if (!tag.noEndTag && (indentingTag || !endTag)) {
|
||||
state.context = new Context(state.context, state.tag, tag.variableScope ? state.variables : null);
|
||||
// Otherwise close the current context.
|
||||
} else if (endTag) {
|
||||
if (!state.context || state.context.tag != tagName) {
|
||||
tagError = true;
|
||||
} else if (state.context) {
|
||||
if (state.context.kind) {
|
||||
state.localStates.pop();
|
||||
var localState = last(state.localStates);
|
||||
if (localState.mode.indent) {
|
||||
state.indent -= localState.mode.indent(localState.state, "", "");
|
||||
}
|
||||
}
|
||||
popcontext(state);
|
||||
}
|
||||
}
|
||||
} else if (endTag) {
|
||||
// Assume all tags with a closing tag are defined in the config.
|
||||
tagError = true;
|
||||
}
|
||||
return (tagError ? "error " : "") + "keyword";
|
||||
|
||||
// Not a tag-keyword; it's an implicit print tag.
|
||||
} else if (stream.eat('{')) {
|
||||
state.tag = "print";
|
||||
state.indent += 2 * config.indentUnit;
|
||||
state.soyState.push("tag");
|
||||
return "keyword";
|
||||
}
|
||||
@@ -161,7 +394,7 @@
|
||||
return tokenUntil(stream, state, /\{|\s+\/\/|\/\*/);
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
indent: function(state, textAfter, line) {
|
||||
var indent = state.indent, top = last(state.soyState);
|
||||
if (top == "comment") return CodeMirror.Pass;
|
||||
|
||||
@@ -173,14 +406,16 @@
|
||||
if (state.tag != "switch" && /^\{(case|default)\b/.test(textAfter)) indent -= config.indentUnit;
|
||||
if (/^\{\/switch\b/.test(textAfter)) indent -= config.indentUnit;
|
||||
}
|
||||
if (indent && state.localMode.indent)
|
||||
indent += state.localMode.indent(state.localState, textAfter);
|
||||
var localState = last(state.localStates);
|
||||
if (indent && localState.mode.indent) {
|
||||
indent += localState.mode.indent(localState.state, textAfter, line);
|
||||
}
|
||||
return indent;
|
||||
},
|
||||
|
||||
innerMode: function(state) {
|
||||
if (state.soyState.length && last(state.soyState) != "literal") return null;
|
||||
else return {state: state.localState, mode: state.localMode};
|
||||
else return last(state.localStates);
|
||||
},
|
||||
|
||||
electricInput: /^\s*\{(\/|\/template|\/deltemplate|\/switch|fallbackmsg|elseif|else|case|default|ifempty|\/literal\})$/,
|
||||
@@ -188,12 +423,15 @@
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/",
|
||||
blockCommentContinue: " * ",
|
||||
useInnerComments: false,
|
||||
fold: "indent"
|
||||
};
|
||||
}, "htmlmixed");
|
||||
|
||||
CodeMirror.registerHelper("hintWords", "soy", indentingTags.concat(
|
||||
["delpackage", "namespace", "alias", "print", "css", "debugger"]));
|
||||
CodeMirror.registerHelper("wordChars", "soy", /[\w$]/);
|
||||
|
||||
CodeMirror.registerHelper("hintWords", "soy", Object.keys(tags).concat(
|
||||
["css", "debugger"]));
|
||||
|
||||
CodeMirror.defineMIME("text/x-soy", "soy");
|
||||
});
|
||||
|
204
public/vendor/plugins/codemirror/mode/soy/test.js
vendored
Normal file
204
public/vendor/plugins/codemirror/mode/soy/test.js
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "soy");
|
||||
function MT(name) {test.mode(name, mode, Array.prototype.slice.call(arguments, 1));}
|
||||
|
||||
// Test of small keywords and words containing them.
|
||||
MT('keywords-test',
|
||||
'[keyword {] [keyword as] worrying [keyword and] notorious [keyword as]',
|
||||
' the Fandor[operator -]alias assassin, [keyword or]',
|
||||
' Corcand cannot fit [keyword in] [keyword }]');
|
||||
|
||||
MT('let-test',
|
||||
'[keyword {template] [def .name][keyword }]',
|
||||
' [keyword {let] [def $name]: [string "world"][keyword /}]',
|
||||
' [tag&bracket <][tag h1][tag&bracket >]',
|
||||
' Hello, [keyword {][variable-2 $name][keyword }]',
|
||||
' [tag&bracket </][tag h1][tag&bracket >]',
|
||||
'[keyword {/template}]',
|
||||
'');
|
||||
|
||||
MT('function-test',
|
||||
'[keyword {] [callee&variable css]([string "MyClass"])[keyword }]',
|
||||
'[tag&bracket <][tag input] [attribute value]=[string "]' +
|
||||
'[keyword {] [callee&variable index]([variable-2&error $list])[keyword }]' +
|
||||
'[string "][tag&bracket />]');
|
||||
|
||||
MT('namespace-test',
|
||||
'[keyword {namespace] [variable namespace][keyword }]')
|
||||
|
||||
MT('namespace-with-attribute-test',
|
||||
'[keyword {namespace] [variable my.namespace.templates] ' +
|
||||
'[attribute requirecss]=[string "my.namespace"][keyword }]');
|
||||
|
||||
MT('operators-test',
|
||||
'[keyword {] [atom 1] [operator ==] [atom 1] [keyword }]',
|
||||
'[keyword {] [atom 1] [operator !=] [atom 2] [keyword }]',
|
||||
'[keyword {] [atom 2] [operator +] [atom 2] [keyword }]',
|
||||
'[keyword {] [atom 2] [operator -] [atom 2] [keyword }]',
|
||||
'[keyword {] [atom 2] [operator *] [atom 2] [keyword }]',
|
||||
'[keyword {] [atom 2] [operator /] [atom 2] [keyword }]',
|
||||
'[keyword {] [atom 2] [operator %] [atom 2] [keyword }]',
|
||||
'[keyword {] [atom 2] [operator <=] [atom 2] [keyword }]',
|
||||
'[keyword {] [atom 2] [operator >=] [atom 2] [keyword }]',
|
||||
'[keyword {] [atom 3] [operator >] [atom 2] [keyword }]',
|
||||
'[keyword {] [atom 2] [operator >] [atom 3] [keyword }]',
|
||||
'[keyword {] [atom null] [operator ?:] [string ""] [keyword }]',
|
||||
'[keyword {] [variable-2&error $variable] [operator |] safeHtml [keyword }]')
|
||||
|
||||
MT('primitive-test',
|
||||
'[keyword {] [atom true] [keyword }]',
|
||||
'[keyword {] [atom false] [keyword }]',
|
||||
'[keyword {] truethy [keyword }]',
|
||||
'[keyword {] falsey [keyword }]',
|
||||
'[keyword {] [atom 42] [keyword }]',
|
||||
'[keyword {] [atom .42] [keyword }]',
|
||||
'[keyword {] [atom 0.42] [keyword }]',
|
||||
'[keyword {] [atom -0.42] [keyword }]',
|
||||
'[keyword {] [atom -.2] [keyword }]',
|
||||
'[keyword {] [atom 6.03e23] [keyword }]',
|
||||
'[keyword {] [atom -0.03e0] [keyword }]',
|
||||
'[keyword {] [atom 0x1F] [keyword }]',
|
||||
'[keyword {] [atom 0x1F00BBEA] [keyword }]');
|
||||
|
||||
MT('param-type-test',
|
||||
'[keyword {@param] [def a]: ' +
|
||||
'[type list]<[[[type a]: [type int], ' +
|
||||
'[type b]: [type map]<[type string], ' +
|
||||
'[type bool]>]]>][keyword }]',
|
||||
'[keyword {@param] [def unknown]: [type ?][keyword }]',
|
||||
'[keyword {@param] [def list]: [type list]<[type ?]>[keyword }]');
|
||||
|
||||
MT('undefined-var',
|
||||
'[keyword {][variable-2&error $var]');
|
||||
|
||||
MT('param-scope-test',
|
||||
'[keyword {template] [def .a][keyword }]',
|
||||
' [keyword {@param] [def x]: [type string][keyword }]',
|
||||
' [keyword {][variable-2 $x][keyword }]',
|
||||
'[keyword {/template}]',
|
||||
'',
|
||||
'[keyword {template] [def .b][keyword }]',
|
||||
' [keyword {][variable-2&error $x][keyword }]',
|
||||
'[keyword {/template}]',
|
||||
'');
|
||||
|
||||
MT('if-variable-test',
|
||||
'[keyword {if] [variable-2&error $showThing][keyword }]',
|
||||
' Yo!',
|
||||
'[keyword {/if}]',
|
||||
'');
|
||||
|
||||
MT('defined-if-variable-test',
|
||||
'[keyword {template] [def .foo][keyword }]',
|
||||
' [keyword {@param?] [def showThing]: [type bool][keyword }]',
|
||||
' [keyword {if] [variable-2 $showThing][keyword }]',
|
||||
' Yo!',
|
||||
' [keyword {/if}]',
|
||||
'[keyword {/template}]',
|
||||
'');
|
||||
|
||||
MT('template-calls-test',
|
||||
'[keyword {call] [variable-2 .foo][keyword /}]',
|
||||
'[keyword {call] [variable foo][keyword /}]',
|
||||
'[keyword {call] [variable foo][keyword }] [keyword {/call}]',
|
||||
'[keyword {call] [variable first1.second.third_3][keyword /}]',
|
||||
'[keyword {call] [variable first1.second.third_3] [keyword }] [keyword {/call}]',
|
||||
'');
|
||||
|
||||
MT('foreach-scope-test',
|
||||
'[keyword {@param] [def bar]: [type string][keyword }]',
|
||||
'[keyword {foreach] [def $foo] [keyword in] [variable-2&error $foos][keyword }]',
|
||||
' [keyword {][variable-2 $foo][keyword }]',
|
||||
'[keyword {/foreach}]',
|
||||
'[keyword {][variable-2&error $foo][keyword }]',
|
||||
'[keyword {][variable-2 $bar][keyword }]');
|
||||
|
||||
MT('foreach-ifempty-indent-test',
|
||||
'[keyword {foreach] [def $foo] [keyword in] [variable-2&error $foos][keyword }]',
|
||||
' something',
|
||||
'[keyword {ifempty}]',
|
||||
' nothing',
|
||||
'[keyword {/foreach}]',
|
||||
'');
|
||||
|
||||
MT('nested-kind-test',
|
||||
'[keyword {template] [def .foo] [attribute kind]=[string "html"][keyword }]',
|
||||
' [tag&bracket <][tag div][tag&bracket >]',
|
||||
' [keyword {call] [variable-2 .bar][keyword }]',
|
||||
' [keyword {param] [property propertyName] [attribute kind]=[string "js"][keyword }]',
|
||||
' [keyword var] [def bar] [operator =] [number 5];',
|
||||
' [keyword {/param}]',
|
||||
' [keyword {/call}]',
|
||||
' [tag&bracket </][tag div][tag&bracket >]',
|
||||
'[keyword {/template}]',
|
||||
'');
|
||||
|
||||
MT('tag-starting-with-function-call-is-not-a-keyword',
|
||||
'[keyword {][callee&variable index]([variable-2&error $foo])[keyword }]',
|
||||
'[keyword {css] [string "some-class"][keyword }]',
|
||||
'[keyword {][callee&variable css]([string "some-class"])[keyword }]',
|
||||
'');
|
||||
|
||||
MT('allow-missing-colon-in-@param',
|
||||
'[keyword {template] [def .foo][keyword }]',
|
||||
' [keyword {@param] [def showThing] [type bool][keyword }]',
|
||||
' [keyword {if] [variable-2 $showThing][keyword }]',
|
||||
' Yo!',
|
||||
' [keyword {/if}]',
|
||||
'[keyword {/template}]',
|
||||
'');
|
||||
|
||||
MT('single-quote-strings',
|
||||
'[keyword {][string "foo"] [string \'bar\'][keyword }]',
|
||||
'');
|
||||
|
||||
MT('literal-comments',
|
||||
'[keyword {literal}]/* comment */ // comment[keyword {/literal}]');
|
||||
|
||||
MT('highlight-command-at-eol',
|
||||
'[keyword {msg]',
|
||||
' [keyword }]');
|
||||
|
||||
MT('switch-indent-test',
|
||||
'[keyword {let] [def $marbles]: [atom 5] [keyword /}]',
|
||||
'[keyword {switch] [variable-2 $marbles][keyword }]',
|
||||
' [keyword {case] [atom 0][keyword }]',
|
||||
' No marbles',
|
||||
' [keyword {default}]',
|
||||
' At least 1 marble',
|
||||
'[keyword {/switch}]',
|
||||
'');
|
||||
|
||||
MT('if-elseif-else-indent',
|
||||
'[keyword {if] [atom true][keyword }]',
|
||||
' [keyword {let] [def $a]: [atom 5] [keyword /}]',
|
||||
'[keyword {elseif] [atom false][keyword }]',
|
||||
' [keyword {let] [def $bar]: [atom 5] [keyword /}]',
|
||||
'[keyword {else}]',
|
||||
' [keyword {let] [def $bar]: [atom 5] [keyword /}]',
|
||||
'[keyword {/if}]');
|
||||
|
||||
MT('msg-fallbackmsg-indent',
|
||||
'[keyword {msg] [attribute desc]=[string "A message"][keyword }]',
|
||||
' A message',
|
||||
'[keyword {fallbackmsg] [attribute desc]=[string "A message"][keyword }]',
|
||||
' Old message',
|
||||
'[keyword {/msg}]');
|
||||
|
||||
MT('special-chars',
|
||||
'[keyword {sp}]',
|
||||
'[keyword {nil}]',
|
||||
'[keyword {\\r}]',
|
||||
'[keyword {\\n}]',
|
||||
'[keyword {\\t}]',
|
||||
'[keyword {lb}]',
|
||||
'[keyword {rb}]');
|
||||
|
||||
MT('wrong-closing-tag',
|
||||
'[keyword {if] [atom true][keyword }]',
|
||||
' Optional',
|
||||
'[keyword&error {/badend][keyword }]');
|
||||
})();
|
Reference in New Issue
Block a user