docs: private static String embedCssIntoHtmlSlow(
        String css, int nextReplacement, boolean searchForEndCData, boolean searchForEndTag) {
      // use an array instead of a stringbuilder so we can take advantage of the bulk copying
      // routine (String.getChars).  For some reason StringBuilder doesn't do this.
      char[] buf = new char[css.length() + 16];
      int endOfPreviousReplacement = 0;
      int bufIndex = 0;
      do {
        int charsToCopy = nextReplacement - endOfPreviousReplacement;
        buf = Chars.ensureCapacity(buf, bufIndex + charsToCopy + 4, 16);
        css.getChars(endOfPreviousReplacement, nextReplacement, buf, bufIndex);
        bufIndex += charsToCopy;
        char c = css.charAt(nextReplacement);
        if (c == ']') {
          buf[bufIndex++] = ']';
          buf[bufIndex++] = ']';
          buf[bufIndex++] = '\\';
          buf[bufIndex++] = '>';
          endOfPreviousReplacement = nextReplacement + 3;
        } else if (c == '<') {
          buf[bufIndex++] = '<';
          buf[bufIndex++] = '\\';
          buf[bufIndex++] = '/';
          endOfPreviousReplacement = nextReplacement + 2;
        } else {
          throw new AssertionError();
        }
        nextReplacement = -1;
        if (searchForEndTag) {
          int indexOfEndTag = css.indexOf("</", endOfPreviousReplacement);
          if (indexOfEndTag == -1) {
            searchForEndTag = false;
          } else {
            nextReplacement = indexOfEndTag;
          }
        }
        if (searchForEndCData) {
          int indexOfEndCData = css.indexOf("]]>", endOfPreviousReplacement);
          if (indexOfEndCData == -1) {
            searchForEndCData = false;
          } else {
            nextReplacement =
                nextReplacement == -1 ? indexOfEndCData : Math.min(nextReplacement, indexOfEndCData);
          }
        }
      } while (nextReplacement != -1);
      // copy tail
      int charsToCopy = css.length() - endOfPreviousReplacement;
      buf = Chars.ensureCapacity(buf, bufIndex + charsToCopy, 16);
      css.getChars(endOfPreviousReplacement, css.length(), buf, bufIndex);
      bufIndex += charsToCopy;
      return new String(buf, 0, bufIndex);
    }