code: private void format(Stream outer, String arg) {
      // Iterate over text and tags, alternately.
      int prev = outer.pos;
      int length = outer.end;
      int next = -1;
  
      // Anchor to the starting '{'.
      while ((next = outer.find('{')) != -1) {
        // Emit characters before the tag's opening '{'
        if (next > prev) {
          emit(prev, next, arg);
          prev = next;
        }
  
        // Locate a tag's bounds and evaluate it. Otherwise return, since we've
        // found a possibly incomplete tag and cannot correctly recover.
        if (outer.seekBounds(tag, '{', '}')) {
          prev = tag.end;
          evaluateTag(buf);
        } else {
          return;
        }
      }
  
      // Copy the remaining trailing characters, if any.
      if (prev < length) {
        emit(prev, length, arg);
      }
    }
docs: Format the current stream, with the optional substitution argument, replacing '#'.