code: private String escapeCodeText(String text) {
      String lowerText = text.toLowerCase();
      int preStart = lowerText.indexOf("<pre>");
      int preEnd = lowerText.indexOf("</pre>");
      if (preStart == -1 && preEnd == -1) {
        return text;
      }
      if (preStart >= 0 && preEnd >= 0 && preEnd < preStart) {
        // Bad code formatting, don't try to escape.
        return text;
      }
  
      // Separately test begin and end tags, to support a span with multiple Javadoc tags.
      StringBuilder sb = new StringBuilder();
      if (preStart > -1 && preEnd > -1) {
        // Both <pre> and </pre> are in the same text segment.
        sb.append(text.substring(0, preStart));
        if (preStart > 0) {
          sb.append('\n');
        }
        sb.append("@code\n");
        sb.append(text.substring(preStart + "<pre>".length(), preEnd));
        sb.append("\n@endcode");
        sb.append(text.substring(preEnd + "</pre>".length()));
      } else if (preStart > -1) {
        // The text has <pre> but not the </pre> should be in a following Javadoc tag.
        sb.append(text.substring(0, preStart));
        if (preStart > 0) {
          sb.append('\n');
        }
        sb.append("@code\n");
        sb.append(text.substring(preStart + "<pre>".length()));
        spanningPreTag = true;
      } else {
        // The text just has a </pre>.
        sb.append("\n@endcode");
        sb.append(text.substring(preEnd + "</pre>".length()));
        spanningPreTag = false;
      }
      return escapeCodeText(sb.toString());  // Allow for multiple <pre> spans in single text element.
    }
docs: If a string has a <pre> tag, or is continuing one from another
  tag, convert to @code/@endcode format.