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

Function to_normal

static/editor.md/lib/codemirror/mode/rst/rst.js:156–351  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

154 ///////////////////////////////////////////////////////////////////////////
155
156 function to_normal(stream, state) {
157 var token = null;
158
159 if (stream.sol() && stream.match(rx_examples, false)) {
160 change(state, to_mode, {
161 mode: mode_python, local: CodeMirror.startState(mode_python)
162 });
163 } else if (stream.sol() && stream.match(rx_explicit)) {
164 change(state, to_explicit);
165 token = 'meta';
166 } else if (stream.sol() && stream.match(rx_section)) {
167 change(state, to_normal);
168 token = 'header';
169 } else if (phase(state) == rx_role_pre ||
170 stream.match(rx_role_pre, false)) {
171
172 switch (stage(state)) {
173 case 0:
174 change(state, to_normal, context(rx_role_pre, 1));
175 stream.match(/^:/);
176 token = 'meta';
177 break;
178 case 1:
179 change(state, to_normal, context(rx_role_pre, 2));
180 stream.match(rx_NAME);
181 token = 'keyword';
182
183 if (stream.current().match(/^(?:math|latex)/)) {
184 state.tmp_stex = true;
185 }
186 break;
187 case 2:
188 change(state, to_normal, context(rx_role_pre, 3));
189 stream.match(/^:`/);
190 token = 'meta';
191 break;
192 case 3:
193 if (state.tmp_stex) {
194 state.tmp_stex = undefined; state.tmp = {
195 mode: mode_stex, local: CodeMirror.startState(mode_stex)
196 };
197 }
198
199 if (state.tmp) {
200 if (stream.peek() == '`') {
201 change(state, to_normal, context(rx_role_pre, 4));
202 state.tmp = undefined;
203 break;
204 }
205
206 token = state.tmp.mode.token(stream, state.tmp.local);
207 break;
208 }
209
210 change(state, to_normal, context(rx_role_pre, 4));
211 stream.match(rx_TEXT2);
212 token = 'string';
213 break;

Callers

nothing calls this directly

Calls 4

phaseFunction · 0.85
stageFunction · 0.85
contextFunction · 0.85
changeFunction · 0.70

Tested by

no test coverage detected