| 354 | /////////////////////////////////////////////////////////////////////////// |
| 355 | |
| 356 | function to_explicit(stream, state) { |
| 357 | var token = null; |
| 358 | |
| 359 | if (phase(state) == rx_substitution || |
| 360 | stream.match(rx_substitution, false)) { |
| 361 | |
| 362 | switch (stage(state)) { |
| 363 | case 0: |
| 364 | change(state, to_explicit, context(rx_substitution, 1)); |
| 365 | stream.match(rx_substitution_text); |
| 366 | token = 'variable-2'; |
| 367 | break; |
| 368 | case 1: |
| 369 | change(state, to_explicit, context(rx_substitution, 2)); |
| 370 | stream.match(rx_substitution_sepa); |
| 371 | break; |
| 372 | case 2: |
| 373 | change(state, to_explicit, context(rx_substitution, 3)); |
| 374 | stream.match(rx_substitution_name); |
| 375 | token = 'keyword'; |
| 376 | break; |
| 377 | case 3: |
| 378 | change(state, to_explicit, context(rx_substitution, 4)); |
| 379 | stream.match(rx_substitution_tail); |
| 380 | token = 'meta'; |
| 381 | break; |
| 382 | default: |
| 383 | change(state, to_normal); |
| 384 | } |
| 385 | } else if (phase(state) == rx_directive || |
| 386 | stream.match(rx_directive, false)) { |
| 387 | |
| 388 | switch (stage(state)) { |
| 389 | case 0: |
| 390 | change(state, to_explicit, context(rx_directive, 1)); |
| 391 | stream.match(rx_directive_name); |
| 392 | token = 'keyword'; |
| 393 | |
| 394 | if (stream.current().match(/^(?:math|latex)/)) |
| 395 | state.tmp_stex = true; |
| 396 | else if (stream.current().match(/^python/)) |
| 397 | state.tmp_py = true; |
| 398 | break; |
| 399 | case 1: |
| 400 | change(state, to_explicit, context(rx_directive, 2)); |
| 401 | stream.match(rx_directive_tail); |
| 402 | token = 'meta'; |
| 403 | |
| 404 | if (stream.match(/^latex\s*$/) || state.tmp_stex) { |
| 405 | state.tmp_stex = undefined; change(state, to_mode, { |
| 406 | mode: mode_stex, local: CodeMirror.startState(mode_stex) |
| 407 | }); |
| 408 | } |
| 409 | break; |
| 410 | case 2: |
| 411 | change(state, to_explicit, context(rx_directive, 3)); |
| 412 | if (stream.match(/^python\s*$/) || state.tmp_py) { |
| 413 | state.tmp_py = undefined; change(state, to_mode, { |