function (tokens, stateMachine) {
    // Recreate the argument string from KaTeX's array of tokens.
    var str = "";
    var expectedLoc = tokens[tokens.length - 1].loc.start
    for (var i = tokens.length - 1; i >= 0; i--) {
      if(tokens[i].loc.start > expectedLoc) {
        // context.consumeArgs has eaten a space.
        str += " ";
        expectedLoc = tokens[i].loc.start;
      }
      str += tokens[i].text;
      expectedLoc += tokens[i].text.length;
    }
    var tex = texify.go(mhchemParser.go(str, stateMachine));
    return tex;
  }
function (tokens, stateMachine) {
    // Recreate the argument string from KaTeX's array of tokens.
    var str = "";
    var expectedLoc = tokens[tokens.length - 1].loc.start
    for (var i = tokens.length - 1; i >= 0; i--) {
      if(tokens[i].loc.start > expectedLoc) {
        // context.consumeArgs has eaten a space.
        str += " ";
        expectedLoc = tokens[i].loc.start;
      }
      str += tokens[i].text;
      expectedLoc += tokens[i].text.length;
    }
    var tex = texify.go(mhchemParser.go(str, stateMachine));
    return tex;
  }
function ( tokens , stateMachine ) { // Recreate the argument string from KaTeX's array of tokens. var str = "" ; var expectedLoc = tokens [ tokens . length - 1 ] . loc . start for ( var i = tokens . length - 1 ; i >= 0 ; i -- ) { if ( tokens [ i ] . loc . start > expectedLoc ) { // context.consumeArgs has eaten a space. str += " " ; expectedLoc = tokens [ i ] . loc . start ; } str += tokens [ i ] . text ; expectedLoc += tokens [ i ] . text . length ; } var tex = texify . go ( mhchemParser . go ( str , stateMachine ) ) ; return tex ; }
This is the main function for handing the \ce and \pu commands. It takes the argument to \ce or \pu and returns the corresponding TeX string.
This is the main function for handing the \ ce and \ pu commands . It takes the argument to \ ce or \ pu and returns the corresponding TeX string .
Parse a KaTeX string