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

Function tokenBase

static/editor.md/lib/codemirror/mode/sieve/sieve.js:25–110  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

23 var indentUnit = config.indentUnit;
24
25 function tokenBase(stream, state) {
26
27 var ch = stream.next();
28 if (ch == "/" && stream.eat("*")) {
29 state.tokenize = tokenCComment;
30 return tokenCComment(stream, state);
31 }
32
33 if (ch === '#') {
34 stream.skipToEnd();
35 return "comment";
36 }
37
38 if (ch == "\"") {
39 state.tokenize = tokenString(ch);
40 return state.tokenize(stream, state);
41 }
42
43 if (ch == "(") {
44 state._indent.push("(");
45 // add virtual angel wings so that editor behaves...
46 // ...more sane incase of broken brackets
47 state._indent.push("{");
48 return null;
49 }
50
51 if (ch === "{") {
52 state._indent.push("{");
53 return null;
54 }
55
56 if (ch == ")") {
57 state._indent.pop();
58 state._indent.pop();
59 }
60
61 if (ch === "}") {
62 state._indent.pop();
63 return null;
64 }
65
66 if (ch == ",")
67 return null;
68
69 if (ch == ";")
70 return null;
71
72
73 if (/[{}\(\),;]/.test(ch))
74 return null;
75
76 // 1*DIGIT "K" / "M" / "G"
77 if (/\d/.test(ch)) {
78 stream.eatWhile(/[\d]/);
79 stream.eat(/[KkMmGg]/);
80 return "number";
81 }
82

Callers

nothing calls this directly

Calls 2

tokenCCommentFunction · 0.70
tokenStringFunction · 0.70

Tested by

no test coverage detected