MCPcopy Create free account
hub / github.com/TruthHun/BookStack / tokenBase

Function tokenBase

static/editor.md/lib/codemirror/mode/velocity/velocity.js:32–127  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

30 return f(stream, state);
31 }
32 function tokenBase(stream, state) {
33 var beforeParams = state.beforeParams;
34 state.beforeParams = false;
35 var ch = stream.next();
36 // start of unparsed string?
37 if ((ch == "'") && state.inParams) {
38 state.lastTokenWasBuiltin = false;
39 return chain(stream, state, tokenString(ch));
40 }
41 // start of parsed string?
42 else if ((ch == '"')) {
43 state.lastTokenWasBuiltin = false;
44 if (state.inString) {
45 state.inString = false;
46 return "string";
47 }
48 else if (state.inParams)
49 return chain(stream, state, tokenString(ch));
50 }
51 // is it one of the special signs []{}().,;? Seperator?
52 else if (/[\[\]{}\(\),;\.]/.test(ch)) {
53 if (ch == "(" && beforeParams)
54 state.inParams = true;
55 else if (ch == ")") {
56 state.inParams = false;
57 state.lastTokenWasBuiltin = true;
58 }
59 return null;
60 }
61 // start of a number value?
62 else if (/\d/.test(ch)) {
63 state.lastTokenWasBuiltin = false;
64 stream.eatWhile(/[\w\.]/);
65 return "number";
66 }
67 // multi line comment?
68 else if (ch == "#" && stream.eat("*")) {
69 state.lastTokenWasBuiltin = false;
70 return chain(stream, state, tokenComment);
71 }
72 // unparsed content?
73 else if (ch == "#" && stream.match(/ *\[ *\[/)) {
74 state.lastTokenWasBuiltin = false;
75 return chain(stream, state, tokenUnparsed);
76 }
77 // single line comment?
78 else if (ch == "#" && stream.eat("#")) {
79 state.lastTokenWasBuiltin = false;
80 stream.skipToEnd();
81 return "comment";
82 }
83 // variable?
84 else if (ch == "$") {
85 stream.eatWhile(/[\w\d\$_\.{}]/);
86 // is it one of the specials?
87 if (specials && specials.propertyIsEnumerable(stream.current())) {
88 return "keyword";
89 }

Callers

nothing calls this directly

Calls 2

chainFunction · 0.70
tokenStringFunction · 0.70

Tested by

no test coverage detected