function doBeginMatch(match) {
          const lexeme = match[0];
          const newMode = match.rule;

          const resp = new Response(newMode);
          // first internal before callbacks, then the public ones
          const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]];
          for (const cb of beforeCallbacks) {
            if (!cb) continue;
            cb(match, resp);
            if (resp.ignore) return doIgnore(lexeme);
          }

          if (newMode && newMode.endSameAsBegin) {
            newMode.endRe = escape(lexeme);
          }

          if (newMode.skip) {
            modeBuffer += lexeme;
          } else {
            if (newMode.excludeBegin) {
              modeBuffer += lexeme;
            }
            processBuffer();
            if (!newMode.returnBegin && !newMode.excludeBegin) {
              modeBuffer = lexeme;
            }
          }
          startNewMode(newMode);
          // if (mode["after:begin"]) {
          //   let resp = new Response(mode);
          //   mode["after:begin"](match, resp);
          // }
          return newMode.returnBegin ? 0 : lexeme.length;
        }
/**
         * Handle the start of a new potential mode match
         *
         * @param {EnhancedMatch} match - the current match
         * @returns {number} how far to advance the parse cursor
         */
Handle the start of a new potential mode match
@param {EnhancedMatch} match - the current match
@returns {number} how far to advance the parse cursor
Handle the start of a new potential mode match @param { EnhancedMatch } match - the current match @returns { number } how far to advance the parse cursor
function doBeginMatch(match) {
          const lexeme = match[0];
          const newMode = match.rule;
          const resp = new Response(newMode);
          const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]];
          for (const cb of beforeCallbacks) {
            if (!cb) continue;
            cb(match, resp);
            if (resp.ignore) return doIgnore(lexeme);
          }
          if (newMode && newMode.endSameAsBegin) {
            newMode.endRe = escape(lexeme);
          }
          if (newMode.skip) {
            modeBuffer += lexeme;
          } else {
            if (newMode.excludeBegin) {
              modeBuffer += lexeme;
            }
            processBuffer();
            if (!newMode.returnBegin && !newMode.excludeBegin) {
              modeBuffer = lexeme;
            }
          }
          startNewMode(newMode);
          return newMode.returnBegin ? 0 : lexeme.length;
        }
function doBeginMatch ( match ) { const lexeme = match [ 0 ] ; const newMode = match . rule ; const resp = new Response ( newMode ) ; const beforeCallbacks = [ newMode . __beforeBegin , newMode [ "on:begin" ] ] ; for ( const cb of beforeCallbacks ) { if ( ! cb ) continue ; cb ( match , resp ) ; if ( resp . ignore ) return doIgnore ( lexeme ) ; } if ( newMode && newMode . endSameAsBegin ) { newMode . endRe = escape ( lexeme ) ; } if ( newMode . skip ) { modeBuffer += lexeme ; } else { if ( newMode . excludeBegin ) { modeBuffer += lexeme ; } processBuffer ( ) ; if ( ! newMode . returnBegin && ! newMode . excludeBegin ) { modeBuffer = lexeme ; } } startNewMode ( newMode ) ; return newMode . returnBegin ? 0 : lexeme . length ; }
Handle the start of a new potential mode match
 @param {EnhancedMatch} match - the current match
 @returns {number} how far to advance the parse cursor
Handle the start of a new potential mode match @param { EnhancedMatch } match - the current match @returns { number } how far to advance the parse cursor
// first internal before callbacks, then the public ones // if (mode["after:begin"]) { //   let resp = new Response(mode); //   mode["after:begin"](match, resp); // }