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

Function tokenBase

static/editor.md/lib/codemirror/mode/sass/sass.js:120–354  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

118 }
119
120 function tokenBase(stream, state) {
121 var ch = stream.peek();
122
123 // Comment
124 if (stream.match("/*")) {
125 state.tokenizer = comment(stream.indentation(), true);
126 return state.tokenizer(stream, state);
127 }
128 if (stream.match("//")) {
129 state.tokenizer = comment(stream.indentation(), false);
130 return state.tokenizer(stream, state);
131 }
132
133 // Interpolation
134 if (stream.match("#{")) {
135 state.tokenizer = buildInterpolationTokenizer(tokenBase);
136 return "operator";
137 }
138
139 // Strings
140 if (ch === '"' || ch === "'") {
141 stream.next();
142 state.tokenizer = buildStringTokenizer(ch);
143 return "string";
144 }
145
146 if(!state.cursorHalf){// state.cursorHalf === 0
147 // first half i.e. before : for key-value pairs
148 // including selectors
149
150 if (ch === ".") {
151 stream.next();
152 if (stream.match(/^[\w-]+/)) {
153 indent(state);
154 return "atom";
155 } else if (stream.peek() === "#") {
156 indent(state);
157 return "atom";
158 }
159 }
160
161 if (ch === "#") {
162 stream.next();
163 // ID selectors
164 if (stream.match(/^[\w-]+/)) {
165 indent(state);
166 return "atom";
167 }
168 if (stream.peek() === "#") {
169 indent(state);
170 return "atom";
171 }
172 }
173
174 // Variables
175 if (ch === "$") {
176 stream.next();
177 stream.eatWhile(/[\w-]/);

Callers 2

commentFunction · 0.70

Calls 5

commentFunction · 0.70
buildStringTokenizerFunction · 0.70
indentFunction · 0.70
dedentFunction · 0.70

Tested by

no test coverage detected