mirror of
https://github.com/zadam/trilium.git
synced 2025-06-05 17:38:47 +02:00
Merge branch 'next'
# Conflicts: # package.json
This commit is contained in:
commit
6ef8a4c018
@ -1,4 +1,4 @@
|
||||
FROM node:10.15.3-alpine
|
||||
FROM node:12.3.0-alpine
|
||||
|
||||
# Create app directory
|
||||
WORKDIR /usr/src/app
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
PKG_DIR=dist/trilium-linux-x64-server
|
||||
NODE_VERSION=10.15.3
|
||||
NODE_VERSION=12.3.1
|
||||
|
||||
rm -r $PKG_DIR
|
||||
mkdir $PKG_DIR
|
||||
|
Binary file not shown.
BIN
bin/deps/linux-x64/sqlite/electron-v6.0-linux-x64/node_sqlite3.node
Executable file
BIN
bin/deps/linux-x64/sqlite/electron-v6.0-linux-x64/node_sqlite3.node
Executable file
Binary file not shown.
Binary file not shown.
BIN
bin/deps/linux-x64/sqlite/node-v72-linux-x64/node_sqlite3.node
Executable file
BIN
bin/deps/linux-x64/sqlite/node-v72-linux-x64/node_sqlite3.node
Executable file
Binary file not shown.
Binary file not shown.
BIN
bin/deps/mac-x64/sqlite/electron-v6.0-darwin-x64/node_sqlite3.node
Executable file
BIN
bin/deps/mac-x64/sqlite/electron-v6.0-darwin-x64/node_sqlite3.node
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -50,6 +50,9 @@ async function createMainWindow() {
|
||||
width: mainWindowState.width,
|
||||
height: mainWindowState.height,
|
||||
title: 'Trilium Notes',
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
},
|
||||
icon: path.join(__dirname, 'images/app-icons/png/256x256.png')
|
||||
});
|
||||
|
||||
|
15
libraries/codemirror/addon/edit/matchbrackets.js
vendored
15
libraries/codemirror/addon/edit/matchbrackets.js
vendored
@ -14,20 +14,25 @@
|
||||
|
||||
var Pos = CodeMirror.Pos;
|
||||
|
||||
var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"};
|
||||
var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<", "<": ">>", ">": "<<"};
|
||||
|
||||
function bracketRegex(config) {
|
||||
return config && config.bracketRegex || /[(){}[\]]/
|
||||
}
|
||||
|
||||
function findMatchingBracket(cm, where, config) {
|
||||
var line = cm.getLineHandle(where.line), pos = where.ch - 1;
|
||||
var afterCursor = config && config.afterCursor
|
||||
if (afterCursor == null)
|
||||
afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className)
|
||||
var re = bracketRegex(config)
|
||||
|
||||
// A cursor is defined as between two characters, but in in vim command mode
|
||||
// (i.e. not insert mode), the cursor is visually represented as a
|
||||
// highlighted box on top of the 2nd character. Otherwise, we allow matches
|
||||
// from before or after the cursor.
|
||||
var match = (!afterCursor && pos >= 0 && matching[line.text.charAt(pos)]) ||
|
||||
matching[line.text.charAt(++pos)];
|
||||
var match = (!afterCursor && pos >= 0 && re.test(line.text.charAt(pos)) && matching[line.text.charAt(pos)]) ||
|
||||
re.test(line.text.charAt(pos + 1)) && matching[line.text.charAt(++pos)];
|
||||
if (!match) return null;
|
||||
var dir = match.charAt(1) == ">" ? 1 : -1;
|
||||
if (config && config.strict && (dir > 0) != (pos == where.ch)) return null;
|
||||
@ -51,7 +56,7 @@
|
||||
var maxScanLines = (config && config.maxScanLines) || 1000;
|
||||
|
||||
var stack = [];
|
||||
var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/;
|
||||
var re = bracketRegex(config)
|
||||
var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
|
||||
: Math.max(cm.firstLine() - 1, where.line - maxScanLines);
|
||||
for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {
|
||||
@ -64,7 +69,7 @@
|
||||
var ch = line.charAt(pos);
|
||||
if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
|
||||
var match = matching[ch];
|
||||
if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
|
||||
if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
|
||||
else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
|
||||
else stack.pop();
|
||||
}
|
||||
|
2
libraries/codemirror/addon/lint/lint.js
vendored
2
libraries/codemirror/addon/lint/lint.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
|
||||
|
File diff suppressed because it is too large
Load Diff
2
libraries/codemirror/mode/asn.1/index.html
vendored
2
libraries/codemirror/mode/asn.1/index.html
vendored
@ -8,7 +8,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="asn.1.js"></script>
|
||||
<style type="text/css">
|
||||
<style>
|
||||
.CodeMirror {
|
||||
border-top: 1px solid black;
|
||||
border-bottom: 1px solid black;
|
||||
|
@ -146,7 +146,7 @@ exten => 8500,n,Goto(s,6)
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: "text/x-asterisk",
|
||||
matchBrackets: true,
|
||||
lineNumber: true
|
||||
lineNumbers: true
|
||||
});
|
||||
</script>
|
||||
|
||||
|
122
libraries/codemirror/mode/clike/clike.js
vendored
122
libraries/codemirror/mode/clike/clike.js
vendored
@ -65,7 +65,10 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
numberStart = parserConfig.numberStart || /[\d\.]/,
|
||||
number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)(u|ll?|l|f)?/i,
|
||||
isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/,
|
||||
isIdentifierChar = parserConfig.isIdentifierChar || /[\w\$_\xa1-\uffff]/;
|
||||
isIdentifierChar = parserConfig.isIdentifierChar || /[\w\$_\xa1-\uffff]/,
|
||||
// An optional function that takes a {string} token and returns true if it
|
||||
// should be treated as a builtin.
|
||||
isReservedIdentifier = parserConfig.isReservedIdentifier || false;
|
||||
|
||||
var curPunc, isDefKeyword;
|
||||
|
||||
@ -113,7 +116,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
return "keyword";
|
||||
}
|
||||
if (contains(types, cur)) return "type";
|
||||
if (contains(builtin, cur)) {
|
||||
if (contains(builtin, cur)
|
||||
|| (isReservedIdentifier && isReservedIdentifier(cur))) {
|
||||
if (contains(blockKeywords, cur)) curPunc = "newstatement";
|
||||
return "builtin";
|
||||
}
|
||||
@ -263,8 +267,33 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
}
|
||||
}
|
||||
var cKeywords = "auto if break case register continue return default do sizeof " +
|
||||
"static else struct switch extern typedef union for goto while enum const volatile";
|
||||
var cTypes = "int long char short double float unsigned signed void size_t ptrdiff_t";
|
||||
"static else struct switch extern typedef union for goto while enum const " +
|
||||
"volatile inline restrict asm fortran";
|
||||
|
||||
// Do not use this. Use the cTypes function below. This is global just to avoid
|
||||
// excessive calls when cTypes is being called multiple times during a parse.
|
||||
var basicCTypes = words("int long char short double float unsigned signed " +
|
||||
"void bool");
|
||||
|
||||
// Do not use this. Use the objCTypes function below. This is global just to avoid
|
||||
// excessive calls when objCTypes is being called multiple times during a parse.
|
||||
var basicObjCTypes = words("SEL instancetype id Class Protocol BOOL");
|
||||
|
||||
// Returns true if identifier is a "C" type.
|
||||
// C type is defined as those that are reserved by the compiler (basicTypes),
|
||||
// and those that end in _t (Reserved by POSIX for types)
|
||||
// http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html
|
||||
function cTypes(identifier) {
|
||||
return contains(basicCTypes, identifier) || /.+_t$/.test(identifier);
|
||||
}
|
||||
|
||||
// Returns true if identifier is a "Objective C" type.
|
||||
function objCTypes(identifier) {
|
||||
return cTypes(identifier) || contains(basicObjCTypes, identifier);
|
||||
}
|
||||
|
||||
var cBlockKeywords = "case do else for if switch while struct enum union";
|
||||
var cDefKeywords = "struct enum union";
|
||||
|
||||
function cppHook(stream, state) {
|
||||
if (!state.startOfLine) return false
|
||||
@ -286,6 +315,14 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// For C and C++ (and ObjC): identifiers starting with __
|
||||
// or _ followed by a capital letter are reserved for the compiler.
|
||||
function cIsReservedIdentifier(token) {
|
||||
if (!token || token.length < 2) return false;
|
||||
if (token[0] != '_') return false;
|
||||
return (token[1] == '_') || (token[1] !== token[1].toLowerCase());
|
||||
}
|
||||
|
||||
function cpp14Literal(stream) {
|
||||
stream.eatWhile(/[\w\.']/);
|
||||
return "number";
|
||||
@ -368,31 +405,36 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
def(["text/x-csrc", "text/x-c", "text/x-chdr"], {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords),
|
||||
types: words(cTypes + " bool _Complex _Bool float_t double_t intptr_t intmax_t " +
|
||||
"int8_t int16_t int32_t int64_t uintptr_t uintmax_t uint8_t uint16_t " +
|
||||
"uint32_t uint64_t"),
|
||||
blockKeywords: words("case do else for if switch while struct"),
|
||||
defKeywords: words("struct"),
|
||||
types: cTypes,
|
||||
blockKeywords: words(cBlockKeywords),
|
||||
defKeywords: words(cDefKeywords),
|
||||
typeFirstDefinitions: true,
|
||||
atoms: words("NULL true false"),
|
||||
hooks: {"#": cppHook, "*": pointerHook},
|
||||
isReservedIdentifier: cIsReservedIdentifier,
|
||||
hooks: {
|
||||
"#": cppHook,
|
||||
"*": pointerHook,
|
||||
},
|
||||
modeProps: {fold: ["brace", "include"]}
|
||||
});
|
||||
|
||||
def(["text/x-c++src", "text/x-c++hdr"], {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try explicit new " +
|
||||
"static_cast typeid catch operator template typename class friend private " +
|
||||
"this using const_cast inline public throw virtual delete mutable protected " +
|
||||
"alignas alignof constexpr decltype nullptr noexcept thread_local final " +
|
||||
"static_assert override"),
|
||||
types: words(cTypes + " bool wchar_t"),
|
||||
blockKeywords: words("catch class do else finally for if struct switch try while"),
|
||||
defKeywords: words("class namespace struct enum union"),
|
||||
// Keywords from https://en.cppreference.com/w/cpp/keyword includes C++20.
|
||||
keywords: words(cKeywords + "alignas alignof and and_eq audit axiom bitand bitor catch " +
|
||||
"class compl concept constexpr const_cast decltype delete dynamic_cast " +
|
||||
"explicit export final friend import module mutable namespace new noexcept " +
|
||||
"not not_eq operator or or_eq override private protected public " +
|
||||
"reinterpret_cast requires static_assert static_cast template this " +
|
||||
"thread_local throw try typeid typename using virtual xor xor_eq"),
|
||||
types: cTypes,
|
||||
blockKeywords: words(cBlockKeywords + " class try catch"),
|
||||
defKeywords: words(cDefKeywords + " class namespace"),
|
||||
typeFirstDefinitions: true,
|
||||
atoms: words("true false NULL"),
|
||||
atoms: words("true false NULL nullptr"),
|
||||
dontIndentStatements: /^template$/,
|
||||
isIdentifierChar: /[\w\$_~\xa1-\uffff]/,
|
||||
isReservedIdentifier: cIsReservedIdentifier,
|
||||
hooks: {
|
||||
"#": cppHook,
|
||||
"*": pointerHook,
|
||||
@ -513,7 +555,6 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
def("text/x-scala", {
|
||||
name: "clike",
|
||||
keywords: words(
|
||||
|
||||
/* scala */
|
||||
"abstract case catch class def do else extends final finally for forSome if " +
|
||||
"implicit import lazy match new null object override package private protected return " +
|
||||
@ -628,6 +669,9 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
},
|
||||
'*': function(_stream, state) {
|
||||
return state.prevToken == '.' ? 'variable' : 'operator';
|
||||
},
|
||||
'"': function(stream, state) {
|
||||
state.tokenize = tokenKotlinString(stream.match('""'));
|
||||
return state.tokenize(stream, state);
|
||||
@ -708,11 +752,11 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
|
||||
def("text/x-nesc", {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords + "as atomic async call command component components configuration event generic " +
|
||||
keywords: words(cKeywords + " as atomic async call command component components configuration event generic " +
|
||||
"implementation includes interface module new norace nx_struct nx_union post provides " +
|
||||
"signal task uses abstract extends"),
|
||||
types: words(cTypes),
|
||||
blockKeywords: words("case do else for if switch while struct"),
|
||||
types: cTypes,
|
||||
blockKeywords: words(cBlockKeywords),
|
||||
atoms: words("null true false"),
|
||||
hooks: {"#": cppHook},
|
||||
modeProps: {fold: ["brace", "include"]}
|
||||
@ -720,28 +764,34 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
|
||||
def("text/x-objectivec", {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginary BOOL Class bycopy byref id IMP in " +
|
||||
"inout nil oneway out Protocol SEL self super atomic nonatomic retain copy readwrite readonly"),
|
||||
types: words(cTypes),
|
||||
atoms: words("YES NO NULL NILL ON OFF true false"),
|
||||
keywords: words(cKeywords + " bycopy byref in inout oneway out self super atomic nonatomic retain copy " +
|
||||
"readwrite readonly strong weak assign typeof nullable nonnull null_resettable _cmd " +
|
||||
"@interface @implementation @end @protocol @encode @property @synthesize @dynamic @class " +
|
||||
"@public @package @private @protected @required @optional @try @catch @finally @import " +
|
||||
"@selector @encode @defs @synchronized @autoreleasepool @compatibility_alias @available"),
|
||||
types: objCTypes,
|
||||
builtin: words("FOUNDATION_EXPORT FOUNDATION_EXTERN NS_INLINE NS_FORMAT_FUNCTION NS_RETURNS_RETAINED " +
|
||||
"NS_ERROR_ENUM NS_RETURNS_NOT_RETAINED NS_RETURNS_INNER_POINTER NS_DESIGNATED_INITIALIZER " +
|
||||
"NS_ENUM NS_OPTIONS NS_REQUIRES_NIL_TERMINATION NS_ASSUME_NONNULL_BEGIN " +
|
||||
"NS_ASSUME_NONNULL_END NS_SWIFT_NAME NS_REFINED_FOR_SWIFT"),
|
||||
blockKeywords: words(cBlockKeywords + " @synthesize @try @catch @finally @autoreleasepool @synchronized"),
|
||||
defKeywords: words(cDefKeywords + " @interface @implementation @protocol @class"),
|
||||
dontIndentStatements: /^@.*$/,
|
||||
typeFirstDefinitions: true,
|
||||
atoms: words("YES NO NULL Nil nil true false nullptr"),
|
||||
isReservedIdentifier: cIsReservedIdentifier,
|
||||
hooks: {
|
||||
"@": function(stream) {
|
||||
stream.eatWhile(/[\w\$]/);
|
||||
return "keyword";
|
||||
},
|
||||
"#": cppHook,
|
||||
indent: function(_state, ctx, textAfter) {
|
||||
if (ctx.type == "statement" && /^@\w/.test(textAfter)) return ctx.indented
|
||||
}
|
||||
"*": pointerHook,
|
||||
},
|
||||
modeProps: {fold: "brace"}
|
||||
modeProps: {fold: ["brace", "include"]}
|
||||
});
|
||||
|
||||
def("text/x-squirrel", {
|
||||
name: "clike",
|
||||
keywords: words("base break clone continue const default delete enum extends function in class" +
|
||||
" foreach local resume return this throw typeof yield constructor instanceof static"),
|
||||
types: words(cTypes),
|
||||
types: cTypes,
|
||||
blockKeywords: words("case catch class else for foreach if switch try while"),
|
||||
defKeywords: words("function local class"),
|
||||
typeFirstDefinitions: true,
|
||||
|
34
libraries/codemirror/mode/clike/index.html
vendored
34
libraries/codemirror/mode/clike/index.html
vendored
@ -147,16 +147,36 @@ This is a longer comment
|
||||
That spans two lines
|
||||
*/
|
||||
|
||||
#import <Test/Test.h>
|
||||
#import "MyClass.h"
|
||||
#import <AFramework/AFrameork.h>
|
||||
@import BFrameworkModule;
|
||||
|
||||
NS_ENUM(SomeValues) {
|
||||
aValue = 1;
|
||||
};
|
||||
|
||||
// A Class Extension with some properties
|
||||
@interface MyClass ()<AProtocol>
|
||||
@property(atomic, readwrite, assign) NSInteger anInt;
|
||||
@property(nonatomic, strong, nullable) NSString *aString;
|
||||
@end
|
||||
|
||||
@implementation YourAppDelegate
|
||||
|
||||
// This is a one-line comment
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
|
||||
char myString[] = "This is a C character array";
|
||||
int test = 5;
|
||||
return YES;
|
||||
- (instancetype)initWithString:(NSString *)aStringVar {
|
||||
if ((self = [super init])) {
|
||||
aString = aStringVar;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)doSomething:(float)progress {
|
||||
NSString *myString = @"This is a ObjC string %f ";
|
||||
myString = [[NSString stringWithFormat:myString, progress] stringByAppendingString:self.aString];
|
||||
return myString.length > 100 ? NO : YES;
|
||||
}
|
||||
|
||||
@end
|
||||
</textarea></div>
|
||||
|
||||
<h2>Java example</h2>
|
||||
|
70
libraries/codemirror/mode/clike/test.js
vendored
70
libraries/codemirror/mode/clike/test.js
vendored
@ -23,6 +23,8 @@
|
||||
MT("def",
|
||||
"[type void] [def foo]() {}",
|
||||
"[keyword struct] [def bar]{}",
|
||||
"[keyword enum] [def zot]{}",
|
||||
"[keyword union] [def ugh]{}",
|
||||
"[type int] [type *][def baz]() {}");
|
||||
|
||||
MT("def_new_line",
|
||||
@ -43,6 +45,26 @@
|
||||
"[type unsigned] [type int] [variable bar] [operator =] [number 8];",
|
||||
"[meta #include <baz> ][comment // comment]")
|
||||
|
||||
MT("c_underscores",
|
||||
"[builtin __FOO];",
|
||||
"[builtin _Complex];",
|
||||
"[builtin __aName];",
|
||||
"[variable _aName];");
|
||||
|
||||
MT("c_types",
|
||||
"[type int];",
|
||||
"[type long];",
|
||||
"[type char];",
|
||||
"[type short];",
|
||||
"[type double];",
|
||||
"[type float];",
|
||||
"[type unsigned];",
|
||||
"[type signed];",
|
||||
"[type void];",
|
||||
"[type bool];",
|
||||
"[type foo_t];",
|
||||
"[variable foo_T];",
|
||||
"[variable _t];");
|
||||
|
||||
var mode_cpp = CodeMirror.getMode({indentUnit: 2}, "text/x-c++src");
|
||||
function MTCPP(name) { test.mode(name, mode_cpp, Array.prototype.slice.call(arguments, 1)); }
|
||||
@ -57,6 +79,54 @@
|
||||
"[def Foo::Foo]() {}",
|
||||
"[def Foo::~Foo]() {}");
|
||||
|
||||
MTCPP("cpp_underscores",
|
||||
"[builtin __FOO];",
|
||||
"[builtin _Complex];",
|
||||
"[builtin __aName];",
|
||||
"[variable _aName];");
|
||||
|
||||
var mode_objc = CodeMirror.getMode({indentUnit: 2}, "text/x-objectivec");
|
||||
function MTOBJC(name) { test.mode(name, mode_objc, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MTOBJC("objc_underscores",
|
||||
"[builtin __FOO];",
|
||||
"[builtin _Complex];",
|
||||
"[builtin __aName];",
|
||||
"[variable _aName];");
|
||||
|
||||
MTOBJC("objc_interface",
|
||||
"[keyword @interface] [def foo] {",
|
||||
" [type int] [variable bar];",
|
||||
"}",
|
||||
"[keyword @property] ([keyword atomic], [keyword nullable]) [variable NSString][operator *] [variable a];",
|
||||
"[keyword @property] ([keyword nonatomic], [keyword assign]) [type int] [variable b];",
|
||||
"[operator -]([type instancetype])[variable initWithFoo]:([type int])[variable a] " +
|
||||
"[builtin NS_DESIGNATED_INITIALIZER];",
|
||||
"[keyword @end]");
|
||||
|
||||
MTOBJC("objc_implementation",
|
||||
"[keyword @implementation] [def foo] {",
|
||||
" [type int] [variable bar];",
|
||||
"}",
|
||||
"[keyword @property] ([keyword readwrite]) [type SEL] [variable a];",
|
||||
"[operator -]([type instancetype])[variable initWithFoo]:([type int])[variable a] {",
|
||||
" [keyword if](([keyword self] [operator =] [[[keyword super] [variable init] ]])) {}",
|
||||
" [keyword return] [keyword self];",
|
||||
"}",
|
||||
"[keyword @end]");
|
||||
|
||||
MTOBJC("objc_types",
|
||||
"[type int];",
|
||||
"[type foo_t];",
|
||||
"[variable foo_T];",
|
||||
"[type id];",
|
||||
"[type SEL];",
|
||||
"[type instancetype];",
|
||||
"[type Class];",
|
||||
"[type Protocol];",
|
||||
"[type BOOL];"
|
||||
);
|
||||
|
||||
var mode_scala = CodeMirror.getMode({indentUnit: 2}, "text/x-scala");
|
||||
function MTSCALA(name) { test.mode("scala_" + name, mode_scala, Array.prototype.slice.call(arguments, 1)); }
|
||||
MTSCALA("nested_comments",
|
||||
|
2
libraries/codemirror/mode/clojure/clojure.js
vendored
2
libraries/codemirror/mode/clojure/clojure.js
vendored
@ -166,7 +166,7 @@ CodeMirror.defineMode("clojure", function (options) {
|
||||
var qualifiedSymbol = /^(?:(?:[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*(?:\.[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*\/)?(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*(?=[\\\[\]\s"(),;@^`{}~]|$))/;
|
||||
|
||||
function base(stream, state) {
|
||||
if (stream.eatSpace()) return ["space", null];
|
||||
if (stream.eatSpace() || stream.eat(",")) return ["space", null];
|
||||
if (stream.match(numberLiteral)) return [null, "number"];
|
||||
if (stream.match(characterLiteral)) return [null, "string-2"];
|
||||
if (stream.eat(/^"/)) return (state.tokenize = inString)(stream, state);
|
||||
|
15
libraries/codemirror/mode/css/css.js
vendored
15
libraries/codemirror/mode/css/css.js
vendored
@ -63,7 +63,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
||||
if (/[\d.]/.test(stream.peek())) {
|
||||
stream.eatWhile(/[\w.%]/);
|
||||
return ret("number", "unit");
|
||||
} else if (stream.match(/^-[\w\\\-]+/)) {
|
||||
} else if (stream.match(/^-[\w\\\-]*/)) {
|
||||
stream.eatWhile(/[\w\\\-]/);
|
||||
if (stream.match(/^\s*:/, false))
|
||||
return ret("variable-2", "variable-definition");
|
||||
@ -77,12 +77,11 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
||||
return ret("qualifier", "qualifier");
|
||||
} else if (/[:;{}\[\]\(\)]/.test(ch)) {
|
||||
return ret(null, ch);
|
||||
} else if (((ch == "u" || ch == "U") && stream.match(/rl(-prefix)?\(/i)) ||
|
||||
((ch == "d" || ch == "D") && stream.match("omain(", true, true)) ||
|
||||
((ch == "r" || ch == "R") && stream.match("egexp(", true, true))) {
|
||||
stream.backUp(1);
|
||||
state.tokenize = tokenParenthesized;
|
||||
return ret("property", "word");
|
||||
} else if (stream.match(/[\w-.]+(?=\()/)) {
|
||||
if (/^(url(-prefix)?|domain|regexp)$/.test(stream.current().toLowerCase())) {
|
||||
state.tokenize = tokenParenthesized;
|
||||
}
|
||||
return ret("variable callee", "variable");
|
||||
} else if (/[\w\\\-]/.test(ch)) {
|
||||
stream.eatWhile(/[\w\\\-]/);
|
||||
return ret("property", "word");
|
||||
@ -501,7 +500,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
||||
"margin-bottom", "margin-left", "margin-right", "margin-top",
|
||||
"marks", "marquee-direction", "marquee-loop",
|
||||
"marquee-play-count", "marquee-speed", "marquee-style", "max-height",
|
||||
"max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
|
||||
"max-width", "min-height", "min-width", "mix-blend-mode", "move-to", "nav-down", "nav-index",
|
||||
"nav-left", "nav-right", "nav-up", "object-fit", "object-position",
|
||||
"opacity", "order", "orphans", "outline",
|
||||
"outline-color", "outline-offset", "outline-style", "outline-width",
|
||||
|
8
libraries/codemirror/mode/css/less_test.js
vendored
8
libraries/codemirror/mode/css/less_test.js
vendored
@ -10,8 +10,8 @@
|
||||
MT("variable",
|
||||
"[variable-2 @base]: [atom #f04615];",
|
||||
"[qualifier .class] {",
|
||||
" [property width]: [variable percentage]([number 0.5]); [comment // returns `50%`]",
|
||||
" [property color]: [variable saturate]([variable-2 @base], [number 5%]);",
|
||||
" [property width]: [variable&callee percentage]([number 0.5]); [comment // returns `50%`]",
|
||||
" [property color]: [variable&callee saturate]([variable-2 @base], [number 5%]);",
|
||||
"}");
|
||||
|
||||
MT("amp",
|
||||
@ -26,10 +26,10 @@
|
||||
|
||||
MT("mixin",
|
||||
"[qualifier .mixin] ([variable dark]; [variable-2 @color]) {",
|
||||
" [property color]: [atom darken]([variable-2 @color], [number 10%]);",
|
||||
" [property color]: [variable&callee darken]([variable-2 @color], [number 10%]);",
|
||||
"}",
|
||||
"[qualifier .mixin] ([variable light]; [variable-2 @color]) {",
|
||||
" [property color]: [atom lighten]([variable-2 @color], [number 10%]);",
|
||||
" [property color]: [variable&callee lighten]([variable-2 @color], [number 10%]);",
|
||||
"}",
|
||||
"[qualifier .mixin] ([variable-2 @_]; [variable-2 @color]) {",
|
||||
" [property display]: [atom block];",
|
||||
|
10
libraries/codemirror/mode/css/scss_test.js
vendored
10
libraries/codemirror/mode/css/scss_test.js
vendored
@ -6,19 +6,19 @@
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "scss"); }
|
||||
|
||||
MT('url_with_quotation',
|
||||
"[tag foo] { [property background]:[atom url]([string test.jpg]) }");
|
||||
"[tag foo] { [property background]:[variable&callee url]([string test.jpg]) }");
|
||||
|
||||
MT('url_with_double_quotes',
|
||||
"[tag foo] { [property background]:[atom url]([string \"test.jpg\"]) }");
|
||||
"[tag foo] { [property background]:[variable&callee url]([string \"test.jpg\"]) }");
|
||||
|
||||
MT('url_with_single_quotes',
|
||||
"[tag foo] { [property background]:[atom url]([string \'test.jpg\']) }");
|
||||
"[tag foo] { [property background]:[variable&callee url]([string \'test.jpg\']) }");
|
||||
|
||||
MT('string',
|
||||
"[def @import] [string \"compass/css3\"]");
|
||||
|
||||
MT('important_keyword',
|
||||
"[tag foo] { [property background]:[atom url]([string \'test.jpg\']) [keyword !important] }");
|
||||
"[tag foo] { [property background]:[variable&callee url]([string \'test.jpg\']) [keyword !important] }");
|
||||
|
||||
MT('variable',
|
||||
"[variable-2 $blue]:[atom #333]");
|
||||
@ -95,7 +95,7 @@
|
||||
|
||||
MT('indent_parentheses',
|
||||
"[tag foo] {",
|
||||
" [property color]: [atom darken]([variable-2 $blue],",
|
||||
" [property color]: [variable&callee darken]([variable-2 $blue],",
|
||||
" [number 9%]);",
|
||||
"}");
|
||||
|
||||
|
50
libraries/codemirror/mode/css/test.js
vendored
50
libraries/codemirror/mode/css/test.js
vendored
@ -89,11 +89,11 @@
|
||||
"[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }");
|
||||
|
||||
MT("tagTwoPropertiesURL",
|
||||
"[tag foo] { [property background]: [atom url]([string //example.com/foo.png]); [property padding]: [number 0]; }");
|
||||
"[tag foo] { [property background]: [variable&callee url]([string //example.com/foo.png]); [property padding]: [number 0]; }");
|
||||
|
||||
MT("indent_tagSelector",
|
||||
"[tag strong], [tag em] {",
|
||||
" [property background]: [atom rgba](",
|
||||
" [property background]: [variable&callee rgba](",
|
||||
" [number 255], [number 255], [number 0], [number .2]",
|
||||
" );",
|
||||
"}");
|
||||
@ -114,7 +114,7 @@
|
||||
|
||||
MT("indent_parentheses",
|
||||
"[tag foo]:[variable-3 before] {",
|
||||
" [property background]: [atom url](",
|
||||
" [property background]: [variable&callee url](",
|
||||
"[string blahblah]",
|
||||
"[string etc]",
|
||||
"[string ]) [keyword !important];",
|
||||
@ -124,20 +124,20 @@
|
||||
"[def @font-face] {",
|
||||
" [property font-family]: [string 'myfont'];",
|
||||
" [error nonsense]: [string 'abc'];",
|
||||
" [property src]: [atom url]([string http://blah]),",
|
||||
" [atom url]([string http://foo]);",
|
||||
" [property src]: [variable&callee url]([string http://blah]),",
|
||||
" [variable&callee url]([string http://foo]);",
|
||||
"}");
|
||||
|
||||
MT("empty_url",
|
||||
"[def @import] [atom url]() [attribute screen];");
|
||||
"[def @import] [variable&callee url]() [attribute screen];");
|
||||
|
||||
MT("parens",
|
||||
"[qualifier .foo] {",
|
||||
" [property background-image]: [variable fade]([atom #000], [number 20%]);",
|
||||
" [property border-image]: [atom linear-gradient](",
|
||||
" [property background-image]: [variable&callee fade]([atom #000], [number 20%]);",
|
||||
" [property border-image]: [variable&callee linear-gradient](",
|
||||
" [atom to] [atom bottom],",
|
||||
" [variable fade]([atom #000], [number 20%]) [number 0%],",
|
||||
" [variable fade]([atom #000], [number 20%]) [number 100%]",
|
||||
" [variable&callee fade]([atom #000], [number 20%]) [number 0%],",
|
||||
" [variable&callee fade]([atom #000], [number 20%]) [number 100%]",
|
||||
" );",
|
||||
"}");
|
||||
|
||||
@ -146,7 +146,15 @@
|
||||
" [variable-2 --main-color]: [atom #06c];",
|
||||
"}",
|
||||
"[tag h1][builtin #foo] {",
|
||||
" [property color]: [atom var]([variable-2 --main-color]);",
|
||||
" [property color]: [variable&callee var]([variable-2 --main-color]);",
|
||||
"}");
|
||||
|
||||
MT("blank_css_variable",
|
||||
":[variable-3 root] {",
|
||||
" [variable-2 --]: [atom #06c];",
|
||||
"}",
|
||||
"[tag h1][builtin #foo] {",
|
||||
" [property color]: [variable&callee var]([variable-2 --]);",
|
||||
"}");
|
||||
|
||||
MT("supports",
|
||||
@ -155,10 +163,10 @@
|
||||
"}");
|
||||
|
||||
MT("document",
|
||||
"[def @document] [tag url]([string http://blah]),",
|
||||
" [tag url-prefix]([string https://]),",
|
||||
" [tag domain]([string blah.com]),",
|
||||
" [tag regexp]([string \".*blah.+\"]) {",
|
||||
"[def @document] [variable&callee url]([string http://blah]),",
|
||||
" [variable&callee url-prefix]([string https://]),",
|
||||
" [variable&callee domain]([string blah.com]),",
|
||||
" [variable&callee regexp]([string \".*blah.+\"]) {",
|
||||
" [builtin #id] {",
|
||||
" [property background-color]: [keyword white];",
|
||||
" }",
|
||||
@ -168,16 +176,16 @@
|
||||
"}");
|
||||
|
||||
MT("document_url",
|
||||
"[def @document] [tag url]([string http://blah]) { [qualifier .class] { } }");
|
||||
"[def @document] [variable&callee url]([string http://blah]) { [qualifier .class] { } }");
|
||||
|
||||
MT("document_urlPrefix",
|
||||
"[def @document] [tag url-prefix]([string https://]) { [builtin #id] { } }");
|
||||
"[def @document] [variable&callee url-prefix]([string https://]) { [builtin #id] { } }");
|
||||
|
||||
MT("document_domain",
|
||||
"[def @document] [tag domain]([string blah.com]) { [tag foo] { } }");
|
||||
"[def @document] [variable&callee domain]([string blah.com]) { [tag foo] { } }");
|
||||
|
||||
MT("document_regexp",
|
||||
"[def @document] [tag regexp]([string \".*blah.+\"]) { [builtin #id] { } }");
|
||||
"[def @document] [variable&callee regexp]([string \".*blah.+\"]) { [builtin #id] { } }");
|
||||
|
||||
MT("counter-style",
|
||||
"[def @counter-style] [variable binary] {",
|
||||
@ -199,11 +207,11 @@
|
||||
"[tag ol][qualifier .roman] { [property list-style]: [variable simple-roman]; }");
|
||||
|
||||
MT("counter-style-symbols",
|
||||
"[tag ol] { [property list-style]: [atom symbols]([atom cyclic] [string \"*\"] [string \"\\2020\"] [string \"\\2021\"] [string \"\\A7\"]); }");
|
||||
"[tag ol] { [property list-style]: [variable&callee symbols]([atom cyclic] [string \"*\"] [string \"\\2020\"] [string \"\\2021\"] [string \"\\A7\"]); }");
|
||||
|
||||
MT("comment-does-not-disrupt",
|
||||
"[def @font-face] [comment /* foo */] {",
|
||||
" [property src]: [atom url]([string x]);",
|
||||
" [property src]: [variable&callee url]([string x]);",
|
||||
" [property font-family]: [variable One];",
|
||||
"}")
|
||||
})();
|
||||
|
7
libraries/codemirror/mode/d/d.js
vendored
7
libraries/codemirror/mode/d/d.js
vendored
@ -182,7 +182,12 @@ CodeMirror.defineMode("d", function(config, parserConfig) {
|
||||
else return ctx.indented + (closing ? 0 : indentUnit);
|
||||
},
|
||||
|
||||
electricChars: "{}"
|
||||
electricChars: "{}",
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/",
|
||||
blockCommentContinue: " * ",
|
||||
lineComment: "//",
|
||||
fold: "brace"
|
||||
};
|
||||
});
|
||||
|
||||
|
2
libraries/codemirror/mode/django/index.html
vendored
2
libraries/codemirror/mode/django/index.html
vendored
@ -11,7 +11,7 @@
|
||||
<script src="../xml/xml.js"></script>
|
||||
<script src="../htmlmixed/htmlmixed.js"></script>
|
||||
<script src="django.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/mode/simple.js"></script>
|
||||
<script src="dockerfile.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
2
libraries/codemirror/mode/dtd/index.html
vendored
2
libraries/codemirror/mode/dtd/index.html
vendored
@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="dtd.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
2
libraries/codemirror/mode/dylan/index.html
vendored
2
libraries/codemirror/mode/dylan/index.html
vendored
@ -10,7 +10,7 @@
|
||||
<script src="../../addon/comment/continuecomment.js"></script>
|
||||
<script src="../../addon/comment/comment.js"></script>
|
||||
<script src="dylan.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
2
libraries/codemirror/mode/ebnf/index.html
vendored
2
libraries/codemirror/mode/ebnf/index.html
vendored
@ -9,7 +9,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../javascript/javascript.js"></script>
|
||||
<script src="ebnf.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>
|
||||
</head>
|
||||
<body>
|
||||
<div id=nav>
|
||||
|
2
libraries/codemirror/mode/elm/index.html
vendored
2
libraries/codemirror/mode/elm/index.html
vendored
@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="elm.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
2
libraries/codemirror/mode/erlang/index.html
vendored
2
libraries/codemirror/mode/erlang/index.html
vendored
@ -9,7 +9,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="erlang.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
2
libraries/codemirror/mode/fortran/index.html
vendored
2
libraries/codemirror/mode/fortran/index.html
vendored
@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="fortran.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
2
libraries/codemirror/mode/gfm/index.html
vendored
2
libraries/codemirror/mode/gfm/index.html
vendored
@ -15,7 +15,7 @@
|
||||
<script src="../htmlmixed/htmlmixed.js"></script>
|
||||
<script src="../clike/clike.js"></script>
|
||||
<script src="../meta.js"></script>
|
||||
<style type="text/css">
|
||||
<style>
|
||||
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
|
||||
.cm-s-default .cm-emoji {color: #009688;}
|
||||
</style>
|
||||
|
2
libraries/codemirror/mode/haskell/index.html
vendored
2
libraries/codemirror/mode/haskell/index.html
vendored
@ -9,7 +9,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="haskell.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
2
libraries/codemirror/mode/haxe/index.html
vendored
2
libraries/codemirror/mode/haxe/index.html
vendored
@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="haxe.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
<script src="../htmlmixed/htmlmixed.js"></script>
|
||||
<script src="../../addon/mode/multiplex.js"></script>
|
||||
<script src="htmlembedded.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
@ -105,7 +105,7 @@
|
||||
return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState));
|
||||
};
|
||||
state.localMode = mode;
|
||||
state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, ""));
|
||||
state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, "", ""));
|
||||
} else if (state.inTag) {
|
||||
state.inTag += stream.current()
|
||||
if (stream.eol()) state.inTag += " "
|
||||
@ -135,7 +135,7 @@
|
||||
|
||||
indent: function (state, textAfter, line) {
|
||||
if (!state.localMode || /^\s*<\//.test(textAfter))
|
||||
return htmlMode.indent(state.htmlState, textAfter);
|
||||
return htmlMode.indent(state.htmlState, textAfter, line);
|
||||
else if (state.localMode.indent)
|
||||
return state.localMode.indent(state.localState, textAfter, line);
|
||||
else
|
||||
|
@ -34,7 +34,7 @@
|
||||
<!-- this is a comment -->
|
||||
<head>
|
||||
<title>Mixed HTML Example</title>
|
||||
<style type="text/css">
|
||||
<style>
|
||||
h1 {font-family: comic sans; color: #f0f;}
|
||||
div {background: yellow !important;}
|
||||
body {
|
||||
|
2
libraries/codemirror/mode/http/index.html
vendored
2
libraries/codemirror/mode/http/index.html
vendored
@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="http.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
2
libraries/codemirror/mode/idl/index.html
vendored
2
libraries/codemirror/mode/idl/index.html
vendored
@ -8,7 +8,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="idl.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
<script src="../../addon/comment/continuecomment.js"></script>
|
||||
<script src="../../addon/comment/comment.js"></script>
|
||||
<script src="javascript.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
@ -365,7 +365,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
}
|
||||
if (type == "function") return cont(functiondef);
|
||||
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
|
||||
if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), className, poplex); }
|
||||
if (type == "class" || (isTS && value == "interface")) {
|
||||
cx.marked = "keyword"
|
||||
return cont(pushlex("form", type == "class" ? type : value), className, poplex)
|
||||
}
|
||||
if (type == "variable") {
|
||||
if (isTS && value == "declare") {
|
||||
cx.marked = "keyword"
|
||||
@ -373,11 +376,11 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
} else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) {
|
||||
cx.marked = "keyword"
|
||||
if (value == "enum") return cont(enumdef);
|
||||
else if (value == "type") return cont(typeexpr, expect("operator"), typeexpr, expect(";"));
|
||||
else if (value == "type") return cont(typename, expect("operator"), typeexpr, expect(";"));
|
||||
else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex)
|
||||
} else if (isTS && value == "namespace") {
|
||||
cx.marked = "keyword"
|
||||
return cont(pushlex("form"), expression, block, poplex)
|
||||
return cont(pushlex("form"), expression, statement, poplex)
|
||||
} else if (isTS && value == "abstract") {
|
||||
cx.marked = "keyword"
|
||||
return cont(statement)
|
||||
@ -552,6 +555,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
}, proceed);
|
||||
}
|
||||
if (type == end || value == end) return cont();
|
||||
if (sep && sep.indexOf(";") > -1) return pass(what)
|
||||
return cont(expect(end));
|
||||
}
|
||||
return function(type, value) {
|
||||
@ -570,7 +574,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
}
|
||||
function maybetype(type, value) {
|
||||
if (isTS) {
|
||||
if (type == ":") return cont(typeexpr);
|
||||
if (type == ":" || value == "in") return cont(typeexpr);
|
||||
if (value == "?") return cont(maybetype);
|
||||
}
|
||||
}
|
||||
@ -587,18 +591,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
}
|
||||
}
|
||||
function typeexpr(type, value) {
|
||||
if (value == "keyof" || value == "typeof") {
|
||||
if (value == "keyof" || value == "typeof" || value == "infer") {
|
||||
cx.marked = "keyword"
|
||||
return cont(value == "keyof" ? typeexpr : expressionNoComma)
|
||||
return cont(value == "typeof" ? expressionNoComma : typeexpr)
|
||||
}
|
||||
if (type == "variable" || value == "void") {
|
||||
cx.marked = "type"
|
||||
return cont(afterType)
|
||||
}
|
||||
if (value == "|" || value == "&") return cont(typeexpr)
|
||||
if (type == "string" || type == "number" || type == "atom") return cont(afterType);
|
||||
if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
|
||||
if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType)
|
||||
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
|
||||
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType)
|
||||
if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr)
|
||||
}
|
||||
function maybeReturnType(type) {
|
||||
@ -608,24 +613,28 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
if (type == "variable" || cx.style == "keyword") {
|
||||
cx.marked = "property"
|
||||
return cont(typeprop)
|
||||
} else if (value == "?") {
|
||||
} else if (value == "?" || type == "number" || type == "string") {
|
||||
return cont(typeprop)
|
||||
} else if (type == ":") {
|
||||
return cont(typeexpr)
|
||||
} else if (type == "[") {
|
||||
return cont(expression, maybetype, expect("]"), typeprop)
|
||||
return cont(expect("variable"), maybetype, expect("]"), typeprop)
|
||||
} else if (type == "(") {
|
||||
return pass(functiondecl, typeprop)
|
||||
}
|
||||
}
|
||||
function typearg(type, value) {
|
||||
if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg)
|
||||
if (type == ":") return cont(typeexpr)
|
||||
if (type == "spread") return cont(typearg)
|
||||
return pass(typeexpr)
|
||||
}
|
||||
function afterType(type, value) {
|
||||
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
|
||||
if (value == "|" || type == "." || value == "&") return cont(typeexpr)
|
||||
if (type == "[") return cont(expect("]"), afterType)
|
||||
if (type == "[") return cont(typeexpr, expect("]"), afterType)
|
||||
if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) }
|
||||
if (value == "?") return cont(typeexpr, expect(":"), typeexpr)
|
||||
}
|
||||
function maybeTypeArgs(_, value) {
|
||||
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
|
||||
@ -655,6 +664,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
if (type == "variable") cx.marked = "property";
|
||||
if (type == "spread") return cont(pattern);
|
||||
if (type == "}") return pass();
|
||||
if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern);
|
||||
return cont(expect(":"), pattern, maybeAssign);
|
||||
}
|
||||
function eltpattern() {
|
||||
@ -671,25 +681,18 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
}
|
||||
function forspec(type, value) {
|
||||
if (value == "await") return cont(forspec);
|
||||
if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
|
||||
if (type == "(") return cont(pushlex(")"), forspec1, poplex);
|
||||
}
|
||||
function forspec1(type) {
|
||||
if (type == "var") return cont(vardef, expect(";"), forspec2);
|
||||
if (type == ";") return cont(forspec2);
|
||||
if (type == "variable") return cont(formaybeinof);
|
||||
return pass(expression, expect(";"), forspec2);
|
||||
}
|
||||
function formaybeinof(_type, value) {
|
||||
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
|
||||
return cont(maybeoperatorComma, forspec2);
|
||||
if (type == "var") return cont(vardef, forspec2);
|
||||
if (type == "variable") return cont(forspec2);
|
||||
return pass(forspec2)
|
||||
}
|
||||
function forspec2(type, value) {
|
||||
if (type == ";") return cont(forspec3);
|
||||
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
|
||||
return pass(expression, expect(";"), forspec3);
|
||||
}
|
||||
function forspec3(type) {
|
||||
if (type != ")") cont(expression);
|
||||
if (type == ")") return cont()
|
||||
if (type == ";") return cont(forspec2)
|
||||
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression, forspec2) }
|
||||
return pass(expression, forspec2)
|
||||
}
|
||||
function functiondef(type, value) {
|
||||
if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
|
||||
@ -697,10 +700,25 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext);
|
||||
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef)
|
||||
}
|
||||
function functiondecl(type, value) {
|
||||
if (value == "*") {cx.marked = "keyword"; return cont(functiondecl);}
|
||||
if (type == "variable") {register(value); return cont(functiondecl);}
|
||||
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, popcontext);
|
||||
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondecl)
|
||||
}
|
||||
function typename(type, value) {
|
||||
if (type == "keyword" || type == "variable") {
|
||||
cx.marked = "type"
|
||||
return cont(typename)
|
||||
} else if (value == "<") {
|
||||
return cont(pushlex(">"), commasep(typeparam, ">"), poplex)
|
||||
}
|
||||
}
|
||||
function funarg(type, value) {
|
||||
if (value == "@") cont(expression, funarg)
|
||||
if (type == "spread") return cont(funarg);
|
||||
if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); }
|
||||
if (isTS && type == "this") return cont(maybetype, maybeAssign)
|
||||
return pass(pattern, maybetype, maybeAssign);
|
||||
}
|
||||
function classExpression(type, value) {
|
||||
@ -731,13 +749,15 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
cx.marked = "property";
|
||||
return cont(isTS ? classfield : functiondef, classBody);
|
||||
}
|
||||
if (type == "number" || type == "string") return cont(isTS ? classfield : functiondef, classBody);
|
||||
if (type == "[")
|
||||
return cont(expression, maybetype, expect("]"), isTS ? classfield : functiondef, classBody)
|
||||
if (value == "*") {
|
||||
cx.marked = "keyword";
|
||||
return cont(classBody);
|
||||
}
|
||||
if (type == ";") return cont(classBody);
|
||||
if (isTS && type == "(") return pass(functiondecl, classBody)
|
||||
if (type == ";" || type == ",") return cont(classBody);
|
||||
if (type == "}") return cont();
|
||||
if (value == "@") return cont(expression, classBody)
|
||||
}
|
||||
@ -745,7 +765,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
if (value == "?") return cont(classfield)
|
||||
if (type == ":") return cont(typeexpr, maybeAssign)
|
||||
if (value == "=") return cont(expressionNoComma)
|
||||
return pass(functiondef)
|
||||
var context = cx.state.lexical.prev, isInterface = context && context.info == "interface"
|
||||
return pass(isInterface ? functiondecl : functiondef)
|
||||
}
|
||||
function afterExport(type, value) {
|
||||
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
|
||||
@ -888,8 +909,6 @@ CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
|
||||
CodeMirror.defineMIME("text/javascript", "javascript");
|
||||
CodeMirror.defineMIME("text/ecmascript", "javascript");
|
||||
CodeMirror.defineMIME("application/javascript", "javascript");
|
||||
CodeMirror.defineMIME("application/javascript;env=frontend", "javascript");
|
||||
CodeMirror.defineMIME("application/javascript;env=backend", "javascript");
|
||||
CodeMirror.defineMIME("application/x-javascript", "javascript");
|
||||
CodeMirror.defineMIME("application/ecmascript", "javascript");
|
||||
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
|
||||
|
@ -10,7 +10,7 @@
|
||||
<script src="../../addon/comment/continuecomment.js"></script>
|
||||
<script src="../../addon/comment/comment.js"></script>
|
||||
<script src="javascript.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"/></a>
|
||||
|
||||
|
12
libraries/codemirror/mode/javascript/test.js
vendored
12
libraries/codemirror/mode/javascript/test.js
vendored
@ -226,6 +226,12 @@
|
||||
" [keyword return] [variable-2 x];",
|
||||
"}");
|
||||
|
||||
MT(
|
||||
"param_destructuring",
|
||||
"[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {",
|
||||
" [keyword return] [variable-2 x];",
|
||||
"}");
|
||||
|
||||
MT("new_target",
|
||||
"[keyword function] [def F]([def target]) {",
|
||||
" [keyword if] ([variable-2 target] [operator &&] [keyword new].[keyword target].[property name]) {",
|
||||
@ -442,6 +448,12 @@
|
||||
TS("abstract class",
|
||||
"[keyword export] [keyword abstract] [keyword class] [def Foo] {}")
|
||||
|
||||
TS("interface without semicolons",
|
||||
"[keyword interface] [def Foo] {",
|
||||
" [property greet]([def x]: [type int]): [type blah]",
|
||||
" [property bar]: [type void]",
|
||||
"}")
|
||||
|
||||
var jsonld_mode = CodeMirror.getMode(
|
||||
{indentUnit: 2},
|
||||
{name: "javascript", jsonld: true}
|
||||
|
@ -8,7 +8,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="javascript.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
2
libraries/codemirror/mode/jinja2/index.html
vendored
2
libraries/codemirror/mode/jinja2/index.html
vendored
@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="jinja2.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
2
libraries/codemirror/mode/jinja2/jinja2.js
vendored
2
libraries/codemirror/mode/jinja2/jinja2.js
vendored
@ -141,4 +141,6 @@
|
||||
blockCommentEnd: "#}"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/jinja2", "jinja2");
|
||||
});
|
||||
|
2
libraries/codemirror/mode/jsx/index.html
vendored
2
libraries/codemirror/mode/jsx/index.html
vendored
@ -9,7 +9,7 @@
|
||||
<script src="../javascript/javascript.js"></script>
|
||||
<script src="../xml/xml.js"></script>
|
||||
<script src="jsx.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
4
libraries/codemirror/mode/jsx/jsx.js
vendored
4
libraries/codemirror/mode/jsx/jsx.js
vendored
@ -32,7 +32,7 @@
|
||||
function flatXMLIndent(state) {
|
||||
var tagName = state.tagName
|
||||
state.tagName = null
|
||||
var result = xmlMode.indent(state, "")
|
||||
var result = xmlMode.indent(state, "", "")
|
||||
state.tagName = tagName
|
||||
return result
|
||||
}
|
||||
@ -105,7 +105,7 @@
|
||||
function jsToken(stream, state, cx) {
|
||||
if (stream.peek() == "<" && jsMode.expressionAllowed(stream, cx.state)) {
|
||||
jsMode.skipExpression(cx.state)
|
||||
state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "")),
|
||||
state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "", "")),
|
||||
xmlMode, 0, state.context)
|
||||
return null
|
||||
}
|
||||
|
2
libraries/codemirror/mode/julia/index.html
vendored
2
libraries/codemirror/mode/julia/index.html
vendored
@ -8,7 +8,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="julia.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
92
libraries/codemirror/mode/julia/julia.js
vendored
92
libraries/codemirror/mode/julia/julia.js
vendored
@ -23,58 +23,50 @@ CodeMirror.defineMode("julia", function(config, parserConf) {
|
||||
var uChar = "([^\\u0027\\u005C\\uD800-\\uDFFF]|[\\uD800-\\uDFFF][\\uDC00-\\uDFFF])";
|
||||
|
||||
var operators = parserConf.operators || wordRegexp([
|
||||
"[<>]:", "[<>=]=", "<<=?", ">>>?=?", "=>", "->", "\\/\\/",
|
||||
"[\\\\%*+\\-<>!=\\/^|&\\u00F7\\u22BB]=?", "\\?", "\\$", "~", ":",
|
||||
"\\u00D7", "\\u2208", "\\u2209", "\\u220B", "\\u220C", "\\u2218",
|
||||
"\\u221A", "\\u221B", "\\u2229", "\\u222A", "\\u2260", "\\u2264",
|
||||
"\\u2265", "\\u2286", "\\u2288", "\\u228A", "\\u22C5",
|
||||
"\\b(in|isa)\\b(?!\.?\\()"], "");
|
||||
"[<>]:", "[<>=]=", "<<=?", ">>>?=?", "=>", "->", "\\/\\/",
|
||||
"[\\\\%*+\\-<>!=\\/^|&\\u00F7\\u22BB]=?", "\\?", "\\$", "~", ":",
|
||||
"\\u00D7", "\\u2208", "\\u2209", "\\u220B", "\\u220C", "\\u2218",
|
||||
"\\u221A", "\\u221B", "\\u2229", "\\u222A", "\\u2260", "\\u2264",
|
||||
"\\u2265", "\\u2286", "\\u2288", "\\u228A", "\\u22C5",
|
||||
"\\b(in|isa)\\b(?!\.?\\()"], "");
|
||||
var delimiters = parserConf.delimiters || /^[;,()[\]{}]/;
|
||||
var identifiers = parserConf.identifiers ||
|
||||
/^[_A-Za-z\u00A1-\u2217\u2219-\uFFFF][\w\u00A1-\u2217\u2219-\uFFFF]*!*/;
|
||||
/^[_A-Za-z\u00A1-\u2217\u2219-\uFFFF][\w\u00A1-\u2217\u2219-\uFFFF]*!*/;
|
||||
|
||||
var chars = wordRegexp([octChar, hexChar, sChar, uChar], "'");
|
||||
|
||||
var commonOpeners = ["begin", "function", "type", "struct", "immutable",
|
||||
"let", "macro", "for", "while", "quote", "if", "else", "elseif", "try",
|
||||
"finally", "catch", "do"];
|
||||
var openersList = ["begin", "function", "type", "struct", "immutable", "let",
|
||||
"macro", "for", "while", "quote", "if", "else", "elseif", "try",
|
||||
"finally", "catch", "do"];
|
||||
|
||||
var commonClosers = ["end", "else", "elseif", "catch", "finally"];
|
||||
var closersList = ["end", "else", "elseif", "catch", "finally"];
|
||||
|
||||
var commonKeywords = ["if", "else", "elseif", "while", "for", "begin",
|
||||
"let", "end", "do", "try", "catch", "finally", "return", "break",
|
||||
"continue", "global", "local", "const", "export", "import", "importall",
|
||||
"using", "function", "where", "macro", "module", "baremodule", "struct",
|
||||
"type", "mutable", "immutable", "quote", "typealias", "abstract",
|
||||
"primitive", "bitstype"];
|
||||
var keywordsList = ["if", "else", "elseif", "while", "for", "begin", "let",
|
||||
"end", "do", "try", "catch", "finally", "return", "break", "continue",
|
||||
"global", "local", "const", "export", "import", "importall", "using",
|
||||
"function", "where", "macro", "module", "baremodule", "struct", "type",
|
||||
"mutable", "immutable", "quote", "typealias", "abstract", "primitive",
|
||||
"bitstype"];
|
||||
|
||||
var commonBuiltins = ["true", "false", "nothing", "NaN", "Inf"];
|
||||
var builtinsList = ["true", "false", "nothing", "NaN", "Inf"];
|
||||
|
||||
CodeMirror.registerHelper("hintWords", "julia", commonKeywords.concat(commonBuiltins));
|
||||
CodeMirror.registerHelper("hintWords", "julia", keywordsList.concat(builtinsList));
|
||||
|
||||
var openers = wordRegexp(commonOpeners);
|
||||
var closers = wordRegexp(commonClosers);
|
||||
var keywords = wordRegexp(commonKeywords);
|
||||
var builtins = wordRegexp(commonBuiltins);
|
||||
var openers = wordRegexp(openersList);
|
||||
var closers = wordRegexp(closersList);
|
||||
var keywords = wordRegexp(keywordsList);
|
||||
var builtins = wordRegexp(builtinsList);
|
||||
|
||||
var macro = /^@[_A-Za-z][\w]*/;
|
||||
var symbol = /^:[_A-Za-z\u00A1-\uFFFF][\w\u00A1-\uFFFF]*!*/;
|
||||
var stringPrefixes = /^(`|([_A-Za-z\u00A1-\uFFFF]*"("")?))/;
|
||||
|
||||
function inArray(state) {
|
||||
return inGenerator(state, '[')
|
||||
return (state.nestedArrays > 0);
|
||||
}
|
||||
|
||||
function inGenerator(state, bracket, depth) {
|
||||
if (typeof(bracket) === "undefined") { bracket = '('; }
|
||||
if (typeof(depth) === "undefined") { depth = 0; }
|
||||
var scope = currentScope(state, depth);
|
||||
if ((depth == 0 && scope === "if" && inGenerator(state, bracket, depth + 1)) ||
|
||||
(scope === "for" && inGenerator(state, bracket, depth + 1)) ||
|
||||
(scope === bracket)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
function inGenerator(state) {
|
||||
return (state.nestedGenerators > 0);
|
||||
}
|
||||
|
||||
function currentScope(state, n) {
|
||||
@ -126,16 +118,19 @@ CodeMirror.defineMode("julia", function(config, parserConf) {
|
||||
|
||||
if (ch === '[') {
|
||||
state.scopes.push('[');
|
||||
state.nestedArrays++;
|
||||
}
|
||||
|
||||
if (ch === '(') {
|
||||
state.scopes.push('(');
|
||||
state.nestedGenerators++;
|
||||
}
|
||||
|
||||
if (inArray(state) && ch === ']') {
|
||||
if (currentScope(state) === "if") { state.scopes.pop(); }
|
||||
while (currentScope(state) === "for") { state.scopes.pop(); }
|
||||
state.scopes.pop();
|
||||
state.nestedArrays--;
|
||||
state.leavingExpr = true;
|
||||
}
|
||||
|
||||
@ -143,6 +138,7 @@ CodeMirror.defineMode("julia", function(config, parserConf) {
|
||||
if (currentScope(state) === "if") { state.scopes.pop(); }
|
||||
while (currentScope(state) === "for") { state.scopes.pop(); }
|
||||
state.scopes.pop();
|
||||
state.nestedGenerators--;
|
||||
state.leavingExpr = true;
|
||||
}
|
||||
|
||||
@ -156,14 +152,12 @@ CodeMirror.defineMode("julia", function(config, parserConf) {
|
||||
}
|
||||
|
||||
var match;
|
||||
if (match = stream.match(openers)) {
|
||||
if (match = stream.match(openers, false)) {
|
||||
state.scopes.push(match[0]);
|
||||
return "keyword";
|
||||
}
|
||||
|
||||
if (stream.match(closers)) {
|
||||
if (stream.match(closers, false)) {
|
||||
state.scopes.pop();
|
||||
return "keyword";
|
||||
}
|
||||
|
||||
// Handle type annotations
|
||||
@ -307,13 +301,13 @@ CodeMirror.defineMode("julia", function(config, parserConf) {
|
||||
function tokenAnnotation(stream, state) {
|
||||
stream.match(/.*?(?=,|;|{|}|\(|\)|=|$|\s)/);
|
||||
if (stream.match(/^{/)) {
|
||||
state.nestedLevels++;
|
||||
} else if (stream.match(/^}/)) {
|
||||
state.nestedLevels--;
|
||||
state.nestedParameters++;
|
||||
} else if (stream.match(/^}/) && state.nestedParameters > 0) {
|
||||
state.nestedParameters--;
|
||||
}
|
||||
if (state.nestedLevels > 0) {
|
||||
if (state.nestedParameters > 0) {
|
||||
stream.match(/.*?(?={|})/) || stream.next();
|
||||
} else if (state.nestedLevels == 0) {
|
||||
} else if (state.nestedParameters == 0) {
|
||||
state.tokenize = tokenBase;
|
||||
}
|
||||
return "builtin";
|
||||
@ -321,14 +315,14 @@ CodeMirror.defineMode("julia", function(config, parserConf) {
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
if (stream.match(/^#=/)) {
|
||||
state.nestedLevels++;
|
||||
state.nestedComments++;
|
||||
}
|
||||
if (!stream.match(/.*?(?=(#=|=#))/)) {
|
||||
stream.skipToEnd();
|
||||
}
|
||||
if (stream.match(/^=#/)) {
|
||||
state.nestedLevels--;
|
||||
if (state.nestedLevels == 0)
|
||||
state.nestedComments--;
|
||||
if (state.nestedComments == 0)
|
||||
state.tokenize = tokenBase;
|
||||
}
|
||||
return "comment";
|
||||
@ -391,7 +385,10 @@ CodeMirror.defineMode("julia", function(config, parserConf) {
|
||||
lastToken: null,
|
||||
leavingExpr: false,
|
||||
isDefinition: false,
|
||||
nestedLevels: 0,
|
||||
nestedArrays: 0,
|
||||
nestedComments: 0,
|
||||
nestedGenerators: 0,
|
||||
nestedParameters: 0,
|
||||
charsAdvanced: 0,
|
||||
firstParenPos: -1
|
||||
};
|
||||
@ -422,6 +419,7 @@ CodeMirror.defineMode("julia", function(config, parserConf) {
|
||||
blockCommentStart: "#=",
|
||||
blockCommentEnd: "=#",
|
||||
lineComment: "#",
|
||||
closeBrackets: "()[]{}\"\"",
|
||||
fold: "indent"
|
||||
};
|
||||
return external;
|
||||
|
@ -9,7 +9,7 @@
|
||||
<script src="../../addon/edit/continuelist.js"></script>
|
||||
<script src="../xml/xml.js"></script>
|
||||
<script src="markdown.js"></script>
|
||||
<style type="text/css">
|
||||
<style>
|
||||
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
|
||||
.cm-s-default .cm-trailing-space-a:before,
|
||||
.cm-s-default .cm-trailing-space-b:before {position: absolute; content: "\00B7"; color: #777;}
|
||||
|
@ -91,7 +91,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
||||
, textRE = /^[^#!\[\]*_\\<>` "'(~:]+/
|
||||
, fencedCodeRE = /^(~~~+|```+)[ \t]*([\w+#-]*)[^\n`]*$/
|
||||
, linkDefRE = /^\s*\[[^\]]+?\]:.*$/ // naive link-definition
|
||||
, punctuation = /[!\"#$%&\'()*+,\-\.\/:;<=>?@\[\\\]^_`{|}~—]/
|
||||
, punctuation = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/
|
||||
, expandedTab = " " // CommonMark specifies tab as 4 spaces
|
||||
|
||||
function switchInline(stream, state, f) {
|
||||
|
4
libraries/codemirror/mode/meta.js
vendored
4
libraries/codemirror/mode/meta.js
vendored
@ -51,7 +51,7 @@
|
||||
{name: "Factor", mime: "text/x-factor", mode: "factor", ext: ["factor"]},
|
||||
{name: "FCL", mime: "text/x-fcl", mode: "fcl"},
|
||||
{name: "Forth", mime: "text/x-forth", mode: "forth", ext: ["forth", "fth", "4th"]},
|
||||
{name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]},
|
||||
{name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90", "f95"]},
|
||||
{name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]},
|
||||
{name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]},
|
||||
{name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
|
||||
@ -75,7 +75,7 @@
|
||||
{name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]},
|
||||
{name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]},
|
||||
{name: "JSX", mime: "text/jsx", mode: "jsx", ext: ["jsx"]},
|
||||
{name: "Jinja2", mime: "null", mode: "jinja2", ext: ["j2", "jinja", "jinja2"]},
|
||||
{name: "Jinja2", mime: "text/jinja2", mode: "jinja2", ext: ["j2", "jinja", "jinja2"]},
|
||||
{name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
|
||||
{name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]},
|
||||
{name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]},
|
||||
|
6
libraries/codemirror/mode/mscgen/mscgen.js
vendored
6
libraries/codemirror/mode/mscgen/mscgen.js
vendored
@ -33,9 +33,9 @@
|
||||
},
|
||||
xu: {
|
||||
"keywords" : ["msc", "xu"],
|
||||
"options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"],
|
||||
"options" : ["hscale", "width", "arcgradient", "wordwraparcs", "wordwrapentities", "watermark"],
|
||||
"constants" : ["true", "false", "on", "off", "auto"],
|
||||
"attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip"],
|
||||
"attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip", "title", "deactivate", "activate", "activation"],
|
||||
"brackets" : ["\\{", "\\}"], // [ and ] are brackets too, but these get handled in with lists
|
||||
"arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"],
|
||||
"arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"],
|
||||
@ -44,7 +44,7 @@
|
||||
},
|
||||
msgenny: {
|
||||
"keywords" : null,
|
||||
"options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"],
|
||||
"options" : ["hscale", "width", "arcgradient", "wordwraparcs", "wordwrapentities", "watermark"],
|
||||
"constants" : ["true", "false", "on", "off", "auto"],
|
||||
"attributes" : null,
|
||||
"brackets" : ["\\{", "\\}"],
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
MT("xù/ msgenny keywords classify as 'base'",
|
||||
"[base watermark]",
|
||||
"[base wordwrapentities]",
|
||||
"[base alt loop opt ref else break par seq assert]"
|
||||
);
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
MT("xù/ msgenny keywords classify as 'keyword'",
|
||||
"[keyword watermark]",
|
||||
"[keyword wordwrapentities]",
|
||||
"[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]"
|
||||
);
|
||||
|
||||
|
7
libraries/codemirror/mode/mscgen/xu_test.js
vendored
7
libraries/codemirror/mode/mscgen/xu_test.js
vendored
@ -60,7 +60,8 @@
|
||||
"[attribute id]","[attribute url]","[attribute idurl]",
|
||||
"[attribute linecolor]","[attribute linecolour]","[attribute textcolor]","[attribute textcolour]","[attribute textbgcolor]","[attribute textbgcolour]",
|
||||
"[attribute arclinecolor]","[attribute arclinecolour]","[attribute arctextcolor]","[attribute arctextcolour]","[attribute arctextbgcolor]","[attribute arctextbgcolour]",
|
||||
"[attribute arcskip][bracket ]]]"
|
||||
"[attribute arcskip]","[attribute title]",
|
||||
"[attribute activate]","[attribute deactivate]","[attribute activation][bracket ]]]"
|
||||
);
|
||||
|
||||
MT("outside an attribute list, attributes classify as base",
|
||||
@ -68,7 +69,7 @@
|
||||
"[base id]","[base url]","[base idurl]",
|
||||
"[base linecolor]","[base linecolour]","[base textcolor]","[base textcolour]","[base textbgcolor]","[base textbgcolour]",
|
||||
"[base arclinecolor]","[base arclinecolour]","[base arctextcolor]","[base arctextcolour]","[base arctextbgcolor]","[base arctextbgcolour]",
|
||||
"[base arcskip]"
|
||||
"[base arcskip]", "[base title]"
|
||||
);
|
||||
|
||||
MT("a typical program",
|
||||
@ -79,7 +80,7 @@
|
||||
"[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]",
|
||||
"[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]",
|
||||
"[base a ][keyword =>>][base b][bracket [[][attribute label][operator =][string \"Hello entity B\"][bracket ]]][base ;]",
|
||||
"[base a ][keyword <<][base b][bracket [[][attribute label][operator =][string \"Here's an answer dude!\"][bracket ]]][base ;]",
|
||||
"[base a ][keyword <<][base b][bracket [[][attribute label][operator =][string \"Here's an answer dude!\"][base , ][attribute title][operator =][string \"This is a title for this message\"][bracket ]]][base ;]",
|
||||
"[base c ][keyword :>][base *][bracket [[][attribute label][operator =][string \"What about me?\"][base , ][attribute textcolor][operator =][base red][bracket ]]][base ;]",
|
||||
"[bracket }]"
|
||||
);
|
||||
|
2
libraries/codemirror/mode/mumps/index.html
vendored
2
libraries/codemirror/mode/mumps/index.html
vendored
@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="mumps.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="ntriples.js"></script>
|
||||
<style type="text/css">
|
||||
<style>
|
||||
.CodeMirror {
|
||||
border: 1px solid #eee;
|
||||
height: auto;
|
||||
|
2
libraries/codemirror/mode/octave/index.html
vendored
2
libraries/codemirror/mode/octave/index.html
vendored
@ -8,7 +8,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="octave.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
4
libraries/codemirror/mode/oz/index.html
vendored
4
libraries/codemirror/mode/oz/index.html
vendored
@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="oz.js"></script>
|
||||
<script type="text/javascript" src="../../addon/runmode/runmode.js"></script>
|
||||
<script src="../../addon/runmode/runmode.js"></script>
|
||||
<style>
|
||||
.CodeMirror {border: 1px solid #aaa;}
|
||||
</style>
|
||||
@ -49,7 +49,7 @@ end
|
||||
</textarea>
|
||||
<p>MIME type defined: <code>text/x-oz</code>.</p>
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
mode: "text/x-oz",
|
||||
|
2
libraries/codemirror/mode/pascal/index.html
vendored
2
libraries/codemirror/mode/pascal/index.html
vendored
@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="pascal.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
2
libraries/codemirror/mode/pegjs/index.html
vendored
2
libraries/codemirror/mode/pegjs/index.html
vendored
@ -9,7 +9,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../javascript/javascript.js"></script>
|
||||
<script src="pegjs.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>
|
||||
</head>
|
||||
<body>
|
||||
<div id=nav>
|
||||
|
2
libraries/codemirror/mode/perl/index.html
vendored
2
libraries/codemirror/mode/perl/index.html
vendored
@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="perl.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
2
libraries/codemirror/mode/php/index.html
vendored
2
libraries/codemirror/mode/php/index.html
vendored
@ -13,7 +13,7 @@
|
||||
<script src="../css/css.js"></script>
|
||||
<script src="../clike/clike.js"></script>
|
||||
<script src="php.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
8
libraries/codemirror/mode/php/php.js
vendored
8
libraries/codemirror/mode/php/php.js
vendored
@ -160,7 +160,7 @@
|
||||
if (!isPHP) {
|
||||
if (stream.match(/^<\?\w*/)) {
|
||||
state.curMode = phpMode;
|
||||
if (!state.php) state.php = CodeMirror.startState(phpMode, htmlMode.indent(state.html, ""))
|
||||
if (!state.php) state.php = CodeMirror.startState(phpMode, htmlMode.indent(state.html, "", ""))
|
||||
state.curState = state.php;
|
||||
return "meta";
|
||||
}
|
||||
@ -213,11 +213,11 @@
|
||||
|
||||
token: dispatch,
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
indent: function(state, textAfter, line) {
|
||||
if ((state.curMode != phpMode && /^\s*<\//.test(textAfter)) ||
|
||||
(state.curMode == phpMode && /^\?>/.test(textAfter)))
|
||||
return htmlMode.indent(state.html, textAfter);
|
||||
return state.curMode.indent(state.curState, textAfter);
|
||||
return htmlMode.indent(state.html, textAfter, line);
|
||||
return state.curMode.indent(state.curState, textAfter, line);
|
||||
},
|
||||
|
||||
blockCommentStart: "/*",
|
||||
|
2
libraries/codemirror/mode/pug/index.html
vendored
2
libraries/codemirror/mode/pug/index.html
vendored
@ -11,7 +11,7 @@
|
||||
<script src="../xml/xml.js"></script>
|
||||
<script src="../htmlmixed/htmlmixed.js"></script>
|
||||
<script src="pug.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
2
libraries/codemirror/mode/python/index.html
vendored
2
libraries/codemirror/mode/python/index.html
vendored
@ -8,7 +8,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="python.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
50
libraries/codemirror/mode/python/python.js
vendored
50
libraries/codemirror/mode/python/python.js
vendored
@ -44,7 +44,7 @@
|
||||
var delimiters = parserConf.delimiters || parserConf.singleDelimiters || /^[\(\)\[\]\{\}@,:`=;\.\\]/;
|
||||
// (Backwards-compatiblity with old, cumbersome config system)
|
||||
var operators = [parserConf.singleOperators, parserConf.doubleOperators, parserConf.doubleDelimiters, parserConf.tripleDelimiters,
|
||||
parserConf.operators || /^([-+*/%\/&|^]=?|[<>=]+|\/\/=?|\*\*=?|!=|[~!@])/]
|
||||
parserConf.operators || /^([-+*/%\/&|^]=?|[<>=]+|\/\/=?|\*\*=?|!=|[~!@]|\.\.\.)/]
|
||||
for (var i = 0; i < operators.length; i++) if (!operators[i]) operators.splice(i--, 1)
|
||||
|
||||
var hangingIndent = parserConf.hangingIndent || conf.indentUnit;
|
||||
@ -144,7 +144,7 @@
|
||||
if (stream.match(stringPrefixes)) {
|
||||
var isFmtString = stream.current().toLowerCase().indexOf('f') !== -1;
|
||||
if (!isFmtString) {
|
||||
state.tokenize = tokenStringFactory(stream.current());
|
||||
state.tokenize = tokenStringFactory(stream.current(), state.tokenize);
|
||||
return state.tokenize(stream, state);
|
||||
} else {
|
||||
state.tokenize = formatStringFactory(stream.current(), state.tokenize);
|
||||
@ -187,23 +187,18 @@
|
||||
var singleline = delimiter.length == 1;
|
||||
var OUTCLASS = "string";
|
||||
|
||||
function tokenFString(stream, state) {
|
||||
// inside f-str Expression
|
||||
if (stream.match(delimiter)) {
|
||||
// expression ends pre-maturally, but very common in editing
|
||||
// Could show error to remind users to close brace here
|
||||
state.tokenize = tokenString
|
||||
return OUTCLASS;
|
||||
} else if (stream.match('{')) {
|
||||
// starting brace, if not eaten below
|
||||
return "punctuation";
|
||||
} else if (stream.match('}')) {
|
||||
// return to regular inside string state
|
||||
state.tokenize = tokenString
|
||||
return "punctuation";
|
||||
} else {
|
||||
// use tokenBaseInner to parse the expression
|
||||
return tokenBaseInner(stream, state);
|
||||
function tokenNestedExpr(depth) {
|
||||
return function(stream, state) {
|
||||
var inner = tokenBaseInner(stream, state)
|
||||
if (inner == "punctuation") {
|
||||
if (stream.current() == "{") {
|
||||
state.tokenize = tokenNestedExpr(depth + 1)
|
||||
} else if (stream.current() == "}") {
|
||||
if (depth > 1) state.tokenize = tokenNestedExpr(depth - 1)
|
||||
else state.tokenize = tokenString
|
||||
}
|
||||
}
|
||||
return inner
|
||||
}
|
||||
}
|
||||
|
||||
@ -222,14 +217,9 @@
|
||||
return OUTCLASS;
|
||||
} else if (stream.match('{', false)) {
|
||||
// switch to nested mode
|
||||
state.tokenize = tokenFString
|
||||
if (stream.current()) {
|
||||
return OUTCLASS;
|
||||
} else {
|
||||
// need to return something, so eat the starting {
|
||||
stream.next();
|
||||
return "punctuation";
|
||||
}
|
||||
state.tokenize = tokenNestedExpr(0)
|
||||
if (stream.current()) return OUTCLASS;
|
||||
else return state.tokenize(stream, state)
|
||||
} else if (stream.match('}}')) {
|
||||
return OUTCLASS;
|
||||
} else if (stream.match('}')) {
|
||||
@ -251,7 +241,7 @@
|
||||
return tokenString;
|
||||
}
|
||||
|
||||
function tokenStringFactory(delimiter) {
|
||||
function tokenStringFactory(delimiter, tokenOuter) {
|
||||
while ("rubf".indexOf(delimiter.charAt(0).toLowerCase()) >= 0)
|
||||
delimiter = delimiter.substr(1);
|
||||
|
||||
@ -266,7 +256,7 @@
|
||||
if (singleline && stream.eol())
|
||||
return OUTCLASS;
|
||||
} else if (stream.match(delimiter)) {
|
||||
state.tokenize = tokenBase;
|
||||
state.tokenize = tokenOuter;
|
||||
return OUTCLASS;
|
||||
} else {
|
||||
stream.eat(/['"]/);
|
||||
@ -276,7 +266,7 @@
|
||||
if (parserConf.singleLineStringErrors)
|
||||
return ERRORCLASS;
|
||||
else
|
||||
state.tokenize = tokenBase;
|
||||
state.tokenize = tokenOuter;
|
||||
}
|
||||
return OUTCLASS;
|
||||
}
|
||||
|
6
libraries/codemirror/mode/python/test.js
vendored
6
libraries/codemirror/mode/python/test.js
vendored
@ -35,4 +35,10 @@
|
||||
MT("fInvalidFString", "[error f'this is wrong}]");
|
||||
MT("fNestedFString", "[string f'expression ]{[number 100] [operator +] [string f'inner]{[number 5]}[string ']}[string string']");
|
||||
MT("uValidStringPrefix", "[string u'this is an unicode string']");
|
||||
|
||||
MT("nestedString", "[string f']{[variable b][[ [string \"c\"] ]]}[string f'] [comment # oops]")
|
||||
|
||||
MT("bracesInFString", "[string f']{[variable x] [operator +] {}}[string !']")
|
||||
|
||||
MT("nestedFString", "[string f']{[variable b][[ [string f\"c\"] ]]}[string f'] [comment # oops]")
|
||||
})();
|
||||
|
2
libraries/codemirror/mode/q/index.html
vendored
2
libraries/codemirror/mode/q/index.html
vendored
@ -8,7 +8,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="q.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
2
libraries/codemirror/mode/r/r.js
vendored
2
libraries/codemirror/mode/r/r.js
vendored
@ -19,7 +19,7 @@ CodeMirror.defineMode("r", function(config) {
|
||||
for (var i = 0; i < words.length; ++i) res[words[i]] = true;
|
||||
return res;
|
||||
}
|
||||
var commonAtoms = ["NULL", "NA", "Inf", "NaN", "NA_integer_", "NA_real_", "NA_complex_", "NA_character_"];
|
||||
var commonAtoms = ["NULL", "NA", "Inf", "NaN", "NA_integer_", "NA_real_", "NA_complex_", "NA_character_", "TRUE", "FALSE"];
|
||||
var commonBuiltins = ["list", "quote", "bquote", "eval", "return", "call", "parse", "deparse"];
|
||||
var commonKeywords = ["if", "else", "repeat", "while", "function", "for", "in", "next", "break"];
|
||||
var commonBlockKeywords = ["if", "else", "repeat", "while", "function", "for"];
|
||||
|
@ -8,7 +8,7 @@
|
||||
<script src="../../../lib/codemirror.js"></script>
|
||||
<script src="changes.js"></script>
|
||||
<link rel="stylesheet" href="../../../doc/docs.css">
|
||||
<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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../../doc/logo.png"></a>
|
||||
|
2
libraries/codemirror/mode/rpm/index.html
vendored
2
libraries/codemirror/mode/rpm/index.html
vendored
@ -8,7 +8,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="rpm.js"></script>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
<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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
2
libraries/codemirror/mode/rst/index.html
vendored
2
libraries/codemirror/mode/rst/index.html
vendored
@ -8,7 +8,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/mode/overlay.js"></script>
|
||||
<script src="rst.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
18
libraries/codemirror/mode/ruby/ruby.js
vendored
18
libraries/codemirror/mode/ruby/ruby.js
vendored
@ -28,7 +28,8 @@ CodeMirror.defineMode("ruby", function(config) {
|
||||
var indentWords = wordObj(["def", "class", "case", "for", "while", "until", "module", "then",
|
||||
"catch", "loop", "proc", "begin"]);
|
||||
var dedentWords = wordObj(["end", "until"]);
|
||||
var matching = {"[": "]", "{": "}", "(": ")"};
|
||||
var opening = {"[": "]", "{": "}", "(": ")"};
|
||||
var closing = {"]": "[", "}": "{", ")": "("};
|
||||
var curPunc;
|
||||
|
||||
function chain(newtok, stream, state) {
|
||||
@ -58,13 +59,13 @@ CodeMirror.defineMode("ruby", function(config) {
|
||||
else if (stream.eat(/[wxq]/)) { style = "string"; embed = false; }
|
||||
var delim = stream.eat(/[^\w\s=]/);
|
||||
if (!delim) return "operator";
|
||||
if (matching.propertyIsEnumerable(delim)) delim = matching[delim];
|
||||
if (opening.propertyIsEnumerable(delim)) delim = opening[delim];
|
||||
return chain(readQuoted(delim, style, embed, true), stream, state);
|
||||
} else if (ch == "#") {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
} else if (ch == "<" && (m = stream.match(/^<-?[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) {
|
||||
return chain(readHereDoc(m[1]), stream, state);
|
||||
} else if (ch == "<" && (m = stream.match(/^<([-~])[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) {
|
||||
return chain(readHereDoc(m[2], m[1]), stream, state);
|
||||
} else if (ch == "0") {
|
||||
if (stream.eat("x")) stream.eatWhile(/[\da-fA-F]/);
|
||||
else if (stream.eat("b")) stream.eatWhile(/[01]/);
|
||||
@ -216,8 +217,9 @@ CodeMirror.defineMode("ruby", function(config) {
|
||||
return style;
|
||||
};
|
||||
}
|
||||
function readHereDoc(phrase) {
|
||||
function readHereDoc(phrase, mayIndent) {
|
||||
return function(stream, state) {
|
||||
if (mayIndent) stream.eatSpace()
|
||||
if (stream.match(phrase)) state.tokenize.pop();
|
||||
else stream.skipToEnd();
|
||||
return "string";
|
||||
@ -276,12 +278,12 @@ CodeMirror.defineMode("ruby", function(config) {
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize[state.tokenize.length-1] != tokenBase) return 0;
|
||||
if (state.tokenize[state.tokenize.length-1] != tokenBase) return CodeMirror.Pass;
|
||||
var firstChar = textAfter && textAfter.charAt(0);
|
||||
var ct = state.context;
|
||||
var closing = ct.type == matching[firstChar] ||
|
||||
var closed = ct.type == closing[firstChar] ||
|
||||
ct.type == "keyword" && /^(?:end|until|else|elsif|when|rescue)\b/.test(textAfter);
|
||||
return ct.indented + (closing ? 0 : config.indentUnit) +
|
||||
return ct.indented + (closed ? 0 : config.indentUnit) +
|
||||
(state.continuedLine ? config.indentUnit : 0);
|
||||
},
|
||||
|
||||
|
7
libraries/codemirror/mode/ruby/test.js
vendored
7
libraries/codemirror/mode/ruby/test.js
vendored
@ -13,4 +13,11 @@
|
||||
|
||||
MT("complex_regexp",
|
||||
"[keyword if] [variable cr] [operator =~] [string-2 /(?: \\( #{][tag RE_NOT][string-2 }\\( | #{][tag RE_NOT_PAR_OR][string-2 }* #{][tag RE_OPA_OR][string-2 } )/][variable x]")
|
||||
|
||||
MT("indented_heredoc",
|
||||
"[keyword def] [def x]",
|
||||
" [variable y] [operator =] [string <<-FOO]",
|
||||
"[string bar]",
|
||||
"[string FOO]",
|
||||
"[keyword end]")
|
||||
})();
|
||||
|
2
libraries/codemirror/mode/rust/index.html
vendored
2
libraries/codemirror/mode/rust/index.html
vendored
@ -8,7 +8,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/mode/simple.js"></script>
|
||||
<script src="rust.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
2
libraries/codemirror/mode/sas/index.html
vendored
2
libraries/codemirror/mode/sas/index.html
vendored
@ -8,7 +8,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../xml/xml.js"></script>
|
||||
<script src="sas.js"></script>
|
||||
<style type="text/css">
|
||||
<style>
|
||||
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
|
||||
.cm-s-default .cm-trailing-space-a:before,
|
||||
.cm-s-default .cm-trailing-space-b:before {position: absolute; content: "\00B7"; color: #777;}
|
||||
|
24
libraries/codemirror/mode/scheme/scheme.js
vendored
24
libraries/codemirror/mode/scheme/scheme.js
vendored
@ -73,7 +73,8 @@ CodeMirror.defineMode("scheme", function () {
|
||||
indentStack: null,
|
||||
indentation: 0,
|
||||
mode: false,
|
||||
sExprComment: false
|
||||
sExprComment: false,
|
||||
sExprQuote: false
|
||||
};
|
||||
},
|
||||
|
||||
@ -121,7 +122,7 @@ CodeMirror.defineMode("scheme", function () {
|
||||
state.sExprComment = 0;
|
||||
}else{
|
||||
// if not we just comment the entire of the next token
|
||||
stream.eatWhile(/[^/s]/); // eat non spaces
|
||||
stream.eatWhile(/[^\s\(\)\[\]]/); // eat symbol atom
|
||||
returnType = COMMENT;
|
||||
break;
|
||||
}
|
||||
@ -133,7 +134,15 @@ CodeMirror.defineMode("scheme", function () {
|
||||
returnType = STRING;
|
||||
|
||||
} else if (ch == "'") {
|
||||
returnType = ATOM;
|
||||
if (stream.peek() == "(" || stream.peek() == "["){
|
||||
if (typeof state.sExprQuote != "number") {
|
||||
state.sExprQuote = 0;
|
||||
} // else already in a quoted expression
|
||||
returnType = ATOM;
|
||||
} else {
|
||||
stream.eatWhile(/[\w_\-!$%&*+\.\/:<=>?@\^~]/);
|
||||
returnType = ATOM;
|
||||
}
|
||||
} else if (ch == '#') {
|
||||
if (stream.eat("|")) { // Multi-line comment
|
||||
state.mode = "comment"; // toggle to comment mode
|
||||
@ -209,6 +218,7 @@ CodeMirror.defineMode("scheme", function () {
|
||||
stream.backUp(stream.current().length - 1); // undo all the eating
|
||||
|
||||
if(typeof state.sExprComment == "number") state.sExprComment++;
|
||||
if(typeof state.sExprQuote == "number") state.sExprQuote++;
|
||||
|
||||
returnType = BRACKET;
|
||||
} else if (ch == ")" || ch == "]") {
|
||||
@ -222,6 +232,12 @@ CodeMirror.defineMode("scheme", function () {
|
||||
state.sExprComment = false; // turn off s-expr commenting mode
|
||||
}
|
||||
}
|
||||
if(typeof state.sExprQuote == "number"){
|
||||
if(--state.sExprQuote == 0){
|
||||
returnType = ATOM; // final closing bracket
|
||||
state.sExprQuote = false; // turn off s-expr quote mode
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
stream.eatWhile(/[\w_\-!$%&*+\.\/:<=>?@\^~]/);
|
||||
@ -231,7 +247,7 @@ CodeMirror.defineMode("scheme", function () {
|
||||
} else returnType = "variable";
|
||||
}
|
||||
}
|
||||
return (typeof state.sExprComment == "number") ? COMMENT : returnType;
|
||||
return (typeof state.sExprComment == "number") ? COMMENT : ((typeof state.sExprQuote == "number") ? ATOM : returnType);
|
||||
},
|
||||
|
||||
indent: function (state) {
|
||||
|
2
libraries/codemirror/mode/smarty/index.html
vendored
2
libraries/codemirror/mode/smarty/index.html
vendored
@ -8,7 +8,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../xml/xml.js"></script>
|
||||
<script src="smarty.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
4
libraries/codemirror/mode/smarty/smarty.js
vendored
4
libraries/codemirror/mode/smarty/smarty.js
vendored
@ -210,9 +210,9 @@
|
||||
state.last = last;
|
||||
return style;
|
||||
},
|
||||
indent: function(state, text) {
|
||||
indent: function(state, text, line) {
|
||||
if (state.tokenize == tokenTop && baseMode.indent)
|
||||
return baseMode.indent(state.base, text);
|
||||
return baseMode.indent(state.base, text, line);
|
||||
else
|
||||
return CodeMirror.Pass;
|
||||
},
|
||||
|
2
libraries/codemirror/mode/solr/index.html
vendored
2
libraries/codemirror/mode/solr/index.html
vendored
@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="solr.js"></script>
|
||||
<style type="text/css">
|
||||
<style>
|
||||
.CodeMirror {
|
||||
border-top: 1px solid black;
|
||||
border-bottom: 1px solid black;
|
||||
|
2
libraries/codemirror/mode/soy/index.html
vendored
2
libraries/codemirror/mode/soy/index.html
vendored
@ -12,7 +12,7 @@
|
||||
<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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
196
libraries/codemirror/mode/soy/soy.js
vendored
196
libraries/codemirror/mode/soy/soy.js
vendored
@ -11,9 +11,43 @@
|
||||
})(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},
|
||||
"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");
|
||||
@ -68,30 +102,38 @@
|
||||
};
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
function popscope(state) {
|
||||
if (state.scopes) {
|
||||
state.variables = state.scopes.element;
|
||||
state.scopes = state.scopes.next;
|
||||
}
|
||||
// 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,
|
||||
quoteKind: null,
|
||||
context: null,
|
||||
localStates: [{
|
||||
mode: modes.html,
|
||||
state: CodeMirror.startState(modes.html)
|
||||
@ -102,12 +144,10 @@
|
||||
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,
|
||||
scopes: state.scopes,
|
||||
context: state.context,
|
||||
indent: state.indent, // Indentation of the following line.
|
||||
quoteKind: state.quoteKind,
|
||||
localStates: state.localStates.map(function(localState) {
|
||||
@ -129,7 +169,7 @@
|
||||
} else {
|
||||
stream.skipToEnd();
|
||||
}
|
||||
if (!state.scopes) {
|
||||
if (!state.context || !state.context.scope) {
|
||||
var paramRe = /@param\??\s+(\S+)/g;
|
||||
var current = stream.current();
|
||||
for (var match; (match = paramRe.exec(current)); ) {
|
||||
@ -162,7 +202,6 @@
|
||||
case "templ-def":
|
||||
if (match = stream.match(/^\.?([\w]+(?!\.[\w]+)*)/)) {
|
||||
state.templates = prepend(state.templates, match[1]);
|
||||
state.scopes = prepend(state.scopes, state.variables);
|
||||
state.soyState.pop();
|
||||
return "def";
|
||||
}
|
||||
@ -170,11 +209,11 @@
|
||||
return null;
|
||||
|
||||
case "templ-ref":
|
||||
if (match = stream.match(/^\.?([\w]+)/)) {
|
||||
if (match = stream.match(/(\.?[a-zA-Z_][a-zA-Z_0-9]+)+/)) {
|
||||
state.soyState.pop();
|
||||
// If the first character is '.', try to match against a local template name.
|
||||
// If the first character is '.', it can only be a local template.
|
||||
if (match[0][0] == '.') {
|
||||
return ref(state.templates, match[1], true);
|
||||
return "variable-2"
|
||||
}
|
||||
// Otherwise
|
||||
return "variable";
|
||||
@ -182,6 +221,14 @@
|
||||
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]);
|
||||
@ -192,13 +239,21 @@
|
||||
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 "variable-3";
|
||||
if (stream.eatWhile(/^([\w]+|[?])/)) {
|
||||
return "type";
|
||||
}
|
||||
stream.next();
|
||||
return null;
|
||||
@ -213,29 +268,31 @@
|
||||
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(/^\/?}/)) {
|
||||
var selfClosed = stream.current() == "/}";
|
||||
if (selfClosed && !endTag) {
|
||||
popcontext(state);
|
||||
}
|
||||
if (state.tag == "/template" || state.tag == "/deltemplate") {
|
||||
popscope(state);
|
||||
state.variables = prepend(null, 'ij');
|
||||
state.indent = 0;
|
||||
} else {
|
||||
if (state.tag == "/for" || state.tag == "/foreach") {
|
||||
popscope(state);
|
||||
}
|
||||
state.indent -= config.indentUnit *
|
||||
(stream.current() == "/}" || indentingTags.indexOf(state.tag) == -1 ? 2 : 1);
|
||||
(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))) {
|
||||
var kind = match[1];
|
||||
state.kind.push(kind);
|
||||
state.kindTag.push(state.tag);
|
||||
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.indent += localState.mode.indent(localState.state, "", "");
|
||||
}
|
||||
state.localStates.push({
|
||||
mode: mode,
|
||||
@ -243,11 +300,22 @@
|
||||
});
|
||||
}
|
||||
return "attribute";
|
||||
} 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]);
|
||||
}
|
||||
@ -269,41 +337,49 @@
|
||||
if (stream.match(/^\{literal}/)) {
|
||||
state.indent += config.indentUnit;
|
||||
state.soyState.push("literal");
|
||||
state.context = new Context(state.context, "literal", state.variables);
|
||||
return "keyword";
|
||||
|
||||
// A tag-keyword must be followed by whitespace, comment or a closing tag.
|
||||
} else if (match = stream.match(/^\{([/@\\]?\w+\??)(?=$|[\s}]|\/[/*])/)) {
|
||||
if (match[1] != "/switch")
|
||||
state.indent += (/^(\/|(else|elseif|ifempty|case|fallbackmsg|default)$)/.test(match[1]) && state.tag != "switch" ? 1 : 2) * config.indentUnit;
|
||||
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.localStates.pop();
|
||||
var localState = last(state.localStates);
|
||||
if (localState.mode.indent) {
|
||||
state.indent -= localState.mode.indent(localState.state, "");
|
||||
}
|
||||
}
|
||||
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");
|
||||
if (state.tag == "template" || state.tag == "deltemplate") {
|
||||
state.soyState.push("templ-def");
|
||||
} else if (state.tag == "call" || state.tag == "delcall") {
|
||||
state.soyState.push("templ-ref");
|
||||
} else if (state.tag == "let") {
|
||||
state.soyState.push("var-def");
|
||||
} else if (state.tag == "for" || state.tag == "foreach") {
|
||||
state.scopes = prepend(state.scopes, state.variables);
|
||||
state.soyState.push("var-def");
|
||||
} else if (state.tag == "namespace") {
|
||||
if (!state.scopes) {
|
||||
state.variables = prepend(null, 'ij');
|
||||
var tagError = false;
|
||||
if (tag) {
|
||||
if (!endTag) {
|
||||
if (tag.soyState) state.soyState.push(tag.soyState);
|
||||
}
|
||||
} else if (state.tag.match(/^@(?:param\??|inject)/)) {
|
||||
state.soyState.push("param-def");
|
||||
// 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 "keyword";
|
||||
return (tagError ? "error " : "") + "keyword";
|
||||
|
||||
// Not a tag-keyword; it's an implicit print tag.
|
||||
} else if (stream.eat('{')) {
|
||||
@ -316,7 +392,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;
|
||||
|
||||
@ -330,7 +406,7 @@
|
||||
}
|
||||
var localState = last(state.localStates);
|
||||
if (indent && localState.mode.indent) {
|
||||
indent += localState.mode.indent(localState.state, textAfter);
|
||||
indent += localState.mode.indent(localState.state, textAfter, line);
|
||||
}
|
||||
return indent;
|
||||
},
|
||||
@ -350,8 +426,10 @@
|
||||
};
|
||||
}, "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");
|
||||
});
|
||||
|
117
libraries/codemirror/mode/soy/test.js
vendored
117
libraries/codemirror/mode/soy/test.js
vendored
@ -8,7 +8,7 @@
|
||||
// Test of small keywords and words containing them.
|
||||
MT('keywords-test',
|
||||
'[keyword {] [keyword as] worrying [keyword and] notorious [keyword as]',
|
||||
' the Fandor-alias assassin, [keyword or]',
|
||||
' the Fandor[operator -]alias assassin, [keyword or]',
|
||||
' Corcand cannot fit [keyword in] [keyword }]');
|
||||
|
||||
MT('let-test',
|
||||
@ -20,18 +20,63 @@
|
||||
'[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]: ' +
|
||||
'[variable-3 list]<[[[variable-3 a]: [variable-3 int], ' +
|
||||
'[variable-3 b]: [variable-3 map]<[variable-3 string], ' +
|
||||
'[variable-3 bool]>]]>][keyword }]');
|
||||
'[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]: [variable-3 string][keyword }]',
|
||||
' [keyword {@param] [def x]: [type string][keyword }]',
|
||||
' [keyword {][variable-2 $x][keyword }]',
|
||||
'[keyword {/template}]',
|
||||
'',
|
||||
@ -48,7 +93,7 @@
|
||||
|
||||
MT('defined-if-variable-test',
|
||||
'[keyword {template] [def .foo][keyword }]',
|
||||
' [keyword {@param?] [def showThing]: [variable-3 bool][keyword }]',
|
||||
' [keyword {@param?] [def showThing]: [type bool][keyword }]',
|
||||
' [keyword {if] [variable-2 $showThing][keyword }]',
|
||||
' Yo!',
|
||||
' [keyword {/if}]',
|
||||
@ -56,17 +101,15 @@
|
||||
'');
|
||||
|
||||
MT('template-calls-test',
|
||||
'[keyword {template] [def .foo][keyword }]',
|
||||
' Yo!',
|
||||
'[keyword {/template}]',
|
||||
'[keyword {call] [variable-2 .foo][keyword /}]',
|
||||
'[keyword {call] [variable foo][keyword /}]',
|
||||
'[keyword {call] [variable .bar][keyword /}]',
|
||||
'[keyword {call] [variable bar][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]: [variable-3 string][keyword }]',
|
||||
'[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}]',
|
||||
@ -84,8 +127,8 @@
|
||||
MT('nested-kind-test',
|
||||
'[keyword {template] [def .foo] [attribute kind]=[string "html"][keyword }]',
|
||||
' [tag&bracket <][tag div][tag&bracket >]',
|
||||
' [keyword {call] [variable .bar][keyword }]',
|
||||
' [keyword {param] [attribute kind]=[string "js"][keyword }]',
|
||||
' [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}]',
|
||||
@ -94,14 +137,14 @@
|
||||
'');
|
||||
|
||||
MT('tag-starting-with-function-call-is-not-a-keyword',
|
||||
'[keyword {]index([variable-2&error $foo])[keyword }]',
|
||||
'[keyword {][callee&variable index]([variable-2&error $foo])[keyword }]',
|
||||
'[keyword {css] [string "some-class"][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] [variable-3 bool][keyword }]',
|
||||
' [keyword {@param] [def showThing] [type bool][keyword }]',
|
||||
' [keyword {if] [variable-2 $showThing][keyword }]',
|
||||
' Yo!',
|
||||
' [keyword {/if}]',
|
||||
@ -118,4 +161,44 @@
|
||||
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 }]');
|
||||
})();
|
||||
|
@ -8,7 +8,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="spreadsheet.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
36
libraries/codemirror/mode/sql/sql.js
vendored
36
libraries/codemirror/mode/sql/sql.js
vendored
File diff suppressed because one or more lines are too long
68
libraries/codemirror/mode/swift/index.html
vendored
68
libraries/codemirror/mode/swift/index.html
vendored
@ -28,50 +28,32 @@
|
||||
<article>
|
||||
<h2>Swift mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
//
|
||||
// TipCalculatorModel.swift
|
||||
// TipCalculator
|
||||
//
|
||||
// Created by Main Account on 12/18/14.
|
||||
// Copyright (c) 2014 Razeware LLC. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class TipCalculatorModel {
|
||||
|
||||
var total: Double
|
||||
var taxPct: Double
|
||||
var subtotal: Double {
|
||||
get {
|
||||
return total / (taxPct + 1)
|
||||
}
|
||||
}
|
||||
|
||||
init(total: Double, taxPct: Double) {
|
||||
self.total = total
|
||||
self.taxPct = taxPct
|
||||
}
|
||||
|
||||
func calcTipWithTipPct(tipPct: Double) -> Double {
|
||||
return subtotal * tipPct
|
||||
}
|
||||
|
||||
func returnPossibleTips() -> [Int: Double] {
|
||||
|
||||
let possibleTipsInferred = [0.15, 0.18, 0.20]
|
||||
let possibleTipsExplicit:[Double] = [0.15, 0.18, 0.20]
|
||||
|
||||
var retval = [Int: Double]()
|
||||
for possibleTip in possibleTipsInferred {
|
||||
let intPct = Int(possibleTip*100)
|
||||
retval[intPct] = calcTipWithTipPct(possibleTip)
|
||||
}
|
||||
return retval
|
||||
|
||||
}
|
||||
|
||||
protocol HeaderViewProtocol {
|
||||
func setTitle(_ string: String)
|
||||
}
|
||||
|
||||
struct AnyHeaderView {
|
||||
let view: UIView
|
||||
let headerView: HeaderViewProtocol
|
||||
init<T: UIView>(view: T) where T: HeaderViewProtocol {
|
||||
self.view = view
|
||||
self.headerView = view
|
||||
}
|
||||
}
|
||||
|
||||
let header = AnyHeaderView(view: myView)
|
||||
header.headerView.setTitle("hi")
|
||||
|
||||
struct HeaderView {
|
||||
let view: UIView
|
||||
let setTitle: (String) -> ()
|
||||
}
|
||||
|
||||
var label = UILabel()
|
||||
let header = HeaderView(view: label) { str in
|
||||
label.text = str
|
||||
}
|
||||
header.setTitle("hello")
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
|
42
libraries/codemirror/mode/swift/swift.js
vendored
42
libraries/codemirror/mode/swift/swift.js
vendored
@ -73,9 +73,9 @@
|
||||
stream.match("..")
|
||||
return "punctuation"
|
||||
}
|
||||
if (ch == '"' || ch == "'") {
|
||||
stream.next()
|
||||
var tokenize = tokenString(ch)
|
||||
var stringMatch
|
||||
if (stringMatch = stream.match(/("""|"|')/)) {
|
||||
var tokenize = tokenString.bind(null, stringMatch[0])
|
||||
state.tokenize.push(tokenize)
|
||||
return tokenize(stream, state)
|
||||
}
|
||||
@ -116,25 +116,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var ch, escaped = false
|
||||
while (ch = stream.next()) {
|
||||
if (escaped) {
|
||||
if (ch == "(") {
|
||||
state.tokenize.push(tokenUntilClosingParen())
|
||||
return "string"
|
||||
}
|
||||
escaped = false
|
||||
} else if (ch == quote) {
|
||||
break
|
||||
} else {
|
||||
escaped = ch == "\\"
|
||||
function tokenString(openQuote, stream, state) {
|
||||
var singleLine = openQuote.length == 1
|
||||
var ch, escaped = false
|
||||
while (ch = stream.peek()) {
|
||||
if (escaped) {
|
||||
stream.next()
|
||||
if (ch == "(") {
|
||||
state.tokenize.push(tokenUntilClosingParen())
|
||||
return "string"
|
||||
}
|
||||
escaped = false
|
||||
} else if (stream.match(openQuote)) {
|
||||
state.tokenize.pop()
|
||||
return "string"
|
||||
} else {
|
||||
stream.next()
|
||||
escaped = ch == "\\"
|
||||
}
|
||||
state.tokenize.pop()
|
||||
return "string"
|
||||
}
|
||||
if (singleLine) {
|
||||
state.tokenize.pop()
|
||||
}
|
||||
return "string"
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
|
8
libraries/codemirror/mode/swift/test.js
vendored
8
libraries/codemirror/mode/swift/test.js
vendored
@ -35,7 +35,13 @@
|
||||
// Strings and string interpolation.
|
||||
MT("strings",
|
||||
"[keyword var] [def a][punctuation :] [variable-2 String] [operator =] [string \"test\"]",
|
||||
"[keyword var] [def b][punctuation :] [variable-2 String] [operator =] [string \"\\(][variable a][string )\"]");
|
||||
"[keyword var] [def b][punctuation :] [variable-2 String] [operator =] [string \"\\(][variable a][string )\"]",
|
||||
"[keyword var] [def c] [operator =] [string \"\"\"]",
|
||||
"[string multi]",
|
||||
"[string line]",
|
||||
"[string \"test\"]",
|
||||
"[string \"\"\"]",
|
||||
"[variable print][punctuation (][string \"\"][punctuation )]");
|
||||
|
||||
// Comments.
|
||||
MT("comments",
|
||||
|
@ -9,7 +9,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="tiddlywiki.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
4
libraries/codemirror/mode/tiki/index.html
vendored
4
libraries/codemirror/mode/tiki/index.html
vendored
@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="tiki.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="tiki.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
@ -85,7 +85,7 @@ Plugin (inline):
|
||||
{plugin attr="my attr"}
|
||||
</textarea></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: 'tiki',
|
||||
lineNumbers: true
|
||||
|
2
libraries/codemirror/mode/toml/index.html
vendored
2
libraries/codemirror/mode/toml/index.html
vendored
@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="toml.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
2
libraries/codemirror/mode/tornado/index.html
vendored
2
libraries/codemirror/mode/tornado/index.html
vendored
@ -10,7 +10,7 @@
|
||||
<script src="../xml/xml.js"></script>
|
||||
<script src="../htmlmixed/htmlmixed.js"></script>
|
||||
<script src="tornado.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="ttcn-cfg.js"></script>
|
||||
<style type="text/css">
|
||||
<style>
|
||||
.CodeMirror {
|
||||
border-top: 1px solid black;
|
||||
border-bottom: 1px solid black;
|
||||
|
2
libraries/codemirror/mode/ttcn/index.html
vendored
2
libraries/codemirror/mode/ttcn/index.html
vendored
@ -8,7 +8,7 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="ttcn.js"></script>
|
||||
<style type="text/css">
|
||||
<style>
|
||||
.CodeMirror {
|
||||
border-top: 1px solid black;
|
||||
border-bottom: 1px solid black;
|
||||
|
2
libraries/codemirror/mode/twig/index.html
vendored
2
libraries/codemirror/mode/twig/index.html
vendored
@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="twig.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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user