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

Function tokenBase

static/editor.md/lib/codemirror/mode/nginx/nginx.js:38–95  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

36 function ret(style, tp) {type = tp; return style;}
37
38 function tokenBase(stream, state) {
39
40
41 stream.eatWhile(/[\w\$_]/);
42
43 var cur = stream.current();
44
45
46 if (keywords.propertyIsEnumerable(cur)) {
47 return "keyword";
48 }
49 else if (keywords_block.propertyIsEnumerable(cur)) {
50 return "variable-2";
51 }
52 else if (keywords_important.propertyIsEnumerable(cur)) {
53 return "string-2";
54 }
55 /**/
56
57 var ch = stream.next();
58 if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("meta", stream.current());}
59 else if (ch == "/" && stream.eat("*")) {
60 state.tokenize = tokenCComment;
61 return tokenCComment(stream, state);
62 }
63 else if (ch == "<" && stream.eat("!")) {
64 state.tokenize = tokenSGMLComment;
65 return tokenSGMLComment(stream, state);
66 }
67 else if (ch == "=") ret(null, "compare");
68 else if ((ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "compare");
69 else if (ch == "\"" || ch == "'") {
70 state.tokenize = tokenString(ch);
71 return state.tokenize(stream, state);
72 }
73 else if (ch == "#") {
74 stream.skipToEnd();
75 return ret("comment", "comment");
76 }
77 else if (ch == "!") {
78 stream.match(/^\s*\w*/);
79 return ret("keyword", "important");
80 }
81 else if (/\d/.test(ch)) {
82 stream.eatWhile(/[\w.%]/);
83 return ret("number", "unit");
84 }
85 else if (/[,.+>*\/]/.test(ch)) {
86 return ret(null, "select-op");
87 }
88 else if (/[;{}:\[\]]/.test(ch)) {
89 return ret(null, ch);
90 }
91 else {
92 stream.eatWhile(/[\w\\\-]/);
93 return ret("variable", "variable");
94 }
95 }

Callers

nothing calls this directly

Calls 4

retFunction · 0.70
tokenCCommentFunction · 0.70
tokenSGMLCommentFunction · 0.70
tokenStringFunction · 0.70

Tested by

no test coverage detected