code: @VisibleForTesting
    static String embedCssIntoHtml(String css) {
      // `</style` can close a containing style element in HTML.
      // `]]>` can similarly close a CDATA element in XHTML.
  
      // Scan for "</" and "]]>" and escape enough to remove the token seen by
      // the HTML parser.
  
      // For well-formed CSS, these string might validly appear in a few contexts:
      // 1. comments
      // 2. string bodies
      // 3. url(...) bodies.
  
      // Appending \ should be semantics preserving in comments and string bodies.
      // This may not be semantics preserving in url content.
      // The substring "]>" can validly appear in a selector
      //   a[href]>b
      // but the substring "]]>" cannot.
  
      // This should not affect how a CSS parser recovers from syntax errors.
      int indexOfEndTag = css.indexOf("</");
      int indexOfEndCData = css.indexOf("]]>");
      if (indexOfEndTag != -1) {
        if (indexOfEndCData != -1) {
          return embedCssIntoHtmlSlow(
              css,
              Math.min(indexOfEndTag, indexOfEndCData),
              /* searchForEndCData= */ true,
              /* searchForEndTag= */ true);
        }
        return embedCssIntoHtmlSlow(
            css, indexOfEndTag, /* searchForEndCData= */ false, /* searchForEndTag= */ true);
      } else if (indexOfEndCData != -1) {
        return embedCssIntoHtmlSlow(
            css, indexOfEndCData, /* searchForEndCData= */ true, /* searchForEndTag= */ false);
      }
      return css;
    }
docs: Make sure that tag boundaries are not broken by Safe CSS when embedded in a {@code <style>}
  element.