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

Function normal

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

Source from the content-addressed store, hash-verified

91
92 // called when in a normal (no environment) context
93 function normal(source, state) {
94 var plug;
95 // Do we look like '\command' ? If so, attempt to apply the plugin 'command'
96 if (source.match(/^\\[a-zA-Z@]+/)) {
97 var cmdName = source.current().slice(1);
98 plug = plugins[cmdName] || plugins["DEFAULT"];
99 plug = new plug();
100 pushCommand(state, plug);
101 setState(state, beginParams);
102 return plug.style;
103 }
104
105 // escape characters
106 if (source.match(/^\\[$&%#{}_]/)) {
107 return "tag";
108 }
109
110 // white space control characters
111 if (source.match(/^\\[,;!\/\\]/)) {
112 return "tag";
113 }
114
115 // find if we're starting various math modes
116 if (source.match("\\[")) {
117 setState(state, function(source, state){ return inMathMode(source, state, "\\]"); });
118 return "keyword";
119 }
120 if (source.match("$$")) {
121 setState(state, function(source, state){ return inMathMode(source, state, "$$"); });
122 return "keyword";
123 }
124 if (source.match("$")) {
125 setState(state, function(source, state){ return inMathMode(source, state, "$"); });
126 return "keyword";
127 }
128
129 var ch = source.next();
130 if (ch == "%") {
131 source.skipToEnd();
132 return "comment";
133 } else if (ch == '}' || ch == ']') {
134 plug = peekCommand(state);
135 if (plug) {
136 plug.closeBracket(ch);
137 setState(state, beginParams);
138 } else {
139 return "error";
140 }
141 return "bracket";
142 } else if (ch == '{' || ch == '[') {
143 plug = plugins["DEFAULT"];
144 plug = new plug();
145 pushCommand(state, plug);
146 return "bracket";
147 } else if (/\d/.test(ch)) {
148 source.eatWhile(/[\w.%]/);
149 return "atom";
150 } else {

Callers 1

beginParamsFunction · 0.70

Calls 5

pushCommandFunction · 0.85
setStateFunction · 0.85
inMathModeFunction · 0.85
peekCommandFunction · 0.85
getMostPowerfulFunction · 0.85

Tested by

no test coverage detected