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

Function dispatch

static/editor.md/lib/codemirror/mode/php/php.js:152–185  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

150 var phpMode = CodeMirror.getMode(config, phpConfig);
151
152 function dispatch(stream, state) {
153 var isPHP = state.curMode == phpMode;
154 if (stream.sol() && state.pending && state.pending != '"' && state.pending != "'") state.pending = null;
155 if (!isPHP) {
156 if (stream.match(/^<\?\w*/)) {
157 state.curMode = phpMode;
158 state.curState = state.php;
159 return "meta";
160 }
161 if (state.pending == '"' || state.pending == "'") {
162 while (!stream.eol() && stream.next() != state.pending) {}
163 var style = "string";
164 } else if (state.pending && stream.pos < state.pending.end) {
165 stream.pos = state.pending.end;
166 var style = state.pending.style;
167 } else {
168 var style = htmlMode.token(stream, state.curState);
169 }
170 if (state.pending) state.pending = null;
171 var cur = stream.current(), openPHP = cur.search(/<\?/), m;
172 if (openPHP != -1) {
173 if (style == "string" && (m = cur.match(/[\'\"]$/)) && !/\?>/.test(cur)) state.pending = m[0];
174 else state.pending = {end: stream.pos, style: style};
175 stream.backUp(cur.length - openPHP);
176 }
177 return style;
178 } else if (isPHP && state.php.tokenize == null && stream.match("?>")) {
179 state.curMode = htmlMode;
180 state.curState = state.html;
181 return "meta";
182 } else {
183 return phpMode.token(stream, state.curState);
184 }
185 }
186
187 return {
188 startState: function() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected