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

Function tokenBase

static/editor.md/lib/codemirror/mode/css/css.js:35–88  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

33 // Tokenizers
34
35 function tokenBase(stream, state) {
36 var ch = stream.next();
37 if (tokenHooks[ch]) {
38 var result = tokenHooks[ch](stream, state);
39 if (result !== false) return result;
40 }
41 if (ch == "@") {
42 stream.eatWhile(/[\w\\\-]/);
43 return ret("def", stream.current());
44 } else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) {
45 return ret(null, "compare");
46 } else if (ch == "\"" || ch == "'") {
47 state.tokenize = tokenString(ch);
48 return state.tokenize(stream, state);
49 } else if (ch == "#") {
50 stream.eatWhile(/[\w\\\-]/);
51 return ret("atom", "hash");
52 } else if (ch == "!") {
53 stream.match(/^\s*\w*/);
54 return ret("keyword", "important");
55 } else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
56 stream.eatWhile(/[\w.%]/);
57 return ret("number", "unit");
58 } else if (ch === "-") {
59 if (/[\d.]/.test(stream.peek())) {
60 stream.eatWhile(/[\w.%]/);
61 return ret("number", "unit");
62 } else if (stream.match(/^-[\w\\\-]+/)) {
63 stream.eatWhile(/[\w\\\-]/);
64 if (stream.match(/^\s*:/, false))
65 return ret("variable-2", "variable-definition");
66 return ret("variable-2", "variable");
67 } else if (stream.match(/^\w+-/)) {
68 return ret("meta", "meta");
69 }
70 } else if (/[,+>*\/]/.test(ch)) {
71 return ret(null, "select-op");
72 } else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
73 return ret("qualifier", "qualifier");
74 } else if (/[:;{}\[\]\(\)]/.test(ch)) {
75 return ret(null, ch);
76 } else if ((ch == "u" && stream.match(/rl(-prefix)?\(/)) ||
77 (ch == "d" && stream.match("omain(")) ||
78 (ch == "r" && stream.match("egexp("))) {
79 stream.backUp(1);
80 state.tokenize = tokenParenthesized;
81 return ret("property", "word");
82 } else if (/[\w\\\-]/.test(ch)) {
83 stream.eatWhile(/[\w\\\-]/);
84 return ret("property", "word");
85 } else {
86 return ret(null, null);
87 }
88 }
89
90 function tokenString(quote) {
91 return function(stream, state) {

Callers

nothing calls this directly

Calls 2

retFunction · 0.70
tokenStringFunction · 0.70

Tested by

no test coverage detected