docs: function to_explicit(stream, state) {
      var token = null;
  
      if (phase(state) == rx_substitution ||
          stream.match(rx_substitution, false)) {
  
        switch (stage(state)) {
        case 0:
          change(state, to_explicit, context(rx_substitution, 1));
          assert(stream.match(rx_substitution_text));
          token = 'variable-2';
          break;
        case 1:
          change(state, to_explicit, context(rx_substitution, 2));
          assert(stream.match(rx_substitution_sepa));
          break;
        case 2:
          change(state, to_explicit, context(rx_substitution, 3));
          assert(stream.match(rx_substitution_name));
          token = 'keyword';
          break;
        case 3:
          change(state, to_explicit, context(rx_substitution, 4));
          assert(stream.match(rx_substitution_tail));
          token = 'meta';
          break;
        default:
          change(state, to_normal);
          assert(stream.current() == '');
        }
      } else if (phase(state) == rx_directive ||
                 stream.match(rx_directive, false)) {
  
        switch (stage(state)) {
        case 0:
          change(state, to_explicit, context(rx_directive, 1));
          assert(stream.match(rx_directive_name));
          token = 'keyword';
  
          if (stream.current().match(/^(?:math|latex)/))
            state.tmp_stex = true;
          else if (stream.current().match(/^python/))
            state.tmp_py = true;
          break;
        case 1:
          change(state, to_explicit, context(rx_directive, 2));
          assert(stream.match(rx_directive_tail));
          token = 'meta';
  
          if (stream.match(/^latex\s*$/) || state.tmp_stex) {
            state.tmp_stex = undefined; change(state, to_mode, {
              mode: mode_stex, local: CodeMirror.startState(mode_stex)
            });
          }
          break;
        case 2:
          change(state, to_explicit, context(rx_directive, 3));
          if (stream.match(/^python\s*$/) || state.tmp_py) {
            state.tmp_py = undefined; change(state, to_mode, {
              mode: mode_python, local: CodeMirror.startState(mode_python)
            });
          }
          break;
        default:
          change(state, to_normal);
          assert(stream.current() == '');
        }
      } else if (phase(state) == rx_link || stream.match(rx_link, false)) {
  
        switch (stage(state)) {
        case 0:
          change(state, to_explicit, context(rx_link, 1));
          assert(stream.match(rx_link_head));
          assert(stream.match(rx_link_name));
          token = 'link';
          break;
        case 1:
          change(state, to_explicit, context(rx_link, 2));
          assert(stream.match(rx_link_tail));
          token = 'meta';
          break;
        default:
          change(state, to_normal);
          assert(stream.current() == '');
        }
      } else if (stream.match(rx_footnote)) {
        change(state, to_normal);
        token = 'quote';
      } else if (stream.match(rx_citation)) {
        change(state, to_normal);
        token = 'quote';
      }
  
      else {
        stream.eatSpace();
        if (stream.eol()) {
          change(state, to_normal);
        } else {
          stream.skipToEnd();
          change(state, to_comment);
          token = 'comment';
        }
      }
  
      return token;
    }