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

Function tokenBase

static/editor.md/lib/codemirror/mode/clike/clike.js:29–73  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

27 var curPunc;
28
29 function tokenBase(stream, state) {
30 var ch = stream.next();
31 if (hooks[ch]) {
32 var result = hooks[ch](stream, state);
33 if (result !== false) return result;
34 }
35 if (ch == '"' || ch == "'") {
36 state.tokenize = tokenString(ch);
37 return state.tokenize(stream, state);
38 }
39 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
40 curPunc = ch;
41 return null;
42 }
43 if (/\d/.test(ch)) {
44 stream.eatWhile(/[\w\.]/);
45 return "number";
46 }
47 if (ch == "/") {
48 if (stream.eat("*")) {
49 state.tokenize = tokenComment;
50 return tokenComment(stream, state);
51 }
52 if (stream.eat("/")) {
53 stream.skipToEnd();
54 return "comment";
55 }
56 }
57 if (isOperatorChar.test(ch)) {
58 stream.eatWhile(isOperatorChar);
59 return "operator";
60 }
61 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
62 var cur = stream.current();
63 if (keywords.propertyIsEnumerable(cur)) {
64 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
65 return "keyword";
66 }
67 if (builtin.propertyIsEnumerable(cur)) {
68 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
69 return "builtin";
70 }
71 if (atoms.propertyIsEnumerable(cur)) return "atom";
72 return "variable";
73 }
74
75 function tokenString(quote) {
76 return function(stream, state) {

Callers

nothing calls this directly

Calls 2

tokenStringFunction · 0.70
tokenCommentFunction · 0.70

Tested by

no test coverage detected