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

Function inMathMode

static/editor.md/lib/codemirror/mode/stex/stex.js:160–203  ·  view source on GitHub ↗
(source, state, endModeSeq)

Source from the content-addressed store, hash-verified

158 }
159
160 function inMathMode(source, state, endModeSeq) {
161 if (source.eatSpace()) {
162 return null;
163 }
164 if (source.match(endModeSeq)) {
165 setState(state, normal);
166 return "keyword";
167 }
168 if (source.match(/^\\[a-zA-Z@]+/)) {
169 return "tag";
170 }
171 if (source.match(/^[a-zA-Z]+/)) {
172 return "variable-2";
173 }
174 // escape characters
175 if (source.match(/^\\[$&%#{}_]/)) {
176 return "tag";
177 }
178 // white space control characters
179 if (source.match(/^\\[,;!\/]/)) {
180 return "tag";
181 }
182 // special math-mode characters
183 if (source.match(/^[\^_&]/)) {
184 return "tag";
185 }
186 // non-special characters
187 if (source.match(/^[+\-<>|=,\/@!*:;'"`~#?]/)) {
188 return null;
189 }
190 if (source.match(/^(\d+\.\d*|\d*\.\d+|\d+)/)) {
191 return "number";
192 }
193 var ch = source.next();
194 if (ch == "{" || ch == "}" || ch == "[" || ch == "]" || ch == "(" || ch == ")") {
195 return "bracket";
196 }
197
198 if (ch == "%") {
199 source.skipToEnd();
200 return "comment";
201 }
202 return "error";
203 }
204
205 function beginParams(source, state) {
206 var ch = source.peek(), lastPlug;

Callers 1

normalFunction · 0.85

Calls 1

setStateFunction · 0.85

Tested by

no test coverage detected