String (@NotNull SnippetMarkup snippet, @Nullable String region) { StringBuilder content = new StringBuilder(); snippet.visitSnippet(region, true, new SnippetMarkup.SnippetVisitor() { @Override public void visitPlainText(SnippetMarkup.@NotNull PlainText plainText, @NotNull List<SnippetMarkup.@NotNull LocationMarkupNode> activeNodes) { if (plainText.content().isEmpty()) { // Empty content = tag was on a given line. In most of the cases, javadoc tool considers such a line as content content.append("\n"); } else { content.append(plainText.content()); } } @Override public void visitError(SnippetMarkup.@NotNull ErrorMarkup errorMarkup) { } }); return content.toString().stripTrailing().replaceAll("[ \t]+\n", "\n"); }