private void generateCodeValue(PsiInlineDocTag tag, StringBuilder buffer) {
    boolean isCodeBlock = isCodeBlock(tag);

    if (isCodeBlock) {
      // remove excess whitespaces between tags e.g. in `<pre>  {@code`
      int lastNonWhite = buffer.length() - 1;
      while (Character.isWhitespace(buffer.charAt(lastNonWhite))) lastNonWhite--;
      buffer.setLength(lastNonWhite + 1);
      // Remove preceding <pre> fragment
      StringUtil.trimEnd(buffer, "<pre>");
    }

    buffer.append(isCodeBlock ? CODE_BLOCK_PREFIX : INLINE_CODE_PREFIX);
    int pos = buffer.length();

    StringBuilder codeSnippetBuilder = new StringBuilder();
    generateLiteralValue(codeSnippetBuilder, tag, false);
    String codeSnippet = codeSnippetBuilder.toString();
    if (isCodeBlock) {
      codeSnippet = StringsKt.trimIndent(codeSnippet);
    }

    if (isCodeBlock && doHighlightCodeBlocks()
        || !isCodeBlock && getInlineCodeHighlightingMode() == InlineCodeHighlightingMode.SEMANTIC_HIGHLIGHTING) {
      // highlights code by lexer
      codeSnippetBuilder.setLength(0);
      appendHighlightedByLexerAndEncodedAsHtmlCodeSnippet(true, codeSnippetBuilder, tag.getProject(), tag.getLanguage(), codeSnippet);
      codeSnippet = codeSnippetBuilder.toString();
    }
    else {
      codeSnippet = XmlStringUtil.escapeString(codeSnippet);
    }

    if (!isCodeBlock) {
      // we are in inline @code block, we should remove all new lines
      codeSnippet = codeSnippet.replace(BR_TAG, "");
    }

    buffer.append(codeSnippet);
    buffer.append(isCodeBlock ? CODE_BLOCK_SUFFIX : INLINE_CODE_SUFFIX);
    if (buffer.charAt(pos) == '\n') buffer.insert(pos, ' '); // line break immediately after opening tag is ignored by JEditorPane
  }
private void generateCodeValue(PsiInlineDocTag tag, StringBuilder buffer)